Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am new to linux server administration and I'm trying to figure out if i need a bigger machine. It appears that my machine (running apache2, php5, ubuntu) is using 80% of its memory when getting no traffic at all.

top
Mem:    501392k total,   398704k used,   102688k free,    22508k buffers
Swap:   499996k total,      868k used,   499128k free,   242296k cached

free -m
         total       used       free     shared    buffers     cached
Mem:           489        389        100          0         21        236
-/+ buffers/cache:        130        358
Swap:          488          0        487

I'm not sure if i'm reading this right, but it seems ubuntu is using a lot of memory for caching, but i'm not sure how efficient this is or if i should change my server configuration.

share|improve this question
1  
linuxatemyram.com –  Zoredache Jan 15 '13 at 16:33

3 Answers 3

Your machine has 100MB free and is using about 260MB for buffers and cache. There's no easy way to know how much of the memory it happens to be using for cache it "needs" or whether performance would be helped by having more memory. Excessive disk I/O is a good sign that more memory would help as it would allow a larger cache.

Your system is using memory for one simple reason -- there is no benefit to making it free. If that memory doesn't get used, then making it free was a waste of effort. And if it does get used, then making it free was again wasted effort since it will just have to be made used again. Modern operating systems can easily transition memory from one use to another without having to bother making it free. Modern operating systems only leave memory free when they have no choice.

share|improve this answer
    
Thanks so much for the input! This might be worthy of a separate question on serverfault but do you have recommendations on how to test 'how much memory in the cache it needs' besides running a load test and seeing if response times slow down materially? –  E T Jan 15 '13 at 15:02
1  
That's a very hard thing to tell. It's like asking if a family needs more money. If they're starving or homeless, that's obvious. But if they seem comfortable, the only way to be sure is to give them more money and see what happens. As I said, a good clue that memory is tight is excessive disk I/O. (Swap use growing with load is a good sign too, as is poor performance of course.) –  David Schwartz Jan 15 '13 at 15:04

Exactly knowing what your system is up to might be a bit hard to understand. Here is a more graphical way to view your system called htop.

You can install it using the following command:

sudo apt-get install htop

Besides a graphical bar displaying the amount of memory in use, it also shows what it is used for with color coding. In the below example the application (zimbra) is using the following:
A large amount of active memory (green).
Some buffers (blue).
And a part of the swap/cache is in memory (yellow).

htop example

Also a few tips for you:
You can check if your server is in use by monitoring your apache acces logs using

tail -f /var/log/apache2/access.log

This will give you a live stream of your access logs.

Also you can use iftop, like htop it gives you a graphical representation on what traffic is going at what rate to what location.

install it using

sudo apt-get install iftop
share|improve this answer

Linux will almost always use all available memory for disk buffers (= cache). This is what's happening on your box as well. This is normal and no cause for alarm. The cache pages get dropped when your programmes really do need the RAM.

Also, to get a better impression about the memory (and other resource) use, I'd recommend you look into a command line programme called "htop". Just install it with apt-get and run it from a command line.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.