Last week I was playing with my EC2 micro instance. I installed Apache, MySQL and WordPress. I configured everything according to great tutorial published on AWS. Everything was great, working fine. But then I encountered an issue, my blog was failing more than couple of times a day.
Problem:
On digging I found out that the MySQL daemon was failing due to insufficient memory.
Details:
EC2 micro instance provides you with 1 vCPU and 1 GB of memory. Clearly this is not ideal for big application. But I am just creating a person blog site with only I am being the user :), so this should be sufficient.
Problem lies with default setup of Linux, Apache and MySQL. Apache and MySQL tries to hog resources and with default Linux setup there is no swap memory allocated.
Solution:
After doing few hours of googling I arrived at following solutions (which worked for me)
1. Allocate swap
- Run dd if=/dev/zero of=/swapfile bs=1M count=1024
- Run mkswap /swapfile
- Run swapon /swapfile
- Add this line /swapfile swap swap defaults 0 0 to /etc/fstab
innodb_buffer_pool_size=64M