Best choice for 5k request spikes

August 7, 2015 636 views
Load Balancing Scaling Ubuntu

I am building a backend that is supposed to handle 5k request spikes. The application is a photo sharing app that uses SQL for database, php to handle requests and x-sendfile to send the images to user. What is the best setup server wise?
Now i have build a HAProxy load balancer to two apache servers who have a shared folder to access images and a database server. 4 servers in total. We may install memcached to save some processing. Will this hold? Is this a good setup? Do you have any suggestions on improvements or better solutions?

1 Answer


When you say 5k request spikes, what period of time is this in? Is that 5k simultaneous requests?

As all apps are very different and depend a lot on the particular code and database queries involved, there isn't a general answer. So, ultimately you'll probably need to load test to get an idea of where the bottlenecks are in your application. Once you've identified the bottlenecks, you can prioritize addressing them based on the complexity of the solutions and how much improvement you think you'll get.

In general, the best approach for massive scalability is to keep high-frequency requests away from PHP entirely. So, if you can find a way to have a web server serve static files to users without having to hit PHP at all (that is, not rely on PHP sending x-sendfile response headers), that's ideal. If every image request has to hit PHP, then the trick is just to keep the amount of processing and number of database queries to an absolute minimum. An extremely fast and lightweight PHP app can handle a huge amount of concurrent traffic with the right server config and server specs.

Have another answer? Share your knowledge.