6

As we did this in the past, i'd like to gather useful information for everyone moving to loadbalancing, as there are issues which your code must be aware of.

We moved from one apache server to squid as reverse proxy/loadbalancer with three apache servers behind.

We are using PHP/MySQL, so issues may differ.

Things we had to solve:

Sessions

We moved from "default" php sessions (files) to distributed memcached-sessions. Simple solution, has to be done. This way, you also don't need "sticky sessions" on your loadbalancer.

Caching

To our non-distributed apc-cache per webserver, we added anoter memcached-layer for distributed object caching, and replaced all old/outdated filecaching systems with it.

Uploads

Uploads go to a shared (nfs) folder.

Things we optimized for speed:

Static Files

Our main NFS runs a lighttpd, serving (also user-uploaded) images. Squid is aware of that and never queries our apache-nodes for images, which gave a nice performance boost. Squid is also configured to cache those files in ram.

What did you do to get your code/project ready for loadbalancing, any other concerns for people thinking about this move, and which platform/language are you using?

2
  • Is NFS robust enough for this?
    – vartec
    Mar 3, 2009 at 9:21
  • yes. nfs is mostly only used for writes or file_exists checks, reads (see our lighttpd solution) don't use nfs that often.
    – Karsten
    Mar 4, 2009 at 9:13

1 Answer 1

1

When doing this:

For http nodes, I push hard for a single system image (ocfs2 is good for this) and use either pound or crossroads as a load balancer, depending on the scenario. Nodes should have a small local disk for swap and to avoid most (but not all) headaches of CDSLs.

Then I bring Xen into the mix. If you place a small, temporal amount of information on Xenbus (i.e. how much virtual memory Linux has actually promised to processes per VM aka Committed_AS) you can quickly detect a brain dead load balancer and adjust it. Oracle caught on to this too .. and is now working to improve the balloon driver in Linux.

After that I look at the cost of splitting the database usage for any given app across sqlite3 and whatever db the app wants natively, while realizing that I need to split the db so posix_fadvise() can do its job and not pollute kernel buffers needlessly. Since most DBMS services want to do their own buffering, you must also let them do their own clustering. This really dictates the type of DB cluster that I use and what I do to the balloon driver.

Memcache servers then boot from a skinny initrd, again while the privileged domain watches their memory and CPU use so it knows when to boot more.

The choice of heartbeat / takeover really depends on the given network and the expected usage of the cluster. Its hard to generalize that one.

The end result is typically 5 or 6 physical nodes with quite a bit of memory booting a virtual machine monitor + guests while attached to mirrored storage.

Storage is also hard to describe in general terms.. sometimes I use cluster LVM, sometimes not. The not will change when LVM2 finally moves away from its current string based API.

Finally, all of this coordination results in something like Augeas updating configurations on the fly, based on events communicated via Xenbus. That includes ocfs2 itself, or any other service where configurations just can't reside on a single system image.

This is really an application specific question .. can you give an example? I love memcache, but not everyone can benefit from using it, for instance. Are we reviewing your configuration or talking about best practices in general?

Edit:

Sorry for being so Linux centric ... its typically what I use when designing a cluster.

4
  • +1 Thank you for your very technical answer, the actual question is at the end of my post ;) "What did you do to get your code/project ready for loadbalancing, any other concerns for people thinking about this move?" = more code-specific things
    – Karsten
    Mar 3, 2009 at 9:51
  • 'it should not matter' is not a good answer, I need to know how you are using memory.
    – user50049
    Mar 3, 2009 at 14:19
  • Also, what platform? This question is VERY good, but also very generic.. its like "what is the best strategy for endurance running?" .. I would then answer "run only when chased."
    – user50049
    Mar 3, 2009 at 14:20
  • Ok, i'll add more specifics to our setup, but i wanted to gather info/reports for every other web-language out there ;)
    – Karsten
    Mar 4, 2009 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.