{"id":715,"date":"2020-07-29T01:45:21","date_gmt":"2020-07-28T20:15:21","guid":{"rendered":"http:\/\/www.cyberaka.com\/?p=715"},"modified":"2020-07-29T01:46:08","modified_gmt":"2020-07-28T20:16:08","slug":"nginx-gzip-compression-and-load-balancing","status":"publish","type":"post","link":"https:\/\/www.cyberaka.com\/?p=715","title":{"rendered":"Nginx gzip compression and load balancing."},"content":{"rendered":"\n<p>To tune performance of my REST endpoints in past I have enabled Gzip compression in my nginx server configuration. So technically a large json response becomes gzipped and the network latency as a result goes down. <\/p>\n\n\n\n<p>There is a good documentation of this feature on the <a href=\"https:\/\/docs.nginx.com\/nginx\/admin-guide\/web-server\/compression\/#:~:text=To%20enable%20compression%2C%20include%20the,and%20list%20the%20additional%20types.\">nginx website<\/a> which does a pretty good job.<\/p>\n\n\n\n<p>However there is a catch which prevents this technique from working on local development system (while the same config works in production linux instance). I finally found <a href=\"https:\/\/serverfault.com\/questions\/818549\/nginx-gzip-not-working\">an answer<\/a> as to why this doesn&#8217;t work in some of my local environment. <\/p>\n\n\n\n<p>To do static load balancing I use the upstream concept of nginx which is documented again on the <a href=\"http:\/\/nginx.org\/en\/docs\/http\/ngx_http_upstream_module.html\">nginx website<\/a>. The performance is reasonable and the implementation is quite simple for a requirement which needs a simple failover implementation. However for advanced implementation we can always go to <a href=\"http:\/\/www.haproxy.org\/\">haproxy<\/a> which is very good open source load balancer. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>To tune performance of my REST endpoints in past I have enabled Gzip compression in my nginx server configuration. So technically a large json response becomes gzipped and the network latency as a result goes down. There is a good documentation of this feature on the nginx website which does a pretty good job. However [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69,30],"tags":[],"class_list":["post-715","post","type-post","status-publish","format-standard","hentry","category-microservices","category-thoughts"],"_links":{"self":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/715","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=715"}],"version-history":[{"count":2,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/715\/revisions"}],"predecessor-version":[{"id":717,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/715\/revisions\/717"}],"wp:attachment":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=715"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=715"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}