Tag Info

Hot answers tagged

46

There are lots of ways you can figure out how much swap use in a machine. Common suggestions use formulas based on RAM such as 2 x RAM, 1.5 x RAM, 1 x RAM, .75 x RAM, and .5 x RAM. Many times the formulas are varied depending on the amount of RAM (so a box with 1GB of RAM might use 2 x RAM swap (2GB), while a box with 16GB of ram might use .5 x RAM swap ...


41

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 ...


35

I'd recommend allowing the normal Linux memory control swap in the things that are actually used, as they are used. The only thing I can think off is to turn swap off, then on again swapoff -a swapon -a That assumes you have enough spare physical memory to contain everything in swap...


20

Are you hitting swap? Generally, the better solution is to avoid that entirely, or at least make it so that things which are swapped out are genuinely not in active use, so that the speed doesn't matter. Put your money into more RAM. This is particularly true because while high-end SSD drives may improve performance, cheap ones are very troublesome in this ...


17

Not more than a gig or two -- you want a little bit of swap available, just in case and because it helps things work a bit better, but if you ever get to the point where you're heavily swapping, the machine is going to be useless -- and in a real catastrophic situation, you're actually better off with a smaller swap space, because then you'll trigger the OOM ...


16

If you run out of physical memory, you use virtual memory, which stores the data in memory on disk. Reading from disk is several orders of magnitude slower than reading from memory, so this slows everything way down. (Exchanging data between real memory and virtual memory is "swapping". The space on disk is "swap space".) If your app is "using swap", ...


15

Do I need a swap partition? You need a swap partition (not a swap file) to send your workstation to sleep. How can I force the kernel not to use swap? sysctl vm.swappiness=0 On another note: How is that related to server administration?


15

"Pages Input / sec is the counter to watch, but you shouldn't worry about it "swapping" as windows does not use the page file like *nixes do. First you need to understand that windows pages in not out. I'm going to quote the relevent portion of Eric Lipperts blog post (lightly edited) since I can't say it any better myself: "RAM can be seen as merely a ...


15

Assuming that you want to create 512MB swap file: # dd if=/dev/zero of=/swapfile bs=1024 count=524288 Setup swap area with: # mkswap /swapfile Activate it: # swapon /swapfile Add to /etc/fstab for permanent: echo -e "/swapfile\t\tswap\t\tswap\t\tdefaults\t0 0" >> /etc/fstab and verify with free -m.


14

Red Hat recommends the following formula for servers with lots of ram: if MEM < 2GB then SWAP = MEM*2 else SWAP = MEM+2GB If your system has 1 GB ram, your swap would be 2 GB, for 16 GB it would be 18 GB.


13

Do it as root: swapoff /dev/hda3 mkswap /dev/hda4 swapon /dev/hda4 and edit swap entry in /etc/fstab


13

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 ...


12

You are I/O-bound. Your system is a little life raft, battered in a stormy sea of buffer/cache/VM paging swells that are 100 feet tall. Wow. Just...wow. You're moving about 100Mbyte/sec out your I/O, you're deep past 50% CPU time in I/O wait, and you have 4Gb of RAM. The backpressure on this server's VM must be enormous. Under "normal" circumstances, ...


12

Actually it doesn't make a lot of difference as long as you don't use sparse files. Creating a "normal" file with dd will allocate the file (if at all possible) in a single run, while creating a sparse file will tell you that you have a 10GB file lying around but not actually using up all the space. I'm not quite sure wether mkswap won't allocate the space ...


12

If you are using RAID1 you won't lose half your swap, only one of the two mirrors. The worst case here is you'll lose any performance benefit you might otherwise have gained. If you have two separate swap areas on the individual drives the kernel will use both in a fashion similar to RAID0 (if they have the same priority set) or JBOD (if priorities differ, ...


12

Windows and linux have two different page/swap strategies. Linux Linux wants to avoid using swap space at all, and waits until the last possible moment. If you see a large amount of swap in linux, your system likely is or was in trouble. This strategy is good for minimizing overall disk i/o, which is the slowest part of your system, but weaker for systems ...


12

9/10 OOM killer will come by and kill the program with the biggest memory consumption. Else your system will crash. I'm assuming you are on Linux.


11

Windows memory management relies heavily on the paging file(s) for many reasons, not only for "swapping out" in low memory conditions; this has been the subject of endless debates, but the bottom line is: Windows actually works a lot better when there's a page file, even if plenty of RAM is available. You should leave it on, unless you're severely limited ...


11

Enter top, then hit f to edit the visible fields, hit p to show swap usage, then hit Enter to get back to the display of programs. Use Shift+< and > to get it to sort by swap usage. Linux swaps data from RAM based on how likely it is (in Linux's personified opinion) that it will need to be referred to any time soon. You can alter your swappiness to ...


11

This is an interesting question. I've never thought about data security at the hypervisor level... usually security policies and hardening revolve around OS-specific tasks (limiting daemons, ports, disabling core files, filesystem mount options, etc.) But after some quick research (and running strings against active VMWare .vswp files) shows that it's ...


10

On large systems, 8GB of physical RAM, we usually allocate 2GB of swap. These are loaded database servers running Oracle or PostgreSQL. For years, I've never seen swap hit even under heavy load. Heavy load is roughly 100 to 150 users doing around 10,000 SQL reads, and maybe 2,500 writes per minute. We also adjust the swapiness level up to discourage ...


10

I was in training in a class taught by Ted Ts'o, and the way he explained it to me when I asked the same question was like this... By default, the kernel reserves most of the memory for caching things like filesystem metadata. That's why your "used" column shows 905MB. That's the total memory that's "used", meaning by programs and by cache. The actual ...


10

You decided to create a separate swap partition upon installation. You can't resize it online - even an offline resize is going to take a considerable amount of time and bear the potential risk of damaging your subsequent filesystem on /dev/sdc2. The easiest option to work around this is to either create a new swap partition on a different disk you don't ...


10

It is NOT recommended to turn off swap even if you have enough memory. If your server needs more memory and it did not get it, it will crash. However, this can be prevented (to some extent) when you have a swap area. Yes, your server performance will degrade when using swap, but at least it will be operational and accessible. Then, you can plan for adding ...


10

I would say it depends on your use case and the rest of the answers have covered this pretty well. 4G of swap are after all a cheap way to buy some safety. And I feel that this cheapness is what is making people not want to turn it off. But let me answer with a rhetorical question. If money is not an issue, and you have a choice between two systems - one ...


9

On hard disks, throughput and seeking is often faster towards the beginning of the disk, because that data is stored closer to the outer area of the disk, which has more sectors per cylinder. Thus, creating the swap at the beginning of the disk might improve performance. For a 2.6 Linux kernel, there is no performance difference between a swap partition and ...


9

You can tune it echoing some number between 0 to 100 into /proc/sys/vm/swappiness. This control is used to define how aggressive the kernel will swap memory pages. Higher values will increase agressiveness, lower values decrease the amount of swap. A value of 0 instructs the kernel not to initiate swap until the amount of free and file-backed ...


9

Memory management is very complex, Understanding The Linux Kernel by O'Reilly gives lots of details. The idea though is that you can swap out memory that will probably never be used again proactively. You can control how likely the swap is used with a value ranging from 0 to 100 in /proc/sys/vm/swappiness. A Higher number means more likely to be swapped. ...


9

In a pinch, you can create a new swap partition or file. For a partition: Format the new partition with mkswap /dev/sdx1 Add the new swap partition to /etc/fstab. Run swapon -a to activate the new swap. To add a swap file: Create the file. This command creates a 1 gigabyte file: dd if=/dev/zero of=/swap bs=1M count=1000 Format the swap file: mkswap ...


9

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/). ...



Only top voted, non community-wiki answers of a minimum length are eligible