Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

Varnish has recently been applauded, and works immense in-terms of D/DOS protection, socket tuning, load-balancing, and most importantly caching.

Currently in this article i am setting up Varnish as cache/loadblancing which will forward clean request to webserver.

Varnish -> Web Server
2x 2x

There are not many files that needs to be changed to run varnish by default varnish setup gives quite intresting config which has ability to handle request and cache.

vi /etc/sysconfig/varnish

# Maximum number of open files

# Locked shared memory
# Default log size is 82MB + header

# Maximum size of corefile

# Reload VCL set 1 to reload,without restart.

# Main configuration file.

# Default address and port to bind

# Telnet admin interface listen address and port

# Shared secret file for admin interface

# The minimum number of worker threads to start

# The Maximum number of worker threads to start

# Idle timeout for worker threads

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

# Cache file location if using file cache

# Cache size: in bytes, optionally using k / M / G / T suffix,
# or in percentage of available disk space using the % suffix.

# Backend storage specification
# malloc runs from RAM, file from file

# Default TTL used when the backend does not specify one

vi /etc/varnish/default.vcl

# Define the list of web servers
# Port 80 Backend Servers
backend web1 { .host = “”; .probe = { .url = “/server_status.php”; .interval = 5s; .timeout = 1s; .window = 5;.threshold = 3; }}
backend web2 { .host = “”; .probe = { .url = “/server_status.php”; .interval = 5s; .timeout = 1s; .window = 5;.threshold = 3; }}

# Define the director that determines how to distribute incoming requests.
director web_director round-robin {
{ .backend = web1; }
{ .backend = web2; }

# Respond to incoming requests
sub vcl_recv {
# Set the director to cycle between web servers.
set req.backend = web_director;

if (req.url ~ “^/server_status.php$”) {
return (pass);

# Pipe these paths directly to Apache for streaming.
if (req.url ~ “^/backup”) {
return (pipe);

# Always cache the following file types for all users.
if (req.url ~ “(?i).(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)(?[a-z0-9]+)?$”) {
unset req.http.Cookie;

sub vcl_hash {

# Code determining what to do when serving items from the Apache servers.
sub vcl_fetch {
# Don’t allow static files to set cookies.
if (req.url ~ “(?i).(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)(?[a-z0-9]+)?$”) {
# beresp == Back-end response from the web server.
unset beresp.http.set-cookie;

# Allow items to be stale if needed.
set beresp.grace = 6h;

# In the event of an error, show friendlier messages.
sub vcl_error {
# Redirect to some other URL in the case of a homepage failure.
if (req.url ~ “^/?$”) {
set obj.status = 302;
set obj.http.Location = “”;