We have 5 physical servers. All are identical. 16 gb ram, 4x146 10k sas in raid 10.

So, we need high availability. Current plan is following:

2 boxes with Heartbeat for load balancing. At this moment nginx is configured as balancer.

then problem is web & mysql. I plan to set up 2 boxes running mysql and nginx. Between theses boxes set up mysql replication in master <-> master. Then add latest box which has replicated mysql. For this model each webserver connects to its local mysql server. (to minimize network latency).

Schema for my model

Other model is to put two boxes (nginx) in HA and another two boxes in mysql master/slave. but in this model load balancer is alone ....

Or i need another setup. Basically i don't need how to do it, but which model to choose. We need to handle lot of traffic (about 20k req/s).

  • 1
    If you planing connecting to local mysql then your model is wrong because you cant do inserts or updates on slave unless the system is doing selects only – B14D3 May 11 '12 at 10:28
  • MySQL can be a slave to only one master. Am I missing something? – John Gardeniers May 11 '12 at 10:30

Three recommendations.

1.) Consider using HA Proxy over nginx for your load balancing.

Things to consider when considering HA Proxy over HttpUpstream:


  • "This module provides simple load-balancing (round-robin and client IP) across backend servers. "

HA Proxy:

  • TCP Load balancing
  • Hot reload
  • Connection Queuing
  • Comprehensive stats page
  • Socket communication including ability to mark servers as down
  • ACL's
  • 'Sticky' Load balancing
  • etc
  • etc
  • etc

HA Proxy is really the go-to free load balancer IMO.

2.) Look into caching. Profile production queries against a sample of production( or the like) data. Hitting the database 20k times a second could destroy your database servers. That's 1.7 BILLION transactions per day assuming each request incurs only ONE transaction. That's a LOT. Squid, memcached, redis, etc can save your bacon here if caching is possible.

3.) Did I mention profiling?

It's hard to suggest a course of action without knowing your applications resource usage patterns. For instance, you may find you'll have to put MySQL on two dedicated boxes to keep up with query demand. On the other hand, HA proxy is extremely memory and cpu efficient. You could probably get away with having your HA Proxy setup share resources on two of your web heads.

  • Please justify your first point. It's entirely possible that it's valid but you've got to explain why. – Martin Fjordvald May 11 '12 at 17:50
  • I think that caching is possible. One problem is that i am only sys admin. so, i don't know what is going on application level. And i do not know if database indexes are set properly.. – Guntis May 11 '12 at 20:40
  • Please see my edit in reference to HA Proxy. It's what we deploy for customers where I work. Also, you're really going to want to work with the devs to do testing/benchmarking so you can choose and verify the best course of action. If that's not possible, as a sysadmin, you can use something like mysql proxy to get a view into what queries are being run and use those to profile your database setup. – Rapzid May 12 '12 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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