-5

Let's make this simple. I have a website hosted on a single dedicated server (LAMP). All static content are alraedy on an external CDN.

PHP pages aren't a problem because they take pretty low time to load (0.05).

What is a good strategy if i see my dedicated server can't handle more users and I need to expand it?

If i don't want to use a Cloud.. I can buy another dedicated server but at that point how can I split the traffic between my 2 dedicated server?

Which is a good strategy for this?

Note: yes i use a database of course (mysql) and no i don't store any session information

3 Answers 3

1

Do you have a database? What other services related to your application are running on the server?

As soon as you need to scale past one server, the first step would normally be to put the database on one server, and the application on another. Each are then managed/monitored separately.

If the database load gets high enough just setup a cluster (mysql?) or replica set (e.g. mongodb) so that they manage the load themselves.

For the frontend, as soon as one server isn't enough realistically you need at least 3. One to act as a load balancer, and 2+ application servers. Depending on where your servers are hosted they may provide a load balancing service.

Example showing number of servers

  1. Everything on the one server
  2. App server + database server
  3. Master db server, slave db server, application server
  4. skip
  5. database cluster, loadbalancer, app server 1, app server 2.

In short: The point in time when you need multiple app servers and any problems that brings is quite some time in the future based on the info you've provided.

6
  • So I will have a load balancer and 2 dedicated server that basically are identical? How do I keep em synched with each other?
    – dynamic
    Jan 29, 2012 at 22:39
  • keep what synced? The code? You would have the db on one server, and your app on another before having multiple app servers and the need for a load balancer.
    – AD7six
    Jan 29, 2012 at 22:46
  • The data, in this case the database data
    – dynamic
    Jan 29, 2012 at 22:49
  • You haven't read/understood my answer if you intend to have 2 identical servers.
    – AD7six
    Jan 29, 2012 at 22:51
  • Sorry but your 2+ application servers of course must be identical (same code + same database?)
    – dynamic
    Jan 29, 2012 at 22:54
1

This question is too vague to give a meaningful answer.

Any answer would have to depend on the specifics of your application. For instance, does it maintain server-side state about sessions? If so, how?

Your expectations for growth are important too. If you expect it to reach about 150% of a single server's capacity in 4 years time, I'd advise you to buy a bigger server in a few years; if it's expected to hit 10000% of a single server's capacity in 3 months time, you're going to need to do some more work.

1
0

First your PHP-code needs to be able to handle session information somehow.

This may be done you using cookies or session IDs coded in the response-URL.

After this the back-end (database) of your application must be able to handle simultaneous access to the same areas with locking or other means.

If you have that in place you are ready to go to increase the number of application servers (here: PHP) to 2+ - you just need some kind of load balancer in front of it.

If then your back-end becomes the bottleneck, you need other strategies there as well.

4
  • I don't need any session information
    – dynamic
    Jan 29, 2012 at 22:37
  • In that case - you should focus on the load-balancing problem. I recommend using LVS in your case.
    – Nils
    Jan 29, 2012 at 22:44
  • Am i wrong or even DNS can do that? they can throttle between a prefixed array of IPs
    – dynamic
    Jan 29, 2012 at 22:57
  • Yes - you can use DNS. But if you do so you must failover IPs to surviving nodes - else the client-requests will go to a dead machine.
    – Nils
    Jan 30, 2012 at 21:20

Not the answer you're looking for? Browse other questions tagged .