High Availability Cluster with Pound
It is very easy to scale web2py using a cluster:
- Install web2py on all the worker machines in your cluster (192.168.0.1:80, 192.168.0.2:80, etc. etc.). We recommend using this install procedure
- Setup one machine as a load balancer.
Here is how to setup and start the load balancer:
wget http://www.apsis.ch/pound/Pound-2.4.5.tgz tar zxvf Pound-2.4.5.tgz cd Pound-2.4.5 ./configure make sudo make install echo ' ListenHTTP Address 0.0.0.0 Port 80 End Session Type IP TTL 3600 End Service BackEnd Address 192.168.0.1 Port 80 End BackEnd Address 192.168.0.2 Port 80 End # etc etc End ' > pound.cfg /usr/local/sbin/pound -f pound.cfg
And that is all. You will be able to access the web2py cluster via port 80 of the load balancer.
Pound provides sticky sessions (the same client IP is mapped to the same worker node) so you do not have to worry about sessions.
You are running different web2py instances. Make sure they connect to the same database.
You may have to worry about uploaded files. So make sure you app stores them in the database and/or make your app uploads folder a shared folder. It is a good to idea to make it a backed-up NFS mounted folder.
Each instance will store error tickets locally. You can write cross mount the error folder, you can write your own script to consolidate error tickets on one machine or you can run this provided script to move error tickets into the database: