Re: To Swap, or not to Swap

From: kyle Hailey <kylelf_at_gmail.com>
Date: Thu, 30 Mar 2023 15:44:17 -0700
Message-ID: <CADsdiQiLHv13EKcgUO-NuFXaS1zH5J7NppDFz_tb_h=6FPxgbA_at_mail.gmail.com>



Initially, I was surprised to hear that RDS had turned off SWAP on a significant portion of their fleet. The reason for my concern is that without SWAP, monitoring for memory pressure becomes difficult. In Unix systems, available memory type metrics are problematic because the system tries to consume all memory. However, with SWAP, it's possible to monitor page in/out, which has always been an indicator of memory issues in the past. It's surprising that the LINUX community hasn't implemented better memory pressure metrics. Linux implemented PSI (pressure stall information) for a few years now but I have yet to work on any systems that had PSI available. PSI allows users to see the number of processes waiting on memory pages.

On Thu, Mar 30, 2023 at 12:22 PM Mladen Gogala <gogala.mladen_at_gmail.com> wrote:

> On 3/30/23 13:46, Jared Still wrote:
>
> I was recently asked by a colleague this same question.
>
> He had been asked by a client, with a fairly well regarded sysadmin team.
>
> They wanted to eliminate swap: here's why.
>
> If a process is consuming memory at a prodigious rate, then the OOM (out
> of memory) killer is going to catch up to it and kill it eventually.
>
> Their position was that with a swap partition, this process was prolonged
> far too long.
>
> Without swap, the process gets killed relatively quickly.
>
> With swap, it can take many minutes. The CPU spends so much time managing
> memory on swap (remember, we are at an OOM condition), which is slow, that
> the time to kill the process is prolonged to many minutes.
>
> At first my position was "what, no swap! we can't do that!"
>
> But, I decided to test it a bit.
>
> A small physical server, 4 cores and 32G of RAM, is running Oracle 19.3.
>
> A swingbench test is running, 10 sessions per core.
>
> When I cause an OOM condition with the 16G swap partition enabled, it took
> the system between 7.5-8 minutes to kill the process.
>
> (For the client, the amount of time was 20+ minutes.)
>
> And during that time, it was impossible to logon to the server. The CPU
> was too busy thrashing around in the swap partition.
>
> The next step of course is to disable the swap.
>
> Same OOM condition caused. Time to resolution is now 7 seconds.
>
> There is no swap to manage as if it were RAM.
>
> That is quite a bit difference.
>
> Of course I wondered 'what about paging in memory for new processes?', as
> that often uses a page in swap.
>
> Without swap, it just takes place in memory.
>
> Swap is also a landing place for some pages used to initialize processes,
> as they can only be used once.
>
> This is a minimal amount, and can just be left in memory.
>
> If one really wants to conserve, there is a thing called ZRAM (compressed
> memory) where those pages can be parked, instead of swap.
>
> So, does anyone see any other need for a swap partition?
>
> It seems to have outlived its usefulness.
>
> Jared Still
> Certifiable Oracle DBA and Part Time Perl Evangelist
> Principal Consultant at Pythian
> Oracle ACE Alumni
> Pythian Blog http://www.pythian.com/blog/author/still/
> Github: https://github.com/jkstill
> Personality: http://www.personalitypage.com/INTJ.html
>
>
>
> Hi Jared,
>
> I will assume that your operating system is Linux. Did you try limiting
> the core or rss size from /etc/security/limits.conf? That should kill the
> offending process as soon as the limit is hit. One note on the cheeky side:
> this is the first time I see optimizing of a failure. I assume you have
> isolated the process and that you know what triggers the unwanted
> occurrence? How about killing the offending process with "kill -9" when it
> starts misbehaving?
>
> Regards
>
> --
> Mladen Gogala
> Database Consultant
> Tel: (347) 321-1217https://dbwhisperer.wordpress.com
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Fri Mar 31 2023 - 00:44:17 CEST

Original text of this message