Re: To Swap, or not to Swap

From: Tim Gorman <tim.evdbt_at_gmail.com>
Date: Thu, 30 Mar 2023 17:25:22 -0700
Message-ID: <c198b944-4dda-9fa9-8f42-8dce7c52e9bc_at_gmail.com>



Jared,

You've made a good point with your testing.  In essence, /fail fast/.  If it is just /fail fast/ versus /fail slow/, then of course we all choose to /fail fast/ and then recover.

The only question that comes to my mind is whether the presence of a swapfile always means slow failure.

Are there no longer any scenarios where the swapfile allows the system to recover, without failing or hanging?

For example, in Azure, VMs can use remote storage (a.k.a. OsDisk) for the swapfile, or VMs can locate the swapfile on optional direct-attached SSD storage that is considered "temporary" or ephemeral, because when the VM is stopped and deallocated, the direct-attached storage has to be erased, because another VM may be allocated to it in future.  It is not quality of storage that makes it "ephemeral", just the use-case.  Anyway, the OsDisk has I/O latency averaging 0.70 ms for both reads and writes, but the so-called "ephemeral" disk provides less than 0.05 ms I/O latency, which is about 14x faster.

Clearly the performance of the storage on which the swapfile resides is going to make a difference in its usefulness.  If your testing involved slow storage, then I can see where the machine would take 7-8 mins to fail.  I'm not trying to denigrate the resources you used, but I'm trying to ask if the swapfile is on fast storage, then perhaps could it be more helpful, even in extreme situations?

In other words, shouldn't we ensure that a swapfile is fast, as well as big enough?  Wouldn't more performant storage allow the swapfile to recover the situation?

Thanks so much for the thought exercise!

-Tim

On 3/30/2023 10:46 AM, 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
>
>
>
>
> On Thu, Mar 30, 2023 at 9:24 AM Jared Still <jkstill_at_gmail.com> wrote:
>
> That is the question.
>
> I am curious about current thoughts on having or not having a swap
> partition on Linux based Oracle servers.
>
> Let's assume typical production standard servers with a reasonable
> amount of RAM, sway 256G or more.
>
> I  have some thoughts on this myself, but would like to see
> others' thoughts on this.
>
>
> 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
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Fri Mar 31 2023 - 02:25:22 CEST

Original text of this message