Welcome to the Linux Foundation Forum!

Swap space is never used, are my settings correct

I'm on GNU/Linux and top command always show that swap space is always 0k used!

How to make sure that its used. I changed its priority from -1 to 1. Its still not used.

Please help me out.

Following are the various stats:

<<<<<<<<<<<<<<<<<<<<<<<br />
top - 04:30:55 up 1 day, 1:35, 2 users, load average: 1.04, 0.47, 0.46

Tasks: 106 total, 2 running, 104 sleeping, 0 stopped, 0 zombie

Cpu(s): 1.0% us, 3.4% sy, 1.3% ni, 85.2% id, 6.4% wa, 0.0% hi, 2.7% si

Mem: 3089396k total, 1954548k used, 1134848k free, 157268k buffers

Swap: 2031608k total, 0k used, 2031608k free, 1290560k cached

%cat /proc/sys/vm/swappiness

60

%swapon -s

Filename Type Size Used Priority

/dev/mapper/VolGroup00-LogVol01 partition 2031608 0 1

# cat /etc/fstab

# This file is edited by fstab-sync - see 'man fstab-sync' for details

/dev/VolGroup00/LogVol00 / ext3 defaults 1 1

LABEL=/boot /boot ext3 defaults 1 2

none /dev/pts devpts gid=5,mode=620 0 0

none /dev/shm tmpfs defaults 0 0

none /proc proc defaults 0 0

none /sys sysfs defaults 0 0

/dev/VolGroup00/LogVol01 swap swap defaults 0 0

/dev/hda /media/cdrom auto pamconsole,exec,noauto,managed 0 0

/dev/fd0 /media/floppy auto pamconsole,exec,noauto,managed 0 0

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Comments

  • mfillpot
    mfillpot Posts: 2,177
    Your results are showing that you have 3G of RAM which is more than enough for most basic tasks, in most cases swap is used as overflow when you exceed your RAM space. I do not understand why you would want to use swap instead of RAM, but you can change the priority by changing your swappiness value, the higher the value (up to 100) the greater potential for swap to be used.

    In my case with my desktop which has 4G or RAM, I only use swap space when I am running virtual machines.
  • Thanks for the help.

    More background: This machine is a server machine. There are seven to eight other client machines in the intranet which copies data from this server; upto 400MB data is copied by each client. Each client continously writes data to the server machine. So it may happen that 400MB * 7; this much data is transferred from the server!!! Plus non-stop writes to server!!

    Problem: Many times, when the client machine is trying to access html pages via the browser, it takes few minutes (upto 5 minutes) to deliver the data. For this slowness I suspected that since the swap space is not used we are getting this slow response.

    I want to know how to improve the performance and if unused swap space is the cause.
  • mfillpot
    mfillpot Posts: 2,177
    The RAM has much greater response speed than the swap, with that being the case I do not think that is the bottleneck, I think it is most likely related to available cpu cycles.

    You can try increasing the swappiness to see if that will improve performance. But I think the bottleneck could be in the cpu scheduling, a network bottleneck or even an issue with the disk performance. Since this is a production server it would not be best to just start changing things, you need to run some logging and conduct some research before implementing a change or you will risk creating greater performance issues.

    If you can confirm that the issue is a full cpu during these long wait times, then you would want to use the renice tool to change cpu priorities for applications to give your web services greater priority. http://www.linux.com/archive/feed/58638

    If the issue is a network issue then you must look at replacing the low throughput hardware to allow more traffic to pass to the server.

    After the information you posted about the delay I would interested in seeing exactly what is causing that kind of a delay, so please keep us updated on what you try and what you find.
  • gomer
    gomer Posts: 158
    Another posibility is a bottle neck at the bus with the drives. If you are really reading and writing that much data simultaneously to that machine, the drives and the bus that the drives are on may not be able to keep up.

    Sources of a network bottle neck can be anythng from the switch being used in the LAN, to improper cabling (e.g. too much untwisted where it was crimped), to the bus into which the network card is plugged. Consider for example, a 1000baseT card plugged into a PCI bus. A PCI bus will NOT move data at 1000bps ....
  • I tried changing the swapiness to 100 but it did not showed any swap usage via top; although I'm waiting for observing it when same problem is seen again. I'll check if its a full CPU issue and record top details with full load.

    Another thing is that this particular server is a VM. (sorry, forgot to mention this earlier). I'll keep updating.
  • mfillpot
    mfillpot Posts: 2,177
    Since it is a VM there are additional layers that could be causing the problem such as contending for resources with other VMs running under the same host or potential issues with the virtual disks. I would recommend monitoring both the VM client and the host machine to track bottlenecks and their sources.
  • The issue just happened, so after fours days of up time the server memory shows following:

    top - 09:03:38 up 3 days, 22 min, 2 users, load average: 0.00, 0.03, 0.00
    Tasks: 104 total, 1 running, 103 sleeping, 0 stopped, 0 zombie
    Cpu(s): 0.2% us, 0.2% sy, 0.0% ni, 98.6% id, 0.8% wa, 0.0% hi, 0.1% si
    Mem: 3089396k total, 3059924k used, 29472k free, 137096k buffers
    Swap: 2031608k total, 0k used, 2031608k free, 2526236k cached

    So, at this time when any client tries to copy that 200mb file, it hangs. So, somehow it never starts using the
    swap space. (which its supposed to start using when RAM is near full!)
    I am now rebooting the server to avail all the 3gb RAM!
  • mfillpot
    mfillpot Posts: 2,177
    Based upon the amount of RAM that is still showing as free, I don't think the actions are really eating the RAM. Have you considered that the RAM may be used for the prefetch operations? Read http://www.linuxatemyram.com/ to learn about RAM usage, it will also tell you how to free the cache next time it appears full so you can properly asses the RAM use.

    I highly recommend looking to the operations on the host machine and the other virtual machines on the host to find the source of the bottleneck.
  • Ram is like real food and swap is like army rations. You only eat the army rations when you run out of real food, and when you have to eat army rations, life sucks. Whatever solution you come up with, using swap is probably not what you want to do.

    What virtualization system are you using? Vmware? Xen? KVM? What other things is the virtualization host doing? How many other VMs are you running? How are they behaving?

    What kind of HDD setup do you have? If the host/dom0/metal just has a regular disk, and your'e sharing it among multiple VMs including this IO intensive one, that's probably your bottleneck. Is the host OS using lots of swap? I could imagine something like you're describing if the host OS is thrashing but the guest claims to have free ram.

    What are you doing that's using so much network? You may have to figure out a better way to make everyone play nicely. Do you know for a fact that things only go bad when multiple hosts do these big transfers, or is it just a slow creeping death?

    Really, as I'm typing this, it smells like you have a memory leak that you either need to plug or restart the responsible process automatically. That should be easy to set up. Do you know what processes are eating the ram? You should find out.

Categories

Upcoming Training