By greatsami
Hi,
I careated LEMP 512MB droplet with ubuntu 17.04 and php 7.1. and i uploaded my laravel project on it. i see high memory usage between 85% and 95%, after that I upgraded the droplet to 1GB.
after that i make swap to enable me to install Redis.
Now i face 2 problems: First one is memory is still high. there are 2 attached images appear this issue with top process in memory.
Second problem mysql is disconnect usually and can’t restart mysql, i reboot the droplet to re work. this problem related with cannot connect to mysql (DB_SOCKET=/var/run/mysqld/mysqld.sock). how i can solve those?
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!
Examine dmesg and log files for signs of mysql crashing. Very likely it’s killed for out of memory errors.
Post memory profile like the output of free(1).
Ensure you have swap enabled.
In my experience at least 2Gb RAM is required for running PHP-FPM in production along with mysql/redis.
If the php process is taking up way too much RAM, it’s possible that your code has a memory leak of some sorts. I would suggest using https://github.com/barryvdh/laravel-debugbar to profile your application’s memory usage and see what’s taking up so much RAM.
As another option you could run mysql on a second droplet and enable local networking for both of them. That way when your php application hogs too much memory the OOM killer will only murder your webserver workers and not your mysql database. (You’ll have to connect to your database via tcp instead of unix sockets though).
As a plus you can also increase the size of each droplet as each sides needs grow, rather than hoping they don’t step on each others’ toes, there’s also less risk of mysql losing data when it’s randomly killed.
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.