Monday, October 25, 2010

Nitrogen Rocks!!!!

Hey guys, have you checked out the 'nprocreg' process registry in nitrogen? This application now allows nitrogen clusters to distribute events amongst them selves especially when run behind a load balancer or if run on top of more than one web servers which map onto the same name.

To check this out, create a LAN of 5 computers. On one of them, install Solaris/ Suse / Debian and create a name server (DNS). Point the other computers'settings for name server to the IP address of this one.

Now, Get two computers and run nitrogen on both. Make sure that you r running the same version of erlang on both computers. Ping the two nodes running nitrogen so that they connect to each other. Create a nitrogen page on both nodes and make sure that the page will display which node its coming from. Make sure that the name server has the same name mapping onto the two nitrogen node IP addresses. (i.e. nitrogen@192.168.0.2 and nitrogen@192.168.0.4 , so the name servers would have say: www.mysite.com mapping to 192.168.0.2 and also mapping to 192.168.0.4), make sure the web server on each of those nodes is actually listening for connections from its IP address.Create a button on the page which will generate an event. say:-
wf:flash(wf:f("Some statement",[])).

Now, request the page in the browser using the name configured in the DNS, from any one of the computers.
Note where each computer is picking the request. Now go kill one of the nitrogen nodes.
When you click on the pages that came from the nitrogen node which has just been killed, you'll see that it still works.

Its because the browser sent the event to the second nitrogen node in the cluster.

Cluster???

Yes, when you pinged on nitrogen node from the other, the tow formed a cluster.
Thanks to Rusty and the friends, we can now distribute our events across multiple nitrogen servers.