Be wary of concluding you do not have enough memory , yes that is the error you see but that is also a symptom not the cause. Wait before paying for a bigger instance, the problem will only go away for some time until the memory fills up again.
Be wary of creating SWAP files, again you are only bandaging the symptoms.
Be wary too of changing config settings (and limiting the performance of your apache or mysql) which has been working just fine for some time but only now suddenly the server will not stay up for long at all.
Think how could that really be settings? if there was a badly optimised setting or a memory leak in PHP it would have failed consistently after the same sort of time period. So assuming you have not just recently installed new modules and have had had a pretty static environment for some time it is unlikely to be a memory leak or settings. Obviously if you have just been installing new modules disabling them should always be a first step
Be wary of splitting the database to another server, this will not solve the problem in the same way as buying a bigger server doesnt solve the problem. Yes each function will get more memory initially but then.....
Be wary of migrating from apache to another http server such as NginX, a drastic step, which may solve the problem..... but for the wrong reasons
I was guilty of most of these and raised many a false hope, until I looked at the apache /var/log/httpd/ACCESS_LOG file and saw that my site was being hit several times a second from the same IP looking for a file called XMLRPC.PHP, some kind of DDOS attack well known in Wordpress circles.
example access_log entry ....
191.96.249.80 - - [21/Nov/2016:20:27:53 +0000] "POST /xmlrpc.php HTTP/1.0" 200 370
each time it is received apache tries to instantiate a child process to service that request. Before long you run out of memory and apache starts failing to fork a new process and mysql gives up trying to allocate memory space to the buffer pool. You basically run out of memory and all these requests grind your server to a halt.
to solve ths I changed the .htaccess file to deny access to the file from that IP, and my server returned to normal operation immediatly.
example .htaccess
<Files xmlrpc.php>
order allow,deny
deny from 191.96.249.80
allow from all
</Files>"
Hope my hard won findings help someone else!
Obviously if your access log is not showing a DDOS effect, it might be something else, try all the above! ;-) but I have now seen several a wordpress/apache site affliicted with this attack. ... same IP too! Its a pity Amazon AWS does not allow blacklists in its security groups. [sigh]