Configuring haproxy LoadBalancer for SSL and multiple sites – Part 1

When I started working upon haproxy I found that examples on Internet and official documentation were rather limiting as compared to practical real-life deployments for eg. configuring SSL, multiple sites handling etc. Hence, I decided to write a kind of guideline myself based upon how it can be used to leverage its capabilities.

Requirements :
If you are going to need SSL to work in your load-balance environment and have multiple sites or domains to configure.
1. Installation : In case you are not aware haproxy latest version is now 1.5 (with built-in SSL support) and I’ll be focusing on version 1.5 only.
Get the latest copy from or use :
tar -xvf haproxy-1.5.0.tar.gz
cd haproxy-1.5.0
Here comes a little tricky part as you need to define options to configure it. Remember SSL is not enabled by default so you have to run this command as the bare minimum:

make instal
To run haproxy in daemon mode :
/usr/local/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg
To confirm if its running :
ps aux | grep haproxy
Configuration for Single Site on Port 80
edit /etc/haproxy/haproxy.cfg
keep the global options as it is and add the following lines (replace x.x.x.x with your IP) :
listen stats <your IP>:1980
log       local1
mode http
stats enable
option      httplog
stats hide-version
stats realm Haproxy\ Stats
stats uri /
stats auth stat:<password>

frontend http-in
     bind *:80
     options httpchk
     acl host_site1 host(hdr) -i <url of your site>
     use_backend site1_cluster if host_site1

backend site1_cluster
   mode http
option httpchk
option redispatch
retries 5
timeout connect 15s
server hostname1 x.x.x.x check inter 10s fall 3 rise 1 maxconn 1200
server hostname2 y.y.y.y check inter 10s fall 3 rise 1 maxconn 1200
The above configuration will loadbalance your site with hostname1 & hostname2, the default loadbalancing algorithm is roundrobin i.e one request will go to hostname1 and next will go to hostname2 (one by one)
To check go to <your IP>:1980 and put in the auth credentials and voila….you have a bare minimum load balanced environment.
In next part I will write about serving multiple sites from haproxy.

Cassandra Multi Node Cluster Setup

Cassandra Multi Node Cluster Setup

In this article we will talk about cassandra multi node cluster setup in brief and very straightforward manner.

If you are new to Cassandra then you can follow this post to learn how to create a single Cassandra node. If you know how to setup single node than you can start from here. For a multi node cluster I will be using three virtual machines hosted on Xen Server. Setup all the three nodes as described here. Verify that all the three Cassandra nodes are up and running.

To configure multi node setup do the following :

Step 1. Locate Cassandra.yaml and search for ‘seed’. Change the IP address to the IP Address of any one node whom you want to designate as ‘seed’ (more on seed later).

Step 2. Change listen_address to local IP (should not be

Step 3. Change rpc_address to local IP (should not be Repeat the configuration changes for all the nodes and run this command to verify :

./nodetool status
Datacenter: datacenter1
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Owns (effective) Host ID Token Rack
UN 42.78 KB 25.4% 6fb0a0cb-b804-4f57-8178-d2c9f36bfac4 -5882736283116946676 rack1
DN 60.04 KB 31.8% 9e675cf5-f428-4770-8e73-38dc4338bf80 7869867229365366303 rack1
UN 62.13 KB 42.8% 8e87c60c-ef07-4ed6-83d0-0dc79f5094e4 2008276574632865675 rack1

(note : x’s are just used to hide real IP-Addresses),

If you can see something similar then you have successfully setup the cassandra multi node environment. In case you are having issues just comment and together we will try to resolve them.

Measuring bandwidth in linux

Measuring bandwidth in linux

Wondering how to measure bandwidth usage on linux, its not that complex just install vnstat. On most linux systems it shows ‘fail to start’ due to unavailability of database. You need to create one, again even this is very simple.You will see this error on Ubuntu :No database found, nothing to do. Use –help for help.A new database can be created with the following command:
vnstat -u -i eth0Replace ‘eth0′ with the interface that should be monitored.The following interfaces are currently available:
lo eth0 wlan0

Simple isnt’t you know what to do, just use vnstat -u -i I used wlan0 to monitor bandwidth usage for wi-fi. As soon as vnstat starts to gather data, it will start showing up. Voilaaa…..Enjoy and measure bandwidth in linux.

Installing Cassandra on Ubuntu 12.04

Installing Cassandra on Ubuntu :

This is an introductory article for installing cassandra on Ubuntu and basic usage. This will take you from installation and basic troubleshooting to inserting and fetching data. I assume that you already know what Cassandra actually is, if not you can read about Cassandra here:

Continue reading