0

I was lucky enough that my website went viral, and the server of course wasn't ready for it.

Unfortunately my setup is quite bad, a single server with Apache, PHP (Laravel), Mongodb and redis.

The backend (laravel) mostly serve a REST API. I currently have 1000+ concurrent users trying to use the website, and everything loads really slowly. MongoDB seems to be working fine, since I can access it through terminal and queries are resolved immediately. What worries me is the Apache/PHP FPM configuration.

My server: 8 core, 16GB RAM

I tried to play with PHP FPM configurations but didn't improve by much. For now I have it on static with 300 max_children.

On Apache I'm using MPM event with this config:

<IfModule mpm_event_module>
ServerLimit 40
    StartServers             2
    MinSpareThreads      50
    MaxSpareThreads      100
    ThreadLimit          64
    ThreadsPerChild      50
    MaxRequestWorkers     1000
    MaxConnectionsPerChild   0
</IfModule>

Using top I have this, which seems fine to me: enter image description here

Anyone can point me in the right direction?

  • Do you use OPcache for PHP? You can also consider migrating to nginx or OpenLiteSpeed. Opinion based, but still they usually scale much better for high load. – NStorm Sep 16 '21 at 16:22
  • I don't use OPCache, would it beneficial even if PHP just serves an API? I have mongo as DB and a redis caching layer. As for nginx and OPS, I was looking for a short term solution rather than migrate everything. But thanks for the suggestion – Gregory Wullimann Sep 16 '21 at 17:07
  • Laravel is pretty advanced framework and OPCache can really improve it's execution times. Your CPU usage are pretty close to 100% and most of it are used by apache processes, but still there are a lot of php-fpm workers there. It's pretty easy to install & configure it so I guess it's worth to try. I don't see any i/o wait so the bottleneck should be in the CPU processing. – NStorm Sep 17 '21 at 05:55
  • Will try it then! Just to test out, I tried to upgrade the server at 32 core and 192GB of ram, just to be sure. By changing a bit the configuration i reached 1500 concurrent users and then the website started to slow down, with just 30GB used out of 192GB, weird – Gregory Wullimann Sep 17 '21 at 06:17
  • To be honest, I don't have any experience with newer Apache MPM workers, like event one. So won't be guessing here. But with older versions & other works it was always slow for any significant load for me. I've always picked nginx if I'd expect any significant loads. After I've tried OLS, I usually try to stick with it. It has it's own issue, but performance wise it's really a great software. And I like it can parse apache style .htaccess rewrite rules (only for mod_rewrite unfortunately, but it's usually enough). – NStorm Sep 17 '21 at 06:56

0 Answers0