Tuesday, November 5, 2013

ELB Multi AZ and Nginx Proxy

Recently I found out that my nginx proxy is not making use of the multi AZ feature of my Amazon ELB.

They way multiple availability zones in an ELB works is basically adding a A record to the existing ELB for round robin resolution on each area (50 - 50). Nginx, by default, will cache the initial response of the ELB as the parameter proxy_buffering is default enabled. Setting it to Off, it will stop caching the response and start to balance across all the AZs.

proxy_buffering off;
Another way would be set the cache to expire in 1 minute:

I have not really tried the following one throughout, but we could enable our other AZ instances only for specific locations with proxy_cache_bypass. In my configuration would be:
 location /place-with-heavy-load { 
 [...]
set $no_cache 1;
[...]
location / {
 [...]
 proxy_cache_bypass $no_cache;
 proxy_pass http://my-elb-at-aws.com;
[...]

No comments:

Post a Comment