I started a couple servers on EC2 and they don't have swap.
Am I doing something wrong or is it that the machines just don't have any?
|
I started a couple servers on EC2 and they don't have swap. Am I doing something wrong or is it that the machines just don't have any? |
|||||||||
|
|
You are right, the Ubuntu EC2 EBS images don't come with swap space configured (for 11.04 at least). The "regular" instance-type images do have a swap partition, albeit only 896 MB on the one I tested. If some process blows up and you don't have swap space, your server could come to a crawling halt for a good while before the OOM killer kicks in, whereas with swap, it merely gets slow. For that reason, I always like to have swap space around, even with enough RAM. Here's your options:
|
|||||||||
|
|
The best location for swap IMHO is the instance-store. Why? AWS doesn't charge you for i/o on the instance-store. Besides, the instance-store is more performant than EBS in many cases. Just make sure you have a script that recreates the swap file in case you stop the instance. Reboots are fine. Why oh why it's not there by default? Let's locate the instance-store.
Hurray, 160.1GB for free! Put your swap in there and forget 100$ overages per server when your EBS-based swap gets swarmed by mistake. Unfortunate experience talking here. Apparently in some cases you don't see the instance-store.
|
||||
|
|
|
This is by design. Swap is turned off by default on EC2 EBS-backed instances, to avoid unpredictable costs. If you have a memory-hungry app that goes rogue (say, on a tiny or small instance), it can generate quite a large amount of I/O requests on your EBS volume. Amazon charges $0.10 per 1 million I/O requests (see http://aws.amazon.com/pricing/ebs/). Under normal conditions you shouldn't worry about it; usually the cost of I/O requests even on smaller instances a few dollars, if so. So if you know you have a properly sized instance and that swap will be used only infrequently, go ahead and enable it. But be careful with tiny instances. If you enable swap, you might want to keep an eye on Usage Reports. Optionally you can also set up a Billing Alert by going to CloudWatch Control Panel and creating a new Alarm for the total billed amount. This way you'll be notified right away is something weird is going on with your instances. |
|||
|
|
|
Check the However, I'm always paranoid about some process ballooning up in memory, so I think it would be prudent of you to simply set up a swap drive and recreate an image from the running ec2 instance. |
|||||
|