Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do multiple servers work in sync for web application?

  1. My first question is, I often read about people using multiple dedicated servers to run their websites, and process queries from users. But how do they exactly do this? I mean, when I enter a domain name, a DNS resolves maps that to an IP address, but I am lost after that.. is there some kind of master/slave architecture there to load balance incoming requests amongst the (potentially) hundreds of servers?

  2. If that's the case, how do the various servers, share data (database for e.g.)? Will they be connected to the same hard disk?

like image 705
philly77 Avatar asked May 25 '09 12:05

philly77


1 Answers

ultramonkey will give you a good description of how to load-balance across many servers, so you see 1 IP address but the connection gets routed to one of many servers (with fault tolerance included).

If you don't have your web servers using the same storage (common storage can be tricky, you have to use a SAN with a 'shared' filesystem like GFS, or a database) then you should enable sticky sessions which tell the router that each client will choose a server to communicate with the first time, and keep with that server. This is less fault-tolerant (but in the web you'll just have to refresh a broken connection to start over) but much easier to architect (and faster as each web server can remain independent)

The other issue you'd need in a truly fault-tolerant situation is to locate the physical servers far away from each other, which raises performance issues for most sharing designs (ie you cannot put all your servers on a SAN if they're in different countries), is to use the multiple servers approach, using a single DNS name and replicate data between them regularly. DNS load balancing is possibly the easiest way of using multiple web servers as a single website.

In these cases, the DB can often be a single database that all servers communicate with, or can be shared themselves, using clustering or more often log-shipping to ensure you have a backup ready to come online should the primary fail. Log-shipping is more common for backup servers than are located far away.

like image 192
gbjbaanb Avatar answered Sep 19 '22 13:09

gbjbaanb