VPS Drupal tuning Apache2, varnish, memcached, ACP

I keep getting OOM errors even tho I am running a Linode 1G. Drupal 7 with about 300-500 unique page views a day and going up. Any and all help appreciated. site serviidb.com. PM me and I will give you address of php info.

Here the info

xxxx@serviidb:~# ab -n 200 -c 4 http://www.serviidb.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.serviidb.com (be patient)
Completed 100 requests
Completed 200 requests
Finished 200 requests

Server Software:        Apache/2.2.14
Server Hostname:        www.serviidb.com
Server Port:            80

Document Path:          /
Document Length:        202809 bytes

Concurrency Level:      4
Time taken for tests:   1.141 seconds
Complete requests:      200
Failed requests:        0
Write errors:           0
Total transferred:      40668990 bytes
HTML transferred:       40561800 bytes
Requests per second:    175.23 [#/sec] (mean)
Time per request:       22.827 [ms] (mean)
Time per request:       5.707 [ms] (mean, across all concurrent requests)
Transfer rate:          34797.25 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     1   23 144.7      2    1034
Waiting:        0   21 144.7      0    1031
Total:          1   23 144.7      2    1034

Percentage of the requests served within a certain time (ms)
  50%      2
  66%      2
  75%      3
  80%      3
  90%      3
  95%      4
  98%   1033
  99%   1033
 100%   1034 (longest request)

part of my apache2.conf

#

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 2

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 6

##
## Server-Pool Size Regulation (MPM specific)
## 

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
 <ifmodule mpm_prefork_module="">StartServers          1
    MinSpareServers       3
    MaxSpareServers      6
    ServerLimit          24
    MaxClients          24
    MaxRequestsPerChild 3000</ifmodule> 

# Include generic snippets of statements
Include /etc/apache2/conf.d/

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/

Include /etc/phpmyadmin/apache.conf

parts of MYSQL my.com

[mysqld]

max_allowed_packet = 16M
key_buffer = 16k
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 2M
myisam_sort_buffer_size = 2M
query_cache_size = 14M

#
# * Basic Settings
#

#
# * IMPORTANT
#   If you make changes to these settings and your system uses apparmor, you may
#   also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
#

user        = mysql
socket        = /var/run/mysqld/mysqld.sock
port        = 3306
basedir        = /usr
datadir        = /var/lib/mysql
tmpdir        = /tmp
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address        = 127.0.0.1
#
# * Fine Tuning
#
#key_buffer        = 16M
max_allowed_packet    = 1M
thread_stack        = 64K
thread_cache_size       = 4
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit    = 1M
#query_cache_size        = 16M
#

9 Replies

I had forgot to restart after changing keepaliverequests to 2

xxxxx@serviidb:~# ab -n 500 -c 4 http://www.serviidb.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.serviidb.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests

Server Software:        Apache/2.2.14
Server Hostname:        www.serviidb.com
Server Port:            80

Document Path:          /
Document Length:        202809 bytes

Concurrency Level:      4
Time taken for tests:   0.315 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      101674000 bytes
HTML transferred:       101404500 bytes
Requests per second:    1587.34 [#/sec] (mean)
Time per request:       2.520 [ms] (mean)
Time per request:       0.630 [ms] (mean, across all concurrent requests)
Transfer rate:          315217.58 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:     1    2   0.9      2       8
Waiting:        0    1   0.6      0       4
Total:          1    2   0.9      2       8
WARNING: The median and mean for the waiting time are not within a normal deviation
        These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
  50%      2
  66%      3
  75%      3
  80%      3
  90%      3
  95%      4
  98%      5
  99%      6
 100%      8 (longest request)

You didn't share any info on actual memory usage, but you've got Apache configured to use up to 24 processes. If we assume the memory usage per Apache process is 80MB (which I think would be a high estimate), 24 * 80 = 1,920, which is well beyond how much memory you have.

Your maxclients should be something like 10, which leaves some room for MySQL, other things, caching, etc.

EDIT: You're also not using ab right for load testing if you're setting the concurrency way lower than your maxclients.

Hi,

i was having the same problem in my drupal 7 site too. I have a linode 512mb.

Follow some support instructions, like the default configurations..

Disabled KeepAlive and MaxClients = 7 and stopped having problems and the site is must faster.. Although i would like to tune it more.

I'm not a sysadmin.. should i decrease MaxClients even more? One of the site's features is to upload large image files (4/5 mb) and using imagemagik to resize them, which consumes a lot of memory..

Should i install apc or memcached?

Can someone give me some advices to keep overall memory balanced?

One important thing to note is that while a user is uploading a large file, they're monopolizing one of those Apache processes. So if 7 people are uploading files at the same time, nobody will be able to access your site.

Your case of file uploads is different from the standard case, you need to keep your maxclients high enough for this scenario. You may need to do one of these two things:

1) Get more RAM to support higher maxclients

2) Switch from prefork to worker so that you can handle larger numbers of simultaneous clients in a more memory-friendly manner

Hi,

The uploads are only made by me and another person (content manager) the main purpose of the site is simply to display content… It's not for public user registrations at the moment.

Thank you for the advice, i'll have to upgrade the account in the future if i need those requirements.

You'll probably be fine then. You can test your site with ab (apache benchmark) with varying levels of concurrency to see how it handles the load with different maxclients setting. It may also be a decent way to see how much RAM things need.

I changed from MBM-Prefork to MBM-worker mod-fcgid and my memory usage went from the high 700's to a pretty steady 400 meg. Site seems to be more responsive also.

I don't always browse the Linode forums, but when I do I spam.

More SPAM in the LINODE Forum.

Wonder what people think of LINODE after seeing all their stinky spam?

Really cool and techie - or just plain lazy and stupid?

Maybe we should have a POLL (which is almost as bad as spam).

Perhaps LINODE should read up on FORUM MODERATORS in the PHPBB Forum manual.

If only they had members across the globe, hence across all time zones, that could moderate such dribble.

Nah, that would make way too much sense.

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