Recently, we had to setup Varnish load balancer for a website having 1 Million visitors per day. Provisioning load balancer based on this scale is a challenging task. We need to do several benchmarking tests in order to reach our optimum solution.
Let us see how we did the load balancer setup for supporting 1 Million visitors.
1 Front-end Proxy server configured with Nginx + Varnish 3.0
Specification: 30 GB RAM, 16 CPU Core, 50 GB SSD
Amazon EC2: c4.4xlarge
Backend server 01 Webserver (Windows)
Backend server 02 Webserver (Windows)
Specification: 122 GB RAM, 16 CPU Core, 200 GB SSD
Amazon EC2: r4.4xlarge
Amazon RDS with Multi-AZ Deployments
In this architecture, the primary proxy server is configured with Nginx + Varnish 3.0. For DNS management, Amazon Route 53 is used. The domain must point to the primary proxy server.
In Varnish configuration, backend servers are specified and the load balancer is configured in round-robin using varnish director. So the request will serve as round-robin manner, The CPU usage is balanced.
All the static contents are cached on the varnish server and Grace Mode is enabled for 6 hours which reduce the CPU overhead.
We have two backend servers to serve website contents. The database server is set up on Amazon RDS with Multi-AZ replication. The Multi-AZ setup acts as failover – new DB instance will immediately act as the primary, if the primary RDS instance fails or crash.
Varnish Load Balancer Configuration
This is a sample configuration with a varnish load balancer. Here two backends are configured. If your backend server’s resource capacity is low, you can add more backends like web1, web2, web3, web4 etc.
Configuration File : /etc/varnish/live.vcl
Get the code from https://raw.githubusercontent.com/xieles/varnish/master/live.vcl
For backups, AWS snapshots and RDS DB snapshots are enabled with the retention of one hour.
Several benchmarking tests were done using Apache JMeter and finally concluded that the above architecture was able to handle up to 1 million requests. The response is 10 times faster when compared to normal web servers because all the static contents are cached using varnish and remaining contents like cart and signup forms will be served from the backend server.
Xieles Support can help you with speeding up of your website. Get a quote from us if you need any assistance.