I think I''m having problems with Ruby/Rails using a large amount of my server memory. After starting Lighttpd is seems to work ok but after about half an hour the server memory usage shoots up and remains around 95%. Killing lighttpd reduces this to a normal level. I''m running in production mode. Is this normal? How can I reduce it? -- Regards, David Mytton Managing Director - Olate Ltd http://www.olate.co.uk T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org
How much memory is it actually using? We have just over 100 running Rails apps on our beta server, and in total they''re using about 3.5GB RAM. There''s a mixture of development and production mode sites. I''ve found that average memory consumption per site is about 30MB to 100MB.... Your problem wouldn''t be lighttpd using the memory, but rather the ruby processes launched by FastCGI. So monitor them and let us know how much memory it''s using in production. P.S. How many FastCGI processes are you spawning? Ben On 8/17/05, David Mytton <david-nkCc03+qR4SsTnJN9+BGXg@public.gmane.org> wrote:> I think I''m having problems with Ruby/Rails using a large amount of my > server memory. After starting Lighttpd is seems to work ok but after > about half an hour the server memory usage shoots up and remains around > 95%. Killing lighttpd reduces this to a normal level. I''m running in > production mode. Is this normal? How can I reduce it? > -- > Regards, > > David Mytton > Managing Director - Olate Ltd > http://www.olate.co.uk > > T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) > F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
How can I find out the total memory usage? I have set up lighttpd to create no more than 5, with a minimum of 1: fastcgi.server = (".fcgi" => ( "blog" => ( "min-procs" => 1, "max-procs" => 5, "socket" => "/tmp/rails-notes-blog.fastcgi", "bin-path" => "/home/notes/blog/public/dispatch.fcgi", "max-load-per-proc" => 25, "idle-timeout" => 60, "bin-environment" => ( "RAILS_ENV" => "production" ) ) ) ) Regards, David Mytton Managing Director - Olate Ltd http://www.olate.co.uk T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org Ben Myles wrote:> How much memory is it actually using? We have just over 100 running > Rails apps on our beta server, and in total they''re using about 3.5GB > RAM. There''s a mixture of development and production mode sites. > > I''ve found that average memory consumption per site is about 30MB to 100MB.... > > Your problem wouldn''t be lighttpd using the memory, but rather the > ruby processes launched by FastCGI. So monitor them and let us know > how much memory it''s using in production. > > P.S. How many FastCGI processes are you spawning? > > Ben > > On 8/17/05, David Mytton <david-nkCc03+qR4SsTnJN9+BGXg@public.gmane.org> wrote: > >>I think I''m having problems with Ruby/Rails using a large amount of my >>server memory. After starting Lighttpd is seems to work ok but after >>about half an hour the server memory usage shoots up and remains around >>95%. Killing lighttpd reduces this to a normal level. I''m running in >>production mode. Is this normal? How can I reduce it? >>-- >>Regards, >> >>David Mytton >>Managing Director - Olate Ltd >>http://www.olate.co.uk >> >>T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) >>F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org >> >>_______________________________________________ >>Rails mailing list >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >>
On 17.8.2005, at 16:10, David Mytton wrote:> How can I find out the total memory usage?ps auxww | grep fcgi You can find all kinds of useful information from there, including mem and cpu usage. //jarkko> > I have set up lighttpd to create no more than 5, with a minimum of 1: > > fastcgi.server = (".fcgi" => > ( "blog" => > ( "min-procs" => 1, > "max-procs" => 5, > "socket" => "/tmp/rails-notes-blog.fastcgi", > "bin-path" => "/home/notes/blog/public/dispatch.fcgi", > "max-load-per-proc" => 25, > "idle-timeout" => 60, > "bin-environment" => ( "RAILS_ENV" => "production" ) > ) > ) > ) > > Regards, > > David Mytton > Managing Director - Olate Ltd > http://www.olate.co.uk > > T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) > F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org > > > > Ben Myles wrote: >> How much memory is it actually using? We have just over 100 running >> Rails apps on our beta server, and in total they''re using about 3.5GB >> RAM. There''s a mixture of development and production mode sites. >> I''ve found that average memory consumption per site is about 30MB to >> 100MB.... >> Your problem wouldn''t be lighttpd using the memory, but rather the >> ruby processes launched by FastCGI. So monitor them and let us know >> how much memory it''s using in production. >> P.S. How many FastCGI processes are you spawning? >> Ben >> On 8/17/05, David Mytton <david-nkCc03+qR4SsTnJN9+BGXg@public.gmane.org> wrote: >>> I think I''m having problems with Ruby/Rails using a large amount of >>> my >>> server memory. After starting Lighttpd is seems to work ok but after >>> about half an hour the server memory usage shoots up and remains >>> around >>> 95%. Killing lighttpd reduces this to a normal level. I''m running in >>> production mode. Is this normal? How can I reduce it? >>> -- >>> Regards, >>> >>> David Mytton >>> Managing Director - Olate Ltd >>> http://www.olate.co.uk >>> >>> T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) >>> F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Depends what OS you''re running, but if it''s Unix-like try the ''top'' command and ''free''. Also, unless you''re running a very high traffic site I''d suggest setting both ''min-procs'' and ''max-procs'' to 1. You will still be able to serve quite a lot of requests/second with 1 process. Ben On 8/17/05, David Mytton <david-nkCc03+qR4SsTnJN9+BGXg@public.gmane.org> wrote:> How can I find out the total memory usage? > > I have set up lighttpd to create no more than 5, with a minimum of 1: > > fastcgi.server = (".fcgi" => > ( "blog" => > ( "min-procs" => 1, > "max-procs" => 5, > "socket" => "/tmp/rails-notes-blog.fastcgi", > "bin-path" => "/home/notes/blog/public/dispatch.fcgi", > "max-load-per-proc" => 25, > "idle-timeout" => 60, > "bin-environment" => ( "RAILS_ENV" => "production" ) > ) > ) > ) > > Regards, > > David Mytton > Managing Director - Olate Ltd > http://www.olate.co.uk > > T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) > F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org > > > > Ben Myles wrote: > > How much memory is it actually using? We have just over 100 running > > Rails apps on our beta server, and in total they''re using about 3.5GB > > RAM. There''s a mixture of development and production mode sites. > > > > I''ve found that average memory consumption per site is about 30MB to 100MB.... > > > > Your problem wouldn''t be lighttpd using the memory, but rather the > > ruby processes launched by FastCGI. So monitor them and let us know > > how much memory it''s using in production. > > > > P.S. How many FastCGI processes are you spawning? > > > > Ben > > > > On 8/17/05, David Mytton <david-nkCc03+qR4SsTnJN9+BGXg@public.gmane.org> wrote: > > > >>I think I''m having problems with Ruby/Rails using a large amount of my > >>server memory. After starting Lighttpd is seems to work ok but after > >>about half an hour the server memory usage shoots up and remains around > >>95%. Killing lighttpd reduces this to a normal level. I''m running in > >>production mode. Is this normal? How can I reduce it? > >>-- > >>Regards, > >> > >>David Mytton > >>Managing Director - Olate Ltd > >>http://www.olate.co.uk > >> > >>T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) > >>F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org > >> > >>_______________________________________________ > >>Rails mailing list > >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>http://lists.rubyonrails.org/mailman/listinfo/rails > >> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ben Myles railsapphosting.com
Ok. I changed the max-procs to 1 and tried ps auxw | grep ruby: root 29392 0.5 2.1 26280 21976 ? S 14:27 0:01 ruby /home/notes/blog/public/dispatch.fcg Would I be correct in assuming the 2.1 is % memory usage? Regards, David Mytton Managing Director - Olate Ltd http://www.olate.co.uk T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org Ben Myles wrote:> Depends what OS you''re running, but if it''s Unix-like try the ''top'' > command and ''free''. > > Also, unless you''re running a very high traffic site I''d suggest > setting both ''min-procs'' and ''max-procs'' to 1. You will still be able > to serve quite a lot of requests/second with 1 process. > > Ben > > On 8/17/05, David Mytton <david-nkCc03+qR4SsTnJN9+BGXg@public.gmane.org> wrote: > >>How can I find out the total memory usage? >> >>I have set up lighttpd to create no more than 5, with a minimum of 1: >> >>fastcgi.server = (".fcgi" => >> ( "blog" => >> ( "min-procs" => 1, >> "max-procs" => 5, >> "socket" => "/tmp/rails-notes-blog.fastcgi", >> "bin-path" => "/home/notes/blog/public/dispatch.fcgi", >> "max-load-per-proc" => 25, >> "idle-timeout" => 60, >> "bin-environment" => ( "RAILS_ENV" => "production" ) >> ) >> ) >>) >> >>Regards, >> >>David Mytton >>Managing Director - Olate Ltd >>http://www.olate.co.uk >> >>T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) >>F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org >> >> >> >>Ben Myles wrote: >> >>>How much memory is it actually using? We have just over 100 running >>>Rails apps on our beta server, and in total they''re using about 3.5GB >>>RAM. There''s a mixture of development and production mode sites. >>> >>>I''ve found that average memory consumption per site is about 30MB to 100MB.... >>> >>>Your problem wouldn''t be lighttpd using the memory, but rather the >>>ruby processes launched by FastCGI. So monitor them and let us know >>>how much memory it''s using in production. >>> >>>P.S. How many FastCGI processes are you spawning? >>> >>>Ben >>> >>>On 8/17/05, David Mytton <david-nkCc03+qR4SsTnJN9+BGXg@public.gmane.org> wrote: >>> >>> >>>>I think I''m having problems with Ruby/Rails using a large amount of my >>>>server memory. After starting Lighttpd is seems to work ok but after >>>>about half an hour the server memory usage shoots up and remains around >>>>95%. Killing lighttpd reduces this to a normal level. I''m running in >>>>production mode. Is this normal? How can I reduce it? >>>>-- >>>>Regards, >>>> >>>>David Mytton >>>>Managing Director - Olate Ltd >>>>http://www.olate.co.uk >>>> >>>>T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) >>>>F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org >>>> >>>>_______________________________________________ >>>>Rails mailing list >>>>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >> >>_______________________________________________ >>Rails mailing list >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> > > >
On Wed, 2005-08-17 at 14:33 +0100, David Mytton wrote:> Ok. I changed the max-procs to 1 and tried ps auxw | grep ruby: > > root 29392 0.5 2.1 26280 21976 ? S 14:27 0:01 ruby > /home/notes/blog/public/dispatch.fcg > > Would I be correct in assuming the 2.1 is % memory usage?Depends on the options you sent to ps or top or whatever produced that ouput. It is likely though that it is. The actual memory usage in bytes or even k bytes would be of more use. If you rely on percentages, you would quickly be incorrect as soon as anything about the system changed such as adding memory. Also just as problematic when you change what machine it is running on. -- Steven Critchfield critch-wQLwMjUOumVBDgjK7y7TUQ@public.gmane.org KI4KTY
I used ps to produce the output. So how would I get the value in bytes? Regards, David Mytton Managing Director - Olate Ltd http://www.olate.co.uk T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org Steven wrote:> On Wed, 2005-08-17 at 14:33 +0100, David Mytton wrote: > >>Ok. I changed the max-procs to 1 and tried ps auxw | grep ruby: >> >>root 29392 0.5 2.1 26280 21976 ? S 14:27 0:01 ruby >>/home/notes/blog/public/dispatch.fcg >> >>Would I be correct in assuming the 2.1 is % memory usage? > > > Depends on the options you sent to ps or top or whatever produced that > ouput. It is likely though that it is. > > The actual memory usage in bytes or even k bytes would be of more use. > If you rely on percentages, you would quickly be incorrect as soon as > anything about the system changed such as adding memory. Also just as > problematic when you change what machine it is running on. >
On 17.8.2005, at 16:33, David Mytton wrote:> Ok. I changed the max-procs to 1 and tried ps auxw | grep ruby: > > root 29392 0.5 2.1 26280 21976 ? S 14:27 0:01 ruby > /home/notes/blog/public/dispatch.fcg > > Would I be correct in assuming the 2.1 is % memory usage?0.5 is %CPU, 2.1 is %Mem. Like Steven said, the absolute mem consumption is probably of more use, and it''s 21976 kb in your case. //jarkko -- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
In your ps output you have two values: 26280 21976 The first is the memory usage required, the second how much it''s using at this moment. So the system has set aside about 25MB memory for it. That seems about normal. Ben On 8/17/05, David Mytton <david-nkCc03+qR4SsTnJN9+BGXg@public.gmane.org> wrote:> I used ps to produce the output. So how would I get the value in bytes? > > Regards, > > David Mytton > Managing Director - Olate Ltd > http://www.olate.co.uk
Ok thanks for the help from everyone. I''ll keep an eye on it and see how it progresses. Regards, David Mytton Managing Director - Olate Ltd http://www.olate.co.uk T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org Ben Myles wrote:> In your ps output you have two values: 26280 21976 > > The first is the memory usage required, the second how much it''s using > at this moment. > > So the system has set aside about 25MB memory for it. That seems about normal. > > Ben > > On 8/17/05, David Mytton <david-nkCc03+qR4SsTnJN9+BGXg@public.gmane.org> wrote: > >>I used ps to produce the output. So how would I get the value in bytes? >> >>Regards, >> >>David Mytton >>Managing Director - Olate Ltd >>http://www.olate.co.uk
What''s the underlying OS? If Linux, which kernel? Linux has its own ideas about how memory should be managed. David Mytton wrote:> I think I''m having problems with Ruby/Rails using a large amount of my > server memory. After starting Lighttpd is seems to work ok but after > about half an hour the server memory usage shoots up and remains > around 95%. Killing lighttpd reduces this to a normal level. I''m > running in production mode. Is this normal? How can I reduce it?
Linux server.example.com 2.6.9-1.6_FC2 #1 Thu Nov 18 22:03:19 EST 2004 i686 i686 i386 GNU/Linux Regards, David Mytton Managing Director - Olate Ltd http://www.olate.co.uk T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org M. Edward (Ed) Borasky wrote:> What''s the underlying OS? If Linux, which kernel? Linux has its own > ideas about how memory should be managed. > > David Mytton wrote: > >> I think I''m having problems with Ruby/Rails using a large amount of my >> server memory. After starting Lighttpd is seems to work ok but after >> about half an hour the server memory usage shoots up and remains >> around 95%. Killing lighttpd reduces this to a normal level. I''m >> running in production mode. Is this normal? How can I reduce it? > >
On Wed, 2005-08-17 at 14:52 +0100, David Mytton wrote:> I used ps to produce the output. So how would I get the value in bytes?>From the ps man pagerss RSS resident set size, the non-swapped physical memory that a task has used (in kiloBytes). (alias rssize, rsz). vsz VSZ virtual memory size of the process in KiB (1024-byte units). Device mappings are currently excluded; this is subject to change. (alias vsize). These should be the two larger numbers in the output you noticed. So RSS is important as it is your real ram usage right now, but keep an eye on the VSZ number as your app might get swapped out and be slowed down considerably. Also to point out why that percentage wasn''t very useful. If I take the RSS and multiply it by 100/2.1 I see that you have a gig of ram in your machine. But if I look at the actual size by looking at the VSZ number, I see it was 2.5% of your ram even though it isn''t all in ram.> Steven wrote: > > On Wed, 2005-08-17 at 14:33 +0100, David Mytton wrote: > > > >>Ok. I changed the max-procs to 1 and tried ps auxw | grep ruby: > >> > >>root 29392 0.5 2.1 26280 21976 ? S 14:27 0:01 ruby > >>/home/notes/blog/public/dispatch.fcg > >> > >>Would I be correct in assuming the 2.1 is % memory usage? > > > > > > Depends on the options you sent to ps or top or whatever produced that > > ouput. It is likely though that it is. > > > > The actual memory usage in bytes or even k bytes would be of more use. > > If you rely on percentages, you would quickly be incorrect as soon as > > anything about the system changed such as adding memory. Also just as > > problematic when you change what machine it is running on. > >-- Steven Critchfield critch-wQLwMjUOumVBDgjK7y7TUQ@public.gmane.org KI4KTY
OK. Run "top" and when it starts up, type a capital "M" to sort the processes by memory size. In the top of the display, you''ll see something like this: top - 07:36:21 up 3 days, 20:58, 3 users, load average: 0.09, 0.05, 0.03 Tasks: 109 total, 1 running, 107 sleeping, 0 stopped, 1 zombie Cpu(s): 1.7% us, 0.7% sy, 0.0% ni, 97.7% id, 0.0% wa, 0.0% hi, 0.0% si Mem: 515484k total, 498464k used, 17020k free, 167968k buffers Swap: 996020k total, 30544k used, 965476k free, 102788k cached What''s interesting is the total memory (512MB in this case from my workstation) and "cached". "Cached" is the Linux page cache. If this is too small, I/O is slow. If it''s too big, the system will swap. Linux by default tries to keep all memory in use. So 95% of memory in use (5 percent free) isn''t bad in and of itself. It''s only bad if Linux has given so much RAM to page cache that it starts swapping. There''s a kernel parameter you can tweak in a 2.6 kernel to help Linux out. It''s called "swappiness". I''ve forgotten exactly how it''s changed, but if you Google for "Linux swappiness" you''ll find more than you ever wanted to know about it. If your system isn''t swapping, don''t mess with it -- just ignore it and find something else that''s broken. :) If your system is swapping, adjust "swappiness" gradually until it stops swapping, or buy more memory if you can''t find a workable setting. How do you tell if a system is swapping? Well, unfortunately "top" doesn''t tell you. There''s another tool called "vmstat" that will, though. In any event, I suspect this isn''t a Rails or web server problem, if indeed it is a problem at all. :) David Mytton wrote:> Linux server.example.com 2.6.9-1.6_FC2 #1 Thu Nov 18 22:03:19 EST 2004 > i686 i686 i386 GNU/Linux > > Regards, > > David Mytton > Managing Director - Olate Ltd > http://www.olate.co.uk > > T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) > F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org > > > > M. Edward (Ed) Borasky wrote: > >> What''s the underlying OS? If Linux, which kernel? Linux has its own >> ideas about how memory should be managed. >> >> David Mytton wrote: >> >>> I think I''m having problems with Ruby/Rails using a large amount of >>> my server memory. After starting Lighttpd is seems to work ok but >>> after about half an hour the server memory usage shoots up and >>> remains around 95%. Killing lighttpd reduces this to a normal level. >>> I''m running in production mode. Is this normal? How can I reduce it? >> >> >> >
OK. I had been using top with M to find the processes using the most memory. Here is the output: top - 15:54:27 up 16:36, 1 user, load average: 0.05, 0.14, 0.16 Tasks: 99 total, 1 running, 98 sleeping, 0 stopped, 0 zombie Cpu(s): 15.2% us, 1.0% sy, 0.0% ni, 82.8% id, 0.7% wa, 0.0% hi, 0.3% si Mem: 1003360k total, 775844k used, 227516k free, 57984k buffers Swap: 2024180k total, 304k used, 2023876k free, 266512k cached with ruby sitting 7th in the list from the top: 29392 root 18 0 28968 23m 6284 S 0.0 2.4 0:03.31 ruby From what you said that looks ok to me. I was having a problem last night with 16k of swap free, but I understand that there is a memory leak in rails running in development mode, so I changed to production and rebooted and it seemed ok after that. Regards, David Mytton Managing Director - Olate Ltd http://www.olate.co.uk T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org M. Edward (Ed) Borasky wrote:> OK. Run "top" and when it starts up, type a capital "M" to sort the > processes by memory size. In the top of the display, you''ll see > something like this: > > top - 07:36:21 up 3 days, 20:58, 3 users, load average: 0.09, 0.05, 0.03 > Tasks: 109 total, 1 running, 107 sleeping, 0 stopped, 1 zombie > Cpu(s): 1.7% us, 0.7% sy, 0.0% ni, 97.7% id, 0.0% wa, 0.0% hi, > 0.0% si > Mem: 515484k total, 498464k used, 17020k free, 167968k buffers > Swap: 996020k total, 30544k used, 965476k free, 102788k cached > > What''s interesting is the total memory (512MB in this case from my > workstation) and "cached". "Cached" is the Linux page cache. If this is > too small, I/O is slow. If it''s too big, the system will swap. > > Linux by default tries to keep all memory in use. So 95% of memory in > use (5 percent free) isn''t bad in and of itself. It''s only bad if Linux > has given so much RAM to page cache that it starts swapping. > > There''s a kernel parameter you can tweak in a 2.6 kernel to help Linux > out. It''s called "swappiness". I''ve forgotten exactly how it''s changed, > but if you Google for "Linux swappiness" you''ll find more than you ever > wanted to know about it. If your system isn''t swapping, don''t mess with > it -- just ignore it and find something else that''s broken. :) If your > system is swapping, adjust "swappiness" gradually until it stops > swapping, or buy more memory if you can''t find a workable setting. > > How do you tell if a system is swapping? Well, unfortunately "top" > doesn''t tell you. There''s another tool called "vmstat" that will, > though. In any event, I suspect this isn''t a Rails or web server > problem, if indeed it is a problem at all. :) > > > > David Mytton wrote: > >> Linux server.example.com 2.6.9-1.6_FC2 #1 Thu Nov 18 22:03:19 EST 2004 >> i686 i686 i386 GNU/Linux >> >> Regards, >> >> David Mytton >> Managing Director - Olate Ltd >> http://www.olate.co.uk >> >> T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) >> F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org >> >> >> >> M. Edward (Ed) Borasky wrote: >> >>> What''s the underlying OS? If Linux, which kernel? Linux has its own >>> ideas about how memory should be managed. >>> >>> David Mytton wrote: >>> >>>> I think I''m having problems with Ruby/Rails using a large amount of >>>> my server memory. After starting Lighttpd is seems to work ok but >>>> after about half an hour the server memory usage shoots up and >>>> remains around 95%. Killing lighttpd reduces this to a normal level. >>>> I''m running in production mode. Is this normal? How can I reduce it? >>> >>> >>> >>> >>
Just curious, last night when you had the memory problem, how long had the process been running for in development mode? And were you doing anything like stress testing which may have used so much memory? I only ask because on our beta server I''ve rarely seen even apps in development mode use over about 100MB memory... Ben On 8/18/05, David Mytton <david-nkCc03+qR4SsTnJN9+BGXg@public.gmane.org> wrote:> OK. I had been using top with M to find the processes using the most > memory. Here is the output: > > top - 15:54:27 up 16:36, 1 user, load average: 0.05, 0.14, 0.16 > Tasks: 99 total, 1 running, 98 sleeping, 0 stopped, 0 zombie > Cpu(s): 15.2% us, 1.0% sy, 0.0% ni, 82.8% id, 0.7% wa, 0.0% hi, 0.3% si > Mem: 1003360k total, 775844k used, 227516k free, 57984k buffers > Swap: 2024180k total, 304k used, 2023876k free, 266512k cached > > with ruby sitting 7th in the list from the top: > > 29392 root 18 0 28968 23m 6284 S 0.0 2.4 0:03.31 ruby > > From what you said that looks ok to me. I was having a problem last > night with 16k of swap free, but I understand that there is a memory > leak in rails running in development mode, so I changed to production > and rebooted and it seemed ok after that.
It seems that the processes had been building up because there were lots! I had been trying to get lighttpd working properly over the weekend and hadn''t noticed these processes not being killed until yesterday. Regards, David Mytton Managing Director - Olate Ltd http://www.olate.co.uk T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org Ben Myles wrote:> Just curious, last night when you had the memory problem, how long had > the process been running for in development mode? And were you doing > anything like stress testing which may have used so much memory? > > I only ask because on our beta server I''ve rarely seen even apps in > development mode use over about 100MB memory... > > Ben > > On 8/18/05, David Mytton <david-nkCc03+qR4SsTnJN9+BGXg@public.gmane.org> wrote: > >>OK. I had been using top with M to find the processes using the most >>memory. Here is the output: >> >>top - 15:54:27 up 16:36, 1 user, load average: 0.05, 0.14, 0.16 >>Tasks: 99 total, 1 running, 98 sleeping, 0 stopped, 0 zombie >>Cpu(s): 15.2% us, 1.0% sy, 0.0% ni, 82.8% id, 0.7% wa, 0.0% hi, 0.3% si >>Mem: 1003360k total, 775844k used, 227516k free, 57984k buffers >>Swap: 2024180k total, 304k used, 2023876k free, 266512k cached >> >>with ruby sitting 7th in the list from the top: >> >>29392 root 18 0 28968 23m 6284 S 0.0 2.4 0:03.31 ruby >> >> From what you said that looks ok to me. I was having a problem last >>night with 16k of swap free, but I understand that there is a memory >>leak in rails running in development mode, so I changed to production >>and rebooted and it seemed ok after that.
I''d *kill* for an application/server that had 227 MB free and only had 266 MB tied up in page cache on a 1 GB machine. :) You''re in great shape. :) David Mytton wrote:> OK. I had been using top with M to find the processes using the most > memory. Here is the output: > > top - 15:54:27 up 16:36, 1 user, load average: 0.05, 0.14, 0.16 > Tasks: 99 total, 1 running, 98 sleeping, 0 stopped, 0 zombie > Cpu(s): 15.2% us, 1.0% sy, 0.0% ni, 82.8% id, 0.7% wa, 0.0% hi, > 0.3% si > Mem: 1003360k total, 775844k used, 227516k free, 57984k buffers > Swap: 2024180k total, 304k used, 2023876k free, 266512k cached > > with ruby sitting 7th in the list from the top: > > 29392 root 18 0 28968 23m 6284 S 0.0 2.4 0:03.31 ruby > > From what you said that looks ok to me. I was having a problem last > night with 16k of swap free, but I understand that there is a memory > leak in rails running in development mode, so I changed to production > and rebooted and it seemed ok after that. > > Regards, > > David Mytton > Managing Director - Olate Ltd > http://www.olate.co.uk > > T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) > F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org > > > > M. Edward (Ed) Borasky wrote: > >> OK. Run "top" and when it starts up, type a capital "M" to sort the >> processes by memory size. In the top of the display, you''ll see >> something like this: >> >> top - 07:36:21 up 3 days, 20:58, 3 users, load average: 0.09, 0.05, >> 0.03 >> Tasks: 109 total, 1 running, 107 sleeping, 0 stopped, 1 zombie >> Cpu(s): 1.7% us, 0.7% sy, 0.0% ni, 97.7% id, 0.0% wa, 0.0% hi, >> 0.0% si >> Mem: 515484k total, 498464k used, 17020k free, 167968k buffers >> Swap: 996020k total, 30544k used, 965476k free, 102788k cached >> >> What''s interesting is the total memory (512MB in this case from my >> workstation) and "cached". "Cached" is the Linux page cache. If this >> is too small, I/O is slow. If it''s too big, the system will swap. >> >> Linux by default tries to keep all memory in use. So 95% of memory in >> use (5 percent free) isn''t bad in and of itself. It''s only bad if >> Linux has given so much RAM to page cache that it starts swapping. >> >> There''s a kernel parameter you can tweak in a 2.6 kernel to help >> Linux out. It''s called "swappiness". I''ve forgotten exactly how it''s >> changed, but if you Google for "Linux swappiness" you''ll find more >> than you ever wanted to know about it. If your system isn''t swapping, >> don''t mess with it -- just ignore it and find something else that''s >> broken. :) If your system is swapping, adjust "swappiness" gradually >> until it stops swapping, or buy more memory if you can''t find a >> workable setting. >> >> How do you tell if a system is swapping? Well, unfortunately "top" >> doesn''t tell you. There''s another tool called "vmstat" that will, >> though. In any event, I suspect this isn''t a Rails or web server >> problem, if indeed it is a problem at all. :) >> >> >> >> David Mytton wrote: >> >>> Linux server.example.com 2.6.9-1.6_FC2 #1 Thu Nov 18 22:03:19 EST >>> 2004 i686 i686 i386 GNU/Linux >>> >>> Regards, >>> >>> David Mytton >>> Managing Director - Olate Ltd >>> http://www.olate.co.uk >>> >>> T: (646) 257 3714 (USA) T: (020) 7870 9176 (UK) >>> F: (0870) 705 1068 (UK) E: support-ELxQ3fsViAr10XsdtD+oqA@public.gmane.org >>> >>> >>> >>> M. Edward (Ed) Borasky wrote: >>> >>>> What''s the underlying OS? If Linux, which kernel? Linux has its own >>>> ideas about how memory should be managed. >>>> >>>> David Mytton wrote: >>>> >>>>> I think I''m having problems with Ruby/Rails using a large amount >>>>> of my server memory. After starting Lighttpd is seems to work ok >>>>> but after about half an hour the server memory usage shoots up and >>>>> remains around 95%. Killing lighttpd reduces this to a normal >>>>> level. I''m running in production mode. Is this normal? How can I >>>>> reduce it? >>>> >>>> >>>> >>>> >>>> >>> >
David Mytton wrote:> I have set up lighttpd to create no more than 5, with a minimum of 1:You always should set these two numbers to be equal. I''ve had issues with fcgi instances being alive, but unused and defunct in some manner. Lighttpd then starts up another listener, and so you end up with a bunch of sleeping ruby processes taking up memory.