Best choice for 5k request spikes

Hi! 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?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


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.