Amit Sharma
Amit Sharma

Reputation: 6174

Scaling a PHP website

Is there a standard solution to scale up a website which runs on PHP + Apache web server ? As in I get a traffic of about 100,000 requests/day as of now. 6 months down the line I expect it to grow to 200,000 requests/day. The first cut solution which comes to my mind is deploying more Apache web servers with mod_php, but something seems so wrong about it.

Any ideas ?

Upvotes: 2

Views: 1129

Answers (4)

Ryan Guest
Ryan Guest

Reputation: 6470

if you like it then you should have put a cache on it

Upvotes: 0

Dan D.
Dan D.

Reputation: 1127

Try these two options first before adding new servers. They may allow you to stick with one server, but your results may vary.

For speeding the site up when you are hit with many concurrent users, look into installing the APC PECL extension (http://us2.php.net/manual/en/book.apc.php). APC will allow you to cache the compiled version of your scripts, saving the step of the PHP interpreter running each time a script is executed.

Also, if you are experiencing heavy load on the database server, look into installing memcached and caching database results for a certain time period, if possible (http://us2.php.net/manual/en/book.memcache.php).

Finally, if you do decide to get a separate server, look into possibly getting a dedicated SQL box. This, of course, assumes that your application is a database heavy application, as web apps are these days. Segregating SQL into a separate box allows it to take advantage of all of the resources on that box, with more cache and processing power. It could be the way to go.

Upvotes: 4

Alexander Sagen
Alexander Sagen

Reputation: 4038

20.000 requests / day is only one every fifth second, sounds like one box should be able to deal with that just fine? If not I'd first have a look at bottlenecks in your code. Redundant database calls? Double-looping database calls rather than simple joins? Are you caching anything?

How to scale after this is totally dependent on your application, how/where do you keep session state and so forth, general advice has limited applicability.

Upvotes: 1

oezi
oezi

Reputation: 51797

i don't have any experience with scaling realy large websites, but i don't think you'll need so scale to different servers in this case. i have a browsergame with 40.000-60.000 requests per day, some cronjobs doing a lot of stuff every 5 minutes and a teamspeak-server on a small server (40 $ / month) and havn't got any performance problems till now.

Upvotes: 3

Related Questions