Swap Memory in Use

I have recently set up linode 1024 and hosted 2 websites in LAMP server.

Visits as per Google Analytics:-

Blog: 4000 per day.

Forum: 800 per day.

Pageviews as per Google Analytics:-

Blog: 10000 per day.

Forum: 4500 per day.

When I run, free -m:

total used free shared buffers cached

Mem: 987 724 262 0 20 209

-/+ buffers/cache: 494 493

Swap: 255 4 251

I contacted support and learned to use:

swapoff -a

swapon -a

I get swap memory free at that moment but again it is used. (often used 13 MB). Is it normal?

7 Replies

See http://linuxatemyram.com

You're only using half your RAM, the rest is being used as file system cache. (That's good).

Things will get swapped out occasionally even if you have free RAM, if the RAM manager decides some RAM isn't going to be used for a while, it will swap it out. So yes, it's normal.

It's only a problem if you're swapping a lot, since swap is slow and hits your disk as well, slowing everything else down.

i don't know why support would tell you to turn swap off and on.

it's not only normal, it is good for efficiency to have a little swapped out.

(swap out is good, swap in is bad)

what you have to watch out for is swap in, if you run free (not free -m) a handful of times during peak period and the swap used number doesn't change, you're all good.

@kyhwana:

You're only using half your RAM, the rest is being used as file system cache. (That's good).
Here is the output of free command. I am currently using 688MB out of 1GB Memory and 7MB out of 256MB Swap space.

total used free shared buffers cached

Mem: 1011432 688500 322932 0 22628 156628

-/+ buffers/cache: 509244 502188

Swap: 262140 7700 254440

@chesty:

if you run free (not free -m) a handful of times during peak period and the swap used number doesn't change, you're all good.
I checked 5 times the output of free and always got the same swap used space i.e. 7700. :D

However, I am attaching the graphs for your kind perusal. Please let me confirm that my system is optimized and configured properly. Thank you.

~~![](<URL url=)http://wbxpress.com/wp-content/uploads/2013/05/1.png" />

~~![](<URL url=)http://wbxpress.com/wp-content/uploads/2013/05/2.png" />

~~![](<URL url=)http://wbxpress.com/wp-content/uploads/2013/05/3.png" />

~~![](<URL url=)http://wbxpress.com/wp-content/uploads/2013/05/4.png" />

I could not understand why spikes are present in the graph. I have not set up any cron jobs. I am presently running a wordpress and a phpBB site.~~~~

Is everything working OK?

If so, then everything is working OK.

A small amount of swap being used is normal as long as it's only writes and not reads. If your box never touches swap at all then you've allocated way to much RAM to the system.

the default os installs have standard hourly, daily, weekly and monthly cron jobs installed.

I'm guessing the spike around 6am is the daily cron job, possible the one that updates the package index.

it's possible to tune your system further, but you can learn over time, since your sites are purring along there's no hurry.

for mysql there's mysqltuner.pl there're also a number of different things you can do to speed up apache and php. they don't

come without risks, you might make things worse, so make one change at a time and document and measure everything, give each

change time to bed in over a few days/weeks.

or leave things as they are, since it's working fine.

@ chesty: Thank you very much for your kind words. I would rather concentrate in my websites with peace of mind, keeping the existing settings until any problem arises in future. I feel relaxed now. :-)

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct