Rails load balancing with Apache and Trinidad 1

Posted by david

I just released a new version of Trinidad with two major features. The first one is that it supports ssl connections adding a simple starting option:


  $ trinidad --ssl

The second one is also related with connections, but this one is about AJP, a protocol designed to increase tomcat's performance, if you already have worked with tomcat or jboss I'm sure you already know it.

But what I'd like to show you is one of its main adventages, how to create a really stable load balancer with Apache httpd and Trinidad thanks to ajp.

First we have to ensure all the apache modules that we need are loaded:


  $ sudo a2enmod proxy_ajp proxy_balancer

After that, we have to configure our virtual host to proxy the connections through ajp, this is an actually basic configuration, there are a lot of resources about mod_proxy_balancer on internet:


<Proxy balancer://trini>
  BalancerMember ajp://127.0.0.1:8009
  BalancerMember ajp://127.0.0.1:8099
</Proxy>

ProxyPass / balancer://trini/

Notice that I'm using my development machine and that's why the two balancer members have the same ip but different port.

Finally, we have to run two different instances of Trinidad with the ajp option enabled, with the ports we specified in the balancer configuration (8009 is the default one), and different http ports due to I'm running it in my machine:



$ trinidad --port 3001 --ajp
$ trinidad --port 3002 --ajp 8099

That's it, quite straightforward.

By the way, I've also set up a google group where you can ask doubts or discuss about the development itself, and, as always, if you find a bug or have a new cool functionality you can add it to the issue tracker.

Comments

Leave a response

  1. JohnAugust 20, 2009 @ 09:27 AM
    Nice work, love your site!
Comment