Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Usually web projects start small, everything is on the one server. But if site becomes popular one server won't be enough.
So, since I don't have any experience in this, I'd like to get an idea of:
1. what kind of load means that I need to move my MySQL DB to a separate server and how to measure this load?
2. what kind of load means that I need to add another web server and how to measure it?
3. approximately, how many users can one server serve?

I'm talking about simple PHP app on a LAMP server like this:
* CPU: Athlon 3800+
* CPU Details: 2 x 2.0 GHz
* RAM: 1 GB RAM
* Hard Disks: 2 x 160 GB (RAID 1 Software)

share|improve this question
2  
@sneg - if your dataset fits in memory you can probably handle thousands of sql queries per second. depending on how many queries on average page display makes - you can calculate how many page displays you can handle. if you spit plenty of images and have tens of gigabytes of those - you'll probably be limited by i/o performance of disk subsystem. in raid1 on desktop-grade disks you'll be able to server probably 200-300 images/sec [ assuming probablility of selecting them is evenly distributed ]. and so on... really - without knowing what you server it's difficult to give some numbers. –  pQd Jun 17 '09 at 15:59
    
Thank you! Finally some numbers I can munch on. –  z-boss Jun 17 '09 at 17:57

5 Answers 5

up vote 3 down vote accepted

it all depends... on size of your dataset, usage pattern.

measure end-user experience. set acceptable page load time, test that every 5-10 minutes, plot charts. it all depends what your business can tolerate and when it becomes unacceptable.

enable slow_query in mysql, probably you do not want to have more then 5-10 queries per day that take more then 10 seconds. or maybe you have some nightly reporting and you can tolerate those?

probably you want to generate some statistics - for instance with munin with cpu usage, iostats, system load, network traffic, number of http processess, number of mysql threads, page generation time and see how that changes during the day / week. you can pinpoint peak time with that and can see how for instance adding more memory / tuning mysql changes your page load time.

in your case load average > 2 or 3 means system is overloaded [ but that's highly discussable ]

look here for some tips.

share|improve this answer
    
"load average > 2 or 3 means system is overloaded" 2 or 3 of what? I'm not an admin. –  z-boss Jun 17 '09 at 12:35
    
@sneg you can see load average after typing w or who in command line. –  pQd Jun 17 '09 at 12:47
1  
Good advice. Monitor, measure and record /everything/ from day 1. Only when you have a good quantity of data can you then predict how your trends and requirements are changing. –  Dan Carley Jun 17 '09 at 13:44

The time to start planning for more servers and a scalable architecture is when you sit down and draw up your specs (you want to have a code base with modular functionality, so it's easy to pull things apart, but at least having a "web front-end" and a "database back-end" is some level ov modularity).

Once you have that in place and you're running on one server (database and front-end), you can monitor how long different operations take and the load on the machine. Once load starts creeping up over "number of CPUs", you're definitely into "we should split this up"-land. If you have saved historical data, you can extrapolate how things will look in the future and decide on adding more capacity at a time, where the capacity will be in roughly as it's needed.

On a unix machine, the "load average" is (approximately) the average length of the run queue (that is, processes that are ready to run, but waiting for a time slot; usually NOT scaled by the number of CPUs physically in the box). If this is persistently higher than the number of CPUs you have, this is at least one indicator that the box is over-worked. It's not the only measure, but as a hard-and-fast guide, it's not too bad and teh system computes it for you.

share|improve this answer

Another thing to look at besides load, is your need for 100% uptime. If you need your site to remain up during server reboots, then you need some redundancy / clustering.

We have our webservers running as Virtual Machines, so we only use two (about 200 sites) for redundancy, and can increase the "server resources" if necessary to handle the load, without needing to introduce a third webserver (up to a point).

If you need to increase performance, the easiest thing is to separate out your MySQL on to a seperate box. However, that also means that your sites will be down twice as much (ie - they will be down when either server is rebooted/fails)

share|improve this answer

You upgrade when your capacity planning tells you that you've got about 3 times your lead time for a new server before your current infrastructure runs out.

share|improve this answer
    
Well, I don't have capacity planning and that's why I'm asking my question — to plan. –  z-boss Jun 17 '09 at 12:30
    
@sneg - fine.. but you do know what you expect? you do know what is ok for your customers and what not. if so - first measure what you have... then decide what is the bottleneck [ disk ios? lack of memory? cpu speed? bandwidth? ] and then upgrade part that slows you down. –  pQd Jun 17 '09 at 12:48
    
@pQd - you're giving me the right answer, but what I'm looking for is very approximate estimation based on your experience. I guess one server will be enough for 5 thousand users, but I'm not sure at all when it's not enough: 100,000? 1 million? 5 million users? Or should this be answered in connections per minute? –  z-boss Jun 17 '09 at 13:37
    
No one can possibly provide you that level of detail. It is very much dependent on the guts of your application and the expectations of your users. –  Dan Carley Jun 17 '09 at 13:41

You should also have a look into mod_proxy and mod_disk_cache to consider for your planning. Placed on a seperate partition with the application sending the correct headers (Cache-Control etc) this is a very good and easy way to improve your applications performance on apache because any cached (and cachable) page can be served as if it were static.

Do not try to use mod_mem_cache because it has worse performance for cache sharing reasons.

It has lowered the load by about 20-30% on a mass-vhosting system I am running. Just be careful with the mod_disk_cache parameters because they may dramatically increase your iostats if set wrong.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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