Bala's Blog


Varnish config for caching

Varnish is one of the powerful caching used widely.

The below config is the basic config for varnish

backend default {

.host = “”;
.port = “8071”;

It should be added in the default.vcl in /etc/varnish/default.vcl

Then it should be restarted by using

sudo varnishd -f /etc/varnish/default.vcl start

The main advantage of varnish caching is , It is very powerful for serving dynamic content.

more config to follow/……………

Nginx Config for load balancing ( using UPStream module)

Upstream module in nginx gives the way for load balancing.

The below is the nginx config for load balancing two redis slaves

upstream app_cluster_1 {

server {
server_name nodetest.local nodetest;
access_log /var/log/nginx/nodetest.log;
error_log /var/log/nginx/nodetesterrot.log;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;

proxy_pass http://app_cluster_1/;
proxy_redirect off;


HAProxy Config for Load balancing the servers

I tried using HAPRoxy for load balancing between the app servers as well as the database slaves.

The generic config for the HAPRoxy is

pidfile /tmp/

mode tcp
balance roundrobin
option httpclose
option forwardfor

listen redis
server server5 maxconn 1 check
server server6 maxconn 1 check


For getting realtime statistics

the below config is used and the port can be used to get the statistics

listen stats :1936
mode http
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /