From owner-freebsd-questions@FreeBSD.ORG Tue May 3 18:56:23 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 98AD816A4CF for ; Tue, 3 May 2005 18:56:23 +0000 (GMT) Received: from malasada.lava.net (malasada.lava.net [64.65.64.17]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3CD9B43D8A for ; Tue, 3 May 2005 18:56:23 +0000 (GMT) (envelope-from cliftonr@lava.net) Received: by malasada.lava.net (Postfix, from userid 102) id 0AFDC153885; Tue, 3 May 2005 08:56:16 -1000 (HST) Date: Tue, 3 May 2005 08:56:15 -1000 From: Clifton Royston To: Chris Knipe Message-ID: <20050503185614.GA17658@tikitechnologies.com> Mail-Followup-To: Chris Knipe , freebsd-questions@freebsd.org References: <000601c5500e$85b4f3c0$0a01a8c0@ops.cenergynetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000601c5500e$85b4f3c0$0a01a8c0@ops.cenergynetworks.com> User-Agent: Mutt/1.4.2i cc: freebsd-questions@freebsd.org Subject: Re: swap space X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2005 18:56:23 -0000 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@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