0

The question I have is very basic, I understand what load balancing is and how it works, however I can't visualize it in practice.

Lets say I have an AMP application running on a server. One day traffic gets too great and I must start to balance the load and I add another server. I already have all of my data stored on the first one so what would I put on that server? I could copy the website's files but my database would still be on the first server and I would still have to connect to it from my new one, so that doesn't seem like a good solution? I could add a third server and make that a MySQL server and use that to store my data and have my Apache servers connect to that, but that doesn't seem like a good solution either because I would still have all requests getting data from a single place.

How is that done in reality?

1

the second option is generally used when using a load balancing device. That is, there are two application servers and the load balancing device distributes the incoming traffics among the two application servers based on different algorithms. For example, Round Robin, least requests first, etc.

The two application servers should be connected to a single data source. For this purpose, you can use a clustered database which works pretty well with MariaDB (free, open source and a MySQL folk).

Hope this answers your question.

| improve this answer | |
  • but isn't this going to create a bottleneck when all application servers are using the same data server? – php_nub_qq Jan 23 '17 at 9:44
  • This is why I suggest you to create a clustered database. You can have a number of devices sharing the same database. It has a lot of advantages like: No slave lag, No lost transactions, Both read and write scalability and among others Smaller client latencies. – NextGen Engineer Jan 23 '17 at 9:46
  • @php_nub_qq That of course depends on what is more expensive: Application logic or database access. You only have to scale as needed. – Daniel B Jan 23 '17 at 10:02
0

There may be number of solutions to your case.
First - yes, you copy your entire www directory to other server with installed apache and php exactly the same versions as on first node. If your application uses file storage then best is to to put it on share - NFS or sshfs for example (on separate server). If you would want to put this file storage on both app servers, then you need to synchronise them in real time (not a good solution). NFS created on SAN is in this case the best, because you have protection of SAN etc.
As to database - single database server, separate from application, hosted with reasonable RAM and disk space, can handle a lot of connections and a lot of queries. You would have to start worrying if queries per second would reach thousands. But if you'd reach that point, then solution is, already suggested, db cluster. To build a cluster, you need at least 3 database servers and a load balancer (proxy).
So, your set would consist of:

  1. load balancer for web servers
  2. at least 2 application/web servers
  3. database server
  4. file server (if required)

or, in case of db cluster:

  1. load balancer for database servers
  2. 3 database servers in a cluster
| improve this answer | |

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.