I'm not sure how "hash $cachekey" works...
Roman Arutyunyan
arut at nginx.com
Thu Jan 21 16:05:41 UTC 2016
Hi,
> On 21 Jan 2016, at 15:41, highclass99 <highclass99 at gmail.com> wrote:
>
> I have a question about "hash $cachekey" consistent;
> Would the following Config 1, Config 2, Config 3 be exactly the same of different?
> i.e. if I swap the configurations would the cache keys stay consistent?
> The reason I am asking is I have a large configuration similar to Config 2 and am not sure it would be "safe" to clean up the order and merge duplicates as weighted config values.
>
> Thank you.
>
> Would the following be different of the same?
> Config 1:
> upstream ImageCluster {
> server 10.1.1.1;
> server 10.1.1.1;
> server 10.1.1.2;
> server 10.1.1.2;
> server 10.1.1.3;
> server 10.1.1.3;
>
> hash $cachekey consistent;
> }
>
> Config 2:
> upstream ImageCluster {
> server 10.1.1.2;
> server 10.1.1.2;
> server 10.1.1.1;
> server 10.1.1.1;
> server 10.1.1.3;
> server 10.1.1.3;
>
> hash $cachekey consistent;
> }
These two are the same. With consistent hash balancer the order of servers
does not matter.
> Config 3:
> upstream ImageCluster {
> server 10.1.1.1 weight=2;
> server 10.1.1.2 weight=2;
> server 10.1.1.3 weight=2;
>
> hash $cachekey consistent;
> }
This one is different.
With Config1 and Config2 you have 160 hash points per each server (duplicates are removed).
With Config3 you have 320 points per each server.
Statistically all configurations are similar.
--
Roman Arutyunyan
More information about the nginx
mailing list