I have a music website built with Laravel 5.0 and one option is letting users to create LRC files and save LRC text for other users. Now with 8,000+ LRC, I get 50 to 130 Users online at the same time. Some requests are made once the page loads via ajax. Since I started to get like 20,000 - 27,000 pageviews per day, Some requests are lost in the queue process and a Maximum execution time of 30 seconds exceeded exception is raised in all kind of pages and requests.
My Old VPS on DigitalOcean : 4GB RAM, 2vCPUs. I started to get the error myself 2 times a day (20,000 pageviews), then 10 times or more (27,000 pageviews). The CPU activity was at 80-90% average respectively, and Memory load was not high. So I scaled the VPS to 8GB RAM, 4vCPUs. After that the server response time was like 6 times slower and CPU load was like 60% (22,000 pageviews). I contacted DigitalOcean which suggest me to create a new VPS and use proxy Server to forward requests to old VPS to the new One, which I did to new VPS. And the new VPS is blazing fast again.
My New VPS on DO : 16GB RAM, 6vCPUs. CPU load is 20% (22,000 pageviews/day). But I still get the error like once a day. And from the error report, there is like 300-500 per day. So I decided to fine tune the Apache MPM Prefork module in /etc/apache2/mods-enabled/mpm_prefork.conf :
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 300 #(From 150 to 300)
ServerLimit 300 #(new line added)
MaxConnectionsPerChild 0
</IfModule>
On the new VPS 16GB, the average of request take 24.9MB, to I put MaxRequestWorkers to 300.
I really don't understand why it is still happening, and now I'm sure my server does have enough RAM and CPU to handle everything. But maybe old config was for small capacity and now I should change them, but I don't know what to touch. Maybe MySQL ram should increase etc.
Apache 2.4, PHP 5.6, MySQL 5.5.9, PMP Prefork module, Laravel 5.0
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2wuqOim
via IFTTT
Aucun commentaire:
Enregistrer un commentaire