Just to start with, I have read the following threads and they do not help:
Optimising MySQL settings - mysqld running out of memory MySQL Server keep shutting down https://stackoverflow.com/questions/12114746/mysqld-service-stops-once-a-day-on-ec2-server MySQL keeps crashing in Ubuntu 12.04
I am running MySQL, Apache, Wordpress on Amazon EC2. I started with a t2.nano and migrated to a t2.medium as MySQL kept crashing.
As I learned from the above threads, this is about MySQL running out of RAM. A t2.medium has 4Gb of RAM.
No crashes since the upgrade, however, I set up a Perl script to run every 20 minutes, collect memory stats by running "free -m", and these are plotted below:
As you can see, over time, the amount of RAM being taken up is increasing, and we can all see where this is going to end - a crash.
So I ran:
ps -e -o pid,vsz,comm= | sort -n -k 2
And the bottom of the resulting table is:
25827 382080 apache2 25828 382080 apache2 25829 382080 apache2 25830 382080 apache2 25831 382080 apache2 25832 382080 apache2 25821 382564 apache2 25816 382580 apache2 25826 382580 apache2 25811 392876 apache2 23868 393828 apache2 23797 393832 apache2 23858 393840 apache2 23859 393852 apache2 25717 393932 apache2 25797 394080 apache2 23867 396320 apache2 23753 397012 apache2 1102 1745780 mysqld
So both apache2 and mysqld are taking up the vast majority of my memory, but why? There is no correlation with load on the server - my wordpress blog is getting < 1000 hits per day.
What is causing this? Any help greatly appreciated
Mick