Portal Home > Knowledgebase > Articles Database > cPanel - Swap Used 100%


cPanel - Swap Used 100%




Posted by !unreal, 07-22-2008, 04:36 AM
My swap is currently at 100% and my website isnt loading. What does swap mean and is this the reason my site isnt loading? Also how do I fix this?

Posted by ~ServerPoint~, 07-22-2008, 05:26 AM
Swap space is the disk space that is set aside for virtual memory. Is apache and named running in the server?

Posted by blueroomhosting, 07-22-2008, 08:32 AM
This means that you don't have enough memory on the system for everything that's running. Swap is extra memory that you can use when your allocation of physical memory (RAM) is used up. It's allocated on the hard disk so is much slower, and will seriously impact system performance. For this reason, you should have enough RAM that you don't need to use swap under normal operating conditions, it's really for those usage spikes that happen occasionally. (You don't say what kind of hosting you have but if you are sharing the system with other people then your swapping is bad for everyone and your host might start getting cross). If your swap is at 100% then you have used up all your main memory (the RAM) and then used up all the swap too. After that the system can't allocate any more, which is why your site won't load. You need to either get a lot more RAM (sounds like you need what you have now, plus what you have in swap, plus some more) or seriously cut back on what you're running. CPanel uses a lot of memory, as does apache by default. If you're not sure what you're doing you can probably hire somebody to take a look at it.

Posted by slrslr, 07-18-2011, 04:52 PM
I believe i have enough ram. There is average 400Mb free when i do TOP -C command Load average is low and websites loading, but i see /tmp looks like to have like 4MB (du /tmp -h) Last edited by slrslr; 07-18-2011 at 04:56 PM.

Posted by Martin-D, 07-18-2011, 04:58 PM
Try restarting Apache and MySQL

Posted by MACscr, 07-18-2011, 05:04 PM
whats the output of 'free -m' ? The full output of 'top' might be useful as well.

Posted by slrslr, 07-18-2011, 06:19 PM
free -m top Apache restarted before 15 mins. And since that, SWAP stays at 71-74%

Posted by slrslr, 02-25-2012, 07:36 AM
In my case SWAP is constantly filling up since Mysql restart. Within 10 days it is like 63.33% USED Swap Used 63.33% (331,400 of 523,260) /dev/loop0 /tmp 6% (53,424 of 1,007,896) How to find the exact cause of this?

Posted by madaboutlinux, 02-25-2012, 09:31 AM
As per the free -m output more than 5GB of RAM is cached which is considered as free but may be that's the reason Swap is been used too. The top output indicates Apache/Mysql are using up high resources and needs to be tweaked. You can also have kernel to stop using SWAP unless RAM is completely used by changing the swappiness value.

Posted by slrslr, 02-26-2012, 06:22 AM
Why it can be the reason? What exactly should i look up and tweak? and in which file? What is a swappiness value and where can i change it please?

Posted by madaboutlinux, 02-27-2012, 04:52 AM
1. Unsure unless someone logs in and check what exactly is running on your system. You can free the cache memory by writing to 1 to the drop_caches file, however, it may make the system a bit slower as the information need to be re-read in the cache again. 2. You should check the Apache (WHM -> Server Configuration -> Apache Configuration) and Mysql (/etc/my.cnf) configuration files. The changes depends on what is running on your server. Paste the Apache and Mysql settings here. 3. swappiness is set to 60 by default, you can change it to 10. Add the below line in /etc/sysctl.conf and execute sysctl -p

Posted by slrslr, 02-27-2012, 09:58 AM
Thanks, i read little bit about this swappiness variable and i think it would not be good to change it without deeper knowledge how to monitor effects of this change. Knowing few ways to monitor all things that this change may impact can be a good thing. # free -m total used free shared buffers cached Mem: 24149 20832 3316 0 1193 14639 -/+ buffers/cache: 4999 19149 Swap: 510 61 449 # top top - 14:50:18 up 15 days, 20:09, 1 user, load average: 0.62, 0.94, 1.39 Tasks: 192 total, 4 running, 186 sleeping, 0 stopped, 2 zombie Cpu(s): 6.6%us, 1.3%sy, 0.0%ni, 91.7%id, 0.4%wa, 0.0%hi, 0.1%si, 0.0%st Mem: 24728848k total, 21236220k used, 3492628k free, 1222388k buffers Swap: 523260k total, 62624k used, 460636k free, 15000780k cached (mysql restarted yesterday) Load average 0,5-3,0 (8), during cpanel backups it can be 9,0 (8) When there are more emails in queue, SWAP goes up /etc/my.cnf : http://pastebin.com/A0pqpB2q mysqltuner and mysql primer says i need to increase query cache size, tmp (+heap) table over 3G and that table cache need to be larger than 8G Largest DB table is around 6GB i think. Is there anythink i can do to tweak it better?

Posted by RRWH, 02-27-2012, 09:21 PM
how come the output of free -m has changed from having 1Gig swap to 500M swap and the RAM has changed from 8Gig to 24Gig ? Is this the same server? I have found most of the time that tuning_primer.sh to be a very good starting point for tuning MySql config. Yes, It does take ime to get a decent baseline - typically I find it takes 2-3 weeks, then a regular check to see if things have changed. What and how are you monitoring your server resources and usage?

Posted by hhw, 02-28-2012, 06:23 AM
RAM is cheap nowadays. Buying more of it will likely cost less than the time you spend investigating why you're out of it, if your provider costs it based on the hardware cost.

Posted by Crashus, 02-28-2012, 10:33 AM
it mysqltuner suggesting you to tweak table chache more than 8Gb then you most-likely have very huge or unoptimized DB Try to lower my.cnf memory settings and prevent mysql memory consumption

Posted by RomanVelcom, 02-28-2012, 03:25 PM
unreal, when this starts ? Its unussualy swap ussage ? or u had same ? IF its new, its can be http attack also which ask many small pages which use SQL also.... so, check your httpd logs, maybe you can see one IP which ask 100 pages per second I can try check this if u PM me.

Posted by slrslr, 02-28-2012, 08:11 PM
RRWH, its a new server, but issues are similar.

Posted by RomanVelcom, 02-28-2012, 11:53 PM
slrslr, need information, how many connection to your server this time, how many visitors on the site? If you down web server is load back to normal ?

Posted by slrslr, 03-05-2012, 05:26 PM
These are average, nothing special. At whole server it can be max. 150 users online max. 20 concurent i guess. nothing special

Posted by Vinayak_Sharma, 03-05-2012, 05:45 PM
Is it hosting PHP sites, what PHP is in use DSO/suPHP/FastCGI ?

Posted by SiteServing, 03-08-2012, 06:45 PM
Increase the swap space. You may add a file and use it as swap if you do not have space to extend the current sap partition.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Domain lookup failure (Views: 598)

Language: