Solving Amazon EC2 Memory Issues
Often with the Amazon micro instances, and other instances with low memory allocations, your web server will ‘crash’, especially where MySQL’s involved. After a few page requests the MySQL engine can lock up because it doesn’t have enough memory.
Amazons micro instances don’t come with any swap memory by default so if you experience issues and don’t want the costs of bumping your server to the next instance size, adding some swap space can improve performance of the micro instances no end:
Once again, swap won’t default to on after a system reboot. To automatically enable swap after a reboot, you’ll need to update /etc/fstab, open the file with the following:
The file will open in an editor, paste the following line at the end of the file
Then type
Then hit enter. This says ‘write and quit’ which is essentially save and exit the editor.
After each reboot your server will now start Apache, MySQL and swap memory.
Depending on what you’re running you may still have memory issues but keep in mind that the Amazon micro instances only have just over half a gig of memory so it may be that your application is just too resource heavy to run on the free tier.
If you enjoyed this post, feel free to buy me a coffee. There's still an RSS feed, and you can follow me on Twitter and Instagram