Is my Swap Usage Too High?

WARNING: Newbie armed with a VPS

BACKDROP TO THE SITUATION:

Linode 1GB RAM using 256mb for Swap

40 GB storage

8 CPU (1x priority)

2 TB Transfer

Total: 49152 MB

Used: 24320 MB

Free: 24832 MB

Overall data storage as of this writing: 7% above used amount

Running 5 websites on Apache2

All sites run on Drupal 7 CMS w/ individual databases

2 Sites running Drupal Commerce, (1 as sandbox and 1 as a future production site)

Basic Setup:

PHP5/MySql/Apache2

NO incoming Email

Site can and does mail out scheduled database backups

All database tar.gz files are under 0.5 mb each

Site is updated/upgraded weekly

All Drupal modules and core are current

The server was setup step-for-step using the Linode Library setup instructions with the following exception made to MySql config file:

MaxPacketSize = 100M instead of 1M (This was done just recently after encountering a MySql

error that after researching and gaining further understanding to the Drupal Commerce database query sizes, was necessary).

THE ISSUES LEADING TO THIS POST:

I began receiving alerts that my I/O rate was exceeding the thresholds defined in the settings of my Linode Dashboard. This did not initially alarm me because I was doing considerable development on the live sites in maintenance mode but I was doing a large amount of writing to the database and theme developing as well.

However, when I began getting heavily into the most recent site, (a Drupal Commerce site that utilizes many modules), I then started seeing the sight just bog down.

Not being a whiz at understanding the charts from Linode, I believe most looks well within range EXCEPT I am accessing Swap memory almost continuously when there is any activity on the server. I say "any" at this point because right now I don't think the server is getting 1000 visitors per month let alone at any given simultaneous point in recent time.

WHAT I BELIEVE TO BE A POTENTIAL PROBLEM WITH MY LINODE CONFIGURATION:

Excessive consuming of Swap Memory. As noted above, considering there is virtually no traffic coming to the sites and I am simply developing at this stage, I don't think the activity I am performing warrants this amount of Swap activity.

This morning I monitored the site with TOP and recorded results during idle time and during times when I was in site admin mode actively writing to the database and loading pages. However, as noted in the opening WARNING statement, I am highly UN-qualified to interpret the charts Linode provides. So my first and foremost question is:

Is there a problem? (SEE SCREENSHOTS BELOW of Linode charts and the TOP program results)- Issue resolved, Image references removed. Thanks for all replies and assistance.

6 Replies

Answered!! Added research directed me to investigate the CMS optimization process for my particular CMS, (Drupal in my case). Issue appears at this point to be primarily related incorrectly cache settings).

Typically the rule of thumb is if you are swapping, you do not have enough memory.

Get more memory or make other adjustments to lower the memory usage if you continue to swap.

Your MaxClients in apache is probably too high. Search this forum, there are a zillion posts about it

@glg:

Your MaxClients in apache is probably too high. Search this forum, there are a zillion posts about it

Right now MaxClient = 30

@arjones85:

Typically the rule of thumb is if you are swapping, you do not have enough memory.

Get more memory or make other adjustments to lower the memory usage if you continue to swap.

I agree and after some investigating it became obvious that MySql and Apache are the RAM consuming culprits:

Total used free shared buffers cached

mem 987 964 23 0 28 128

buffer/cache 807 179

swap 255 116 139

* [email protected]:~$ ps auxf | sort -nr -k 4 | head -5

mysql 24087 0.0 9.8 1290472 99188 ? Ssl Nov09 1:24 /usr/sbin/mysqld

www-data 25765 0.0 8.1 392684 82656 ? S 07:56 0:12 \_ /usr/sbin/apache2 -k start

www-data 25803 0.0 5.8 368908 58780 ? S 08:19 0:08 \_ /usr/sbin/apache2 -k start

www-data 25794 0.0 5.6 367356 57180 ? S 08:12 0:10 \_ /usr/sbin/apache2 -k start

www-data 25804 0.0 5.5 367444 56000 ? S 08:19 0:10 \_ /usr/sbin/apache2 -k start</list> 

I am running independent Drupal instances and a couple sites have alot of modules enabled w/ many queries using Views module.

I believe the main issue there is the .htaccess files Drupal requires along with many from contributing modules. So in the end, I have many, many .htaccess files that Apache has to find and aggregate. Unless of course someone sees something I don't in the above mem usage.

I am now wondering if there is a global way in the vhost file to add a to include a script or something that will find and store all .htaccess files so they don't have to be searched for?

Thanks for input.

You might want to consider installing nginx as a reverse proxy - it helped reduce the memory usage of Apache on my Linode and made my sites quite a bit faster. I wrote about it here:

~~[https://forum.linode.com/viewtopic.php?f=12&t=10568#p61207" target="_blank">](https://forum.linode.com/viewtopic.php?f=12&t=10568#p61207](

It's pretty easy to do.

@nicholasmark:

You might want to consider installing nginx as a reverse proxy - it helped reduce the memory usage of Apache on my Linode and made my sites quite a bit faster. I wrote about it here:

~~[https://forum.linode.com/viewtopic.php?f=12&t=10568#p61207" target="_blank">](https://forum.linode.com/viewtopic.php?f=12&t=10568#p61207](

It's pretty easy to do.

Thanks, I will definitely investigate this. However, I think I am going open another thread that is more focused on apache memory usage. I am interested in posting some tests that I've run on Apache and MySql RAM usage and see how it may compare to other community members just to make sure I haven't missed something large in the optimization process.

Thanks,

Again

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct