0

When I bring up an EC2 instance, I noticed that virtual memory is not enabled.

$ free
             total       used       free     shared    buffers     cached
Mem:       1017260     344956     672304         60     141252     136976
-/+ buffers/cache:      66728     950532
Swap:            0          0          0

Where as in a typical Linux installation, it would create swap partition by default. Is there any reason that virtual memory is not enabled on EC2 by default? Or is the memory my EC2 getting already part-physical / part-swap?

1 Answer 1

1

I don't think you should enable virtual memory unless you need it. For most instances, your EBS disk is across a network and relatively slow, so if you swap a lot it will slow your server. If you have an instance disk, an SSD inside the machine, it'll be pretty fast.

However, if you need more memory and it's not actively swapping a bit of virtual memory can help you run more software on a smaller VM. I run a t2.nano with 512MB RAM and 512MB swap, and it works fine. With that I can run Nginx, PHP 5.6, MySQL, and a few utilities with no issues.

I have a tutorial on how I added swap space to my instance here.

Here's my servers memory setup

[ec2-user@aws ~]$ free
             total       used       free     shared    buffers     cached
Mem:        500984     458016      42968     118864      13164     171068
-/+ buffers/cache:     273784     227200
Swap:       524284     141252     383032

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .