I see kswapd using 100% CPU... how can I tell on which process's behalf kswapd is being used so much?
Why does my server show
total used free shared buffers cached
Mem: 12286456 11715372 571084 0 81912 6545228
-/+ buffers/cache: 5088232 7198224
Swap: 24571408 54528 24516880
I have no idea on calculating the memory in linux. I think it says that 5088232 is used where as 7198224 is free, meaning it is actually consuming 5GB of RAM?
I have a rather old server that has 4GB of RAM and it is pretty much serving the same files all day, but it is doing so from the hard drive while 3GBs of RAM are "free".
Anyone who has ever tried running a ram-drive can witness that It's awesome in terms of speed. The memory usage of this system is usually never higher than 1GB/4GB so I want to know if there is a way to use that extra memory for something good.
- Is it possible to tell the filesystem to always serve certain files out of RAM?
- Are there any other methods I can use to improve file reading capabilities by use of RAM?
More specifically, I am not looking for a 'hack' here. I want file system calls to serve the files from RAM without needing to create a ram-drive and copy the files there manually. Or at least a script that does this for me.
Possible applications here are:
- Web servers with static files that get read alot
- Application servers with large libraries
- Desktop computers with too much RAM
Any ideas?
Edit:
- Found this very informative: The Linux Page Cache and pdflush
- As Zan pointed out, the memory isn't actually free. What I mean is that it's not being used by applications and I want to control what should be cached in memory.
What is better for performance? A partition closer to the inside of the disk will have slower access times, and we must wait for the drive to switch between the OS and swap partitions.
On the other hand, a swap partition bypasses all of the filesystem allowing writes to the disk directly, which can be faster than a file.
What is the performance trade off?
How much does having a fixed size swapfile make a difference?
Is it a case that it will be longer to change to the swap partition, but performance will be better while it is on the swap partition that if it had been a swap file?
This is an old question that I've seen from time to time. My understanding of it is rather limited (having read about the differences a long time ago, but the factoid(s) involved never really stuck).
As I understand it,
Buffers
Are used by programs with active I/O operations, i.e. data waiting to be written to disk
Cache
Is the result of completed I/O operations, i.e. buffers that have been flushed or data read from disk to satisfy a request.
Can I get a clear explanation for posterity?