Some of you have probably experienced that an Amazon Web Services EC2 micro instance might be too small with it’s 613MB of memory. If you deploy medium or large footprint application on it (well, even WordPress + MySQL could be stretch), both the instance and your systems might start to crash.
Tip #1: Use a 32-bit image
Using a 64-bit OS sets you at a disadvantage since everything 64-bit actually uses more memory. A memory reference in a 64-bit OS is twice the size of a 32-bit OS, so for micro-instances, be sure to go 32-bit.
A lot of people want to use 64-bit to have an upgrade path. But frankly; both the EC2 small and EC2 medium has under 4GB memory, so stay 32-bit if you are planning to use a micro-instance. The 32-bit alternative gives you a decent upgrade-path, and if your systems grow larger than medium size, a reinstall is probably required anyway.
Tip 2: Add virtual memory
The EC2 micro has, as mentioned above, just a puny 613MB memory allocation, and there is no virtual memory allocated by default. This is however easy to fix.
First, create a EBS-volume with for example 1 GB (if you want to add 1 GB virtual memory).
After the EBS-volume is creates, attach it to the EC 2 micro instance (remember which device it is attached to (for example
Logged into your micro-instance, attach the new drive by doing (assuming the volume was mounted as
/dev/sdf and you run Ubuntu 12.04 or later):
mkswap -f /dev/xvdf swapon /dev/xvdf
The virtual memory should now be attached. You may verify it by issuing the command:
Attach the swap-area permanently so it survives reboots.
/etc/fstab file and add the line:
/dev/xvdf swap swap defaults 0 0