Archive

Archive for July, 2009

The Mayonnaise Jar and 2 Cups of Coffee…

July 14th, 2009 Comments off

When things in your life seem almost too much to handle, when 24 hours in a day are not enough, remember the mayonnaise jar… and the coffee…

A professor stood before his philosophy class and had some items in front of him. When the class began, wordlessly, he picked up a very large and empty mayonnaise jar and proceeded to fill it with golf balls. He then asked the students if the jar was full. They agreed that it was.

So the professor then picked up a box of pebbles and poured them into the jar. He shook the jar lightly. The pebbles rolled into the open areas between the golf balls. He then asked the students again if the jar was full. They agreed it was.

The professor next picked up a box of sand and poured it into the jar. Of course, the sand filled up everything else. He asked once more if the jar was full. The students responded with a unanimous “yes.”

The professor then produced two cups of coffee from under the table and poured the entire contents into the jar, effectively filling the empty space between the sand. The students laughed.

“Now,” said the professor, as the laughter subsided, “I want you to recognize that this jar represents your life. The golf balls are the important things-your God, your family, your children, your health, your friends, and your favourite passions-things that if everything else was lost and only they remained, your life would still be full. The pebbles are the other things that matter like your job, your house, and your car.The sand is everything else-the small stuff.

“If you put the sand into the jar first,” he continued, “there is no room for the pebbles or the golf balls. The same goes for life. If you spend all your time and energy on the small stuff, you will never have room for the things that are important to you. Pay attention to the things that are critical to your happiness. Play with your children. Take time to get medical checkups. Take your partner out to dinner. Play another 18 holes. There will always be time to clean the house and fix the disposal.” Take care of the golf balls first, the things that really matter. Set your priorities. The rest is just sand.”

One of the students raised her hand and inquired what the coffee represented.

The professor smiled. “I’m glad you asked. It just goes to show you that no matter how full your life may seem, there’s always room for a couple of cups of coffee with a friend.”

Understanding the “free” command in Linux

July 1st, 2009 Comments off

Free is a command line interface (CLI) tool available on most Linux and Unix based systems. From the man page

… displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel.”

Running free, you get output similar to the following (by default the numbers are in kilobytes)…

1
2
3
4
5
:~$ free
             total     used     free   shared    buffers     cached
Mem:       3992680  3033116   959564        0     272632    1754476
-/+ buffers/cache:  1006008  2986672
Swap:       979924        0   979924

The numbers are essentially counters representing how the RAM on your Linux system is allocated in bytes. By itself the above is not very readable, but the command comes with a few handy options to make it easier. You can pass it the ‘-m’ parameter to translates the counters to MB, the ‘b’ option does the same in bytes.

1
2
3
4
5
:~$ free -m
             total     used     free   shared    buffers     cached
Mem:          3899     2963      935        0        266       1713
-/+ buffers/cache:      984     2914
Swap:          956        0      956

The first line shows overall usage of the total memory usage on your system. Including any file-system and other caches reserved by the kernel. Since RAM is faster the OS will always try to take advantage of that resource by using it to its fullest. But in practice most of that can be released quite quickly for applications that need more space.

So how can we see how much memory us really being used by the applications on your server? The ‘-/+ buffers’ line shows how much of the actual RAM is in use by applications while the last line shows how much of your slower disk based virtual memory is in use.

Sometimes a PC will start to run relatively slowly, for example when it is running a busy web server. By checking free you will likely see the used column of the last two lines starting to approach the total value. Which is bad for performance and you run the risk of the kernel killing low priority processes to release memory for new tasks.

There are lots of great guides available about optimising memory usage, especially in a server environment. One that I have found handy is on the Rimuhosting.com site. There is also an incredibly extensive but more general page at Linux Troubleshooting with some handy tips. Lots more can be found on Google.