By enstulen
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?
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!
Hi,
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.