How big your swap partition to be (2024)

Feb 5, 2020 8:19:00 AM


CloudLinux OS team

CloudLinux OS team

  • Technical Blog
  • swap

How big your swap partition to be

How big your swap partition to be (2)

Typically - you should never have more than 2GB of swap. On shared hosting servers - you're better of with 0.5 or no swap at all.

Let us explain the problem.

1. In ancient times, swap was used so that computer can do its job (even if slow) even in thecase when aprogram(s) doesn't fit into memory. We are past that.

2. In more modern time, it is mostly used so some of the programs that are not used right now could be pushed out of RAM, giving some extra RAM for caches/buffers to get extra performance out of the server.

Note that in that case, only programs that are rarely used (at most once for several minutes, more like once in a few hours) are good candidates for that.

On a typical shared hosting server - there might be about 1/2GB of such programs.

Now, having more swap sounds like a non-issue until your server doesn't have problems.

Yet, it becomes a problem if something "happens" that causes server to use up all the RAM.

With no/small swap, OOM killer (a kernel thread that monitors memory consumption) will detect that server doesn't have enough memory - decide which process to kill, and will kill it.

It will do it for as long as it needed, killing processes left and right.

This will result in servers acting badly, giving out 500 errors, or even stop serving HTTP requests at all. Yet, you will still be able to get into the server via SSH, and figure out/fix whatever is happening.

With the large swap, OOM killer (rightfully) thinks that there are plenty of memory left, so it doesn't act. Processes that were getting more ram, are the one that needs to be running (based on OS), so everything else will be pushed out to swap. That includes Apache/PHP processes, SSH, MySQL, etc...

And whatever is in swap - is VERY slow. 1000s of times slower...

So, now:

HTTP doesn't work. Requests timeout - though OS tries to bring up Apache/PHP from swap, causing something else into swap, trashing disks.

SSH doesn't work... probably timeouts as well. Maybe you can get it to work if you wait for 30 minutes, as it competes with all the HTTP requests/apache processes.

Logging doesn't work - your IO overloaded with all the swap disk IO that are trashing your disk.

As a result, you get anunresponsive server, and often - no idea what happened.

Our advice - shrink swap to at most 0.5G-1GB, or turn it off completely, as by the time you have 2GB in SWAP - your server is hosed.

How big your swap partition to be

Feb 5, 2020 8:19:00 AM

CloudLinux OS team

  • Technical Blog
  • swap

How big your swap partition to be (3)

Typically - you should never have more than 2GB of swap. On shared hosting servers - you're better of with 0.5 or no swap at all.

Let us explain the problem.

1. In ancient times, swap was used so that computer can do its job (even if slow) even in thecase when aprogram(s) doesn't fit into memory. We are past that.

2. In more modern time, it is mostly used so some of the programs that are not used right now could be pushed out of RAM, giving some extra RAM for caches/buffers to get extra performance out of the server.

Note that in that case, only programs that are rarely used (at most once for several minutes, more like once in a few hours) are good candidates for that.

On a typical shared hosting server - there might be about 1/2GB of such programs.

Now, having more swap sounds like a non-issue until your server doesn't have problems.

Yet, it becomes a problem if something "happens" that causes server to use up all the RAM.

With no/small swap, OOM killer (a kernel thread that monitors memory consumption) will detect that server doesn't have enough memory - decide which process to kill, and will kill it.

It will do it for as long as it needed, killing processes left and right.

This will result in servers acting badly, giving out 500 errors, or even stop serving HTTP requests at all. Yet, you will still be able to get into the server via SSH, and figure out/fix whatever is happening.

With the large swap, OOM killer (rightfully) thinks that there are plenty of memory left, so it doesn't act. Processes that were getting more ram, are the one that needs to be running (based on OS), so everything else will be pushed out to swap. That includes Apache/PHP processes, SSH, MySQL, etc...

And whatever is in swap - is VERY slow. 1000s of times slower...

So, now:

HTTP doesn't work. Requests timeout - though OS tries to bring up Apache/PHP from swap, causing something else into swap, trashing disks.

SSH doesn't work... probably timeouts as well. Maybe you can get it to work if you wait for 30 minutes, as it competes with all the HTTP requests/apache processes.

Logging doesn't work - your IO overloaded with all the swap disk IO that are trashing your disk.

As a result, you get anunresponsive server, and often - no idea what happened.

Our advice - shrink swap to at most 0.5G-1GB, or turn it off completely, as by the time you have 2GB in SWAP - your server is hosed.

How big your swap partition to be (2024)
Top Articles
This Warren Buffett ETF Could Turn $300 Per Month Into $976,000 While Barely Lifting a Finger | The Motley Fool
Tips if You're Living Paycheck to Paycheck - United Texas CU
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Pearson Correlation Coefficient
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Dong Thiel

Last Updated:

Views: 5792

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Dong Thiel

Birthday: 2001-07-14

Address: 2865 Kasha Unions, West Corrinne, AK 05708-1071

Phone: +3512198379449

Job: Design Planner

Hobby: Graffiti, Foreign language learning, Gambling, Metalworking, Rowing, Sculling, Sewing

Introduction: My name is Dong Thiel, I am a brainy, happy, tasty, lively, splendid, talented, cooperative person who loves writing and wants to share my knowledge and understanding with you.