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).
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).
Three recommendations.
1.) Consider using HA Proxy over nginx for your load balancing.
[EDIT]
Things to consider when considering HA Proxy over HttpUpstream:
HttpUpstream:
HA Proxy:
HA Proxy is really the go-to free load balancer IMO.
[EDIT/]
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.