LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   SWAP Partition location (https://www.linuxquestions.org/questions/linux-server-73/swap-partition-location-4175466721/)

austin0902008 06-20-2013 05:37 AM

SWAP Partition location
 
Hi All,

I have one query, When we install any Enterprise Linux server, Shall we create the SWAP partition on Primary or Extended?

How is the generally deploy specially on those Internet Server?

I would like to know if we can use this for tuning the server.

Regards,
Austin

TobiSGD 06-20-2013 06:13 AM

It doesn't matter at all if it is a primary or a logical partition in an extended partition. If you want to tune it for speed you should put the swap partition onto the fastest part of the disk, which is usually the outer part, to get the best transfer data. A different approach would be to put the swap partition in the middle of the disk, so that head movements from and to the swap partition are as short as possible. The real thing to tune your server for speed would be to add more RAM, so that swap is rarely used in the first place, or at least to use a fast SSD for swap storage, that will give you better transfer rates and minimizes seek times.

johnsfine 06-20-2013 07:09 AM

Quote:

Originally Posted by TobiSGD (Post 4975294)
It doesn't matter at all if it is a primary or a logical partition in an extended partition.

I agree.

Quote:

If you want to tune it for speed you should put the swap partition onto the fastest part of the disk, which is usually the outer part, to get the best transfer data. A different approach would be to put the swap partition in the middle of the disk, so that head movements from and to the swap partition are as short as possible.
That is obsolete advice based on ram prices that were so high that configuring a server with "enough" ram was not cost effective. Those days are long gone.

Swap on a server now serves two purposes:
1) Stale anonymous data (typically used in startup of service processes and never touched during normal operation) can be swapped out once and left in swap till shutdown.
2) Graceful degradation (rather than OOM killer) in case of memory leak or unexpected demand crunch.

Both those uses imply swap should be put out of the way somewhere, saving premium disk positions for more important purposes. On a system with a single hard drive, that typically means the swap partition goes at the end of the drive.

Quote:

The real thing to tune your server for speed would be to add more RAM, so that swap is rarely used in the first place,
I would guess the server already has enough ram that swap is rarely used.

Quote:

or at least to use a fast SSD for swap storage, that will give you better transfer rates and minimizes seek times.
If you have both SSD and hard disk and can choose:

If swap is rarely used, taking up SSD space is a waste.
If swap is heavily used, using SSD is still a waste. Swap usage typically has one write for every read. That is low performance for SSD. SSD should be used for contents that are mostly read and rarely written.

If you have a mix of SSD and hard drive and you have such limited ram that swap speed is a noticeable factor in performance and you can't simply add enough ram, you may want to tune the swappiness parameter.

First you would make sure all the commonly used programs are stored in SSD. Then reduce swappiness. The default swappiness in Linux is based on the approximation that one reread of a program page is half as expensive as a write plus reread of swap. But if program storage is on SSD, a reread of a program page is much less than half as expensive as a swap. So a lower swappiness may conserve ram at the cost of many program page rereads, and that conserved ram saves a few swaps, netting to better performance since SSD reads are so fast.

TobiSGD 06-20-2013 07:57 AM

Quote:

Originally Posted by johnsfine (Post 4975328)
If swap is heavily used, using SSD is still a waste. Swap usage typically has one write for every read. That is low performance for SSD. SSD should be used for contents that are mostly read and rarely written.

I disagree. Modern SSDs have write speeds of above 400MB/s. I wouldn't call that low performance, but if you do, how would you call write speed of mechanical disks?

austin0902008 06-21-2013 02:27 AM

Hi All,

Thank you for providing this valuable information.

Regards,
Austin


All times are GMT -5. The time now is 11:03 AM.