swap space

Clifton Royston cliftonr at tikitechnologies.com
Tue May 3 11:56:23 PDT 2005


On Tue, May 03, 2005 at 08:32:54PM +0200, Chris Knipe wrote:
> Simple question really... Can you ever have to much swap space?
 
  Only if there are better things you can do with that disk (or money.)
In this case, RAM might be a better priority, see below.

> We're sitting with quite a nifty P4 System with 1GB Ram.  We will more than 
> likely add another 2 or 3GB in the month to come as our applications 
> (mainly perl) are consuming vast amounts of memory and swap.
 
  You might want to look at your application architecture as to why you
are using all that virtual memory and whether you could change
something so as not to be using so much at once.

> We made the mistake however of just allocating 512MB swap as we did not 
> know accurately at the time of installation what the resouce requires are 
> going to be (especially not that it would be this high).
> 
> Obviously reinstalling the entire OS / Applications is not really a option. 
> We may want to install a dedicated 40GB just for swap... Would this be 
> advisable, or will it actually slow the system down?  And to what extend?
 
  Having lots of swap space shouldn't slow a system down.  However,
*using* it will.  If your applications are hitting the swap any more than
occasionally under peak load, you should assume that your system is
running a good order of magnitude slower than it needs to (i.e. at
least a factor of 10.)

  A traditional rule of thumb is to have 1x - 2x the total RAM size in
swap space.  This assures that you can do a crash dump and that you can
deal with peak load of 2x the normal maximum number of processes by
swapping them out.  Beyond that, you are probably better off with the
system just refusing to fork more processes or allocate them memory.

  Sometimes unbounded swap usage reflects the system "falling off a
cliff" as the result of an inbound transaction request rate which
exceeds the transaction service rate.  If the outstanding transactions
build up to the point that the system starts to swap a little bit, then
the system performance drops dramatically as the system needs to page
data out/in to run some processes.  This causes the transaction service
rate to drop sharply (e.g. by an order of magnitude as I mentioned
above.) As a direct result the number of outstanding processes shoots
up and the VM and swap usage goes through the roof.

  If this is the scenario, you should definitely add more RAM before
worrying about adding more swap.  The swap won't hurt, but the RAM is
what will actually benefit your system.  (Depending on your
application, software changes may have the most benefit of all.)

  There's my free advice, worth every penny.
  -- Clifton

-- 
          Clifton Royston  --  cliftonr at tikitechnologies.com 
         Tiki Technologies Lead Programmer/Software Architect
"I'm gonna tell my son to grow up pretty as the grass is green
And whip-smart as the English Channel's wide..."
                                            -- 'Whip-Smart', Liz Phair


More information about the freebsd-questions mailing list