My web is still slow even with Boost + Authcache + APC + Memcache

Events happening in the community are now at Drupal community events on www.drupal.org.
reynaldio's picture

Hi all,

i recently installed boost, authcache, apc and memcache. Is this too much? However i dont get the performance boost i want. My web even getting slower than ever. could there be conflict between this modules? With boost and authcache alone, page execution between 2800-3500 ms. Later i installed apc and page execution goes beyod 30000-50000 ms. And then i installed memcache and page execution goes back to 3000.
What have i done wrong.

php.ini

max_execution_time = 60
memory_limit = 320M

extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
extension=pdo_mysql.so
extension="ixed.5.2.lin"
;zend_extension="/usr/local/Zend/lib/Optimizer-3.3.9/php-5.2.x/ZendOptimizer.so"
extension=uploadprogress.so
extension=apc.so
extension=memcache.so

apc.enabled=1
apc.shm_segments=1
apc.shm_size=256
apc.apc.stat = 0
apc.ttl=0
apc.include_once_override = 1

memcache.hash_strategy="consistent"

settings.php

$conf['memcache_servers'] = array('localhost:11211' => 'default');
$conf['cache_inc'] = './sites/all/modules/authcache/authcache.inc';

any help and idea will be highly appreciated

Regards,
Reynaldi

Comments

When doing performance tuning

dalin's picture

When doing performance tuning you can't just install a bunch of things that might help and hope for the best. You need to first figure out what your bottlenecks are, benchmark, make one performance improvement that fixes that bottleneck, benchmark to confirm that you actually made an improvement, repeat. It's so easy to make a small error in configuration that will actually make problems worse. If you don't know what the problem is, and you don't benchmark, then you can't fix the problem, or even know if you've made things better or worse.

--


Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his

Benchmark tools

reynaldio's picture

Hi,

Thanks for you input
what tools do you use to benchmark your site performance?

Regards,
Reynaldi

Apache Bench (ab) is probably

dalin's picture

Apache Bench (ab) is probably the easiest tool that you have available.

In reviewing your config above I see that you have your PHP memory limit at 320MB. If you really do need it to be that high then you have a serious problem that performance modules aren't going to be able to fix. A standard Drupal page usually uses somewhere in the range of 24-48MB. Some admin pages may require a bit more. If you need 300MB to render a page you likely have a misbehaving module. Likely a custom module, a custom theme, or a lesser-used module.

--


Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his

Hi, i put 320M memory_limit

reynaldio's picture

Hi,

i put 320M memory_limit is only for precaution sake. It usually only takes 80-90mb.
does setting memory_limit high have negative impact?

Performance is very good when using boost only. It only takes 5 secs to open the homepage. But boost is only for anonymous guest only. I need improvements for registered users. That is why i installed those other modules. Do those modules work well together?

Regards,
Reynaldi

and 1 more thing, i get B on

reynaldio's picture

and 1 more thing, i get B on YSlow. But still that does not reflect page loading performance on my web :(

Memory?

yohgaki's picture

Generally speaking, APC will never slow down execution. Do you have enough memory? I guess you don't.

Hi, My server is running on

reynaldio's picture

Hi,

My server is running on Hostgator VPS account with 756MB of memory. I've checked and i still have 512 Mb of free memory.

Regards,
Reynaldi

How it is possible?

jcisio's picture

768 MB total, 80 MB for each PHP process, a few dozens of MB for OS, and you have more than 500 MB free?

Did you check if your APC setting is correct (in phpinfo, e.g. APC memory usage), 256 MB is too much, too.

YSlow tells you only the frontend, it can't barely distinguish between 200 ms and 2000 ms execution time on the server side. As per dalin's suggest, do more benchmark. If a script takes 3000 ms to execute, how much for PHP and how much for MySQL? If PHP, tune your APC. If MySQL, look at your slow query log. And sometimes, improve can be only made with hardware upgrade. How many pageviews per day do you have? How many modules do you install? It's strange that a normal Drupal script uses 80 MB if it is not a large image manipulation.

Hi, That's what my WHM report

reynaldio's picture

Hi,

That's what my WHM report says. I do have a lot image manipulation on my web.

         total       used       free     shared    buffers     cached

Mem: 786432 273792 512640 0 0 0
-/+ buffers/cache: 273792 512640
Swap: 0 0 0
Total: 786432 273792 512640

I have about 500-1000 page views per day and about 50 modules enabled.
I'll try to do more benchmarking and post back with the results.
btw, my website is www.warawiri.com

Regards,
Reynaldi

Database

stompersly's picture

If your site is slow for authenticated users I would suspect you need to look at the database. Try tuning the MySQL as shown here: http://web3us.com/drupal6/how-create-web-site-handbook/how-setup-mysql/t...

Is your PHP running as CGI?

Alexander Langer's picture

Is your PHP running as CGI? In that case the APC cache may not be shared by different CGI processes and you won't see any speed improvements. Checkout this discussion which also covers workarounds: http://stackoverflow.com/questions/598444/how-to-share-apc-cache-between...

On the otehr hand it may be easier to switch to mod_php5 instead of running PHP as CGI.

yes!

playfulwolf's picture

Agree - it can be the cause of problem.

drupal+me: jeweler portfolio

disable memcache!

playfulwolf's picture

Hi,

I had experience with similar setup on similar vps, and... almost the same problems. Try to:
1) Remove memcache from server and all related Drupal modules. And yes, I am sure, because it sometimes freezes when used with authcache and it is useless if you are using APC and Boost in your configuration.
2) Increase APC memory, to the amount of APC + memcache, maybe a bit less, there is apc monitoring script, so it will help a lot. WOW! In your case you already allocated 256M - it is an overkil! Make 128M and give more/less after initial testing
3) install cacherouter module, and tune it to use 'apc' as storage (you allocated extra memory, right?)
4) install boost, enable html, maybe ajax and json caching and NOT css, js as you probably are using css, js aggregation modules - they create real mess if enabled both... I also do not recommend to enable Boost crawler...
5) Disable Drupal native core caching as now authcache will take care of that
6) In authcache settings enable cacheing ONLY for registered users (Boost will take care of rest)
7) Play with views caching and block caching settings, avoid any on-the-fly calculations, maybe with js, css agregation settings - but not with the most aggresive settings.

exact example: http://hotweb.lt

NOTE: I am not a great specialist of Apache settings - but you need your config be tuned for APC to function properly.
NOTE2: I take for granted, that you already set up VPS, MySQL, PHP and other non-Drupal stuff in the best possible way.
NOTE3: YSlow may help you with the front end performance, which is no less important
NOTE4: I suspect you are using settings for your VPS, as if it is quad-core machine with 8gigs of RAM... Probably the VPS you are using is in "low-memory server" category , so google for optimal settings.

Khalid from 2bits wrote some good articles, google them.

drupal+me: jeweler portfolio

css/js caching in boost

mikeytown2's picture

I created the caching of .js and .css files just for use with the aggregation option. Otherwise you will get missing css & js files unless you set this boost setting that kills the boost cache on every flush cache request, since drupal_flush_all_caches clears out all aggregated css and js files. Whats left in the boost cache are html referencing css and js files that no longer exist.

Ignore cache flushing: Disabled
By default its set to Only Ignore Clear Entire Cache Commands (Recommended if caching css/js files)

Performance tuning

Mixologic's picture

With performance tuning, I've found that there is almost no silver bullets. That being said you definitely need to know exactly what your setup is doing before tweaking anything.

If you want to get serious about performance tuning, isolation of bottlenecks and benchmarking, then the best tool available (imho) is xhprof.

This is the tool facebook built to analyze and monitor their systems, and lucky for us they open sourced it last march.

Its a hierarchical code profiler that gives you CPU and Wall clock times for how long it takes to run through your code, and comes with a web based tool to parse and digest all the output from the profiler, making it really, really, obvious where all the holdup is. (be it mysql, or particular modules etc).

For help installing it and more details I highly recommend this article:
http://techportal.ibuildings.com/2009/12/01/profiling-with-xhprof/

Btw, there is a misleading comment in the comments of that ibuildings article for y'all wanting to install xhprof on your mac: comment 8 says just use macports to install it.. you have to be careful if you are running snow leopard, and make sure that it doesnt try to compile it as 64 bit only .so, when all your php could be compiled 32 bit (like if you are using mamp).

Oh one more thing, when you downloaded and installed APC, there should have been and 'apc.php' file in the directory with everything else. Throw that somewhere accessable on your server (like www.warawiri.com/apc.php), and give us a screen shot of your output. That'll also display all the other apc settings, which may or may not need adjusting. Very useful tool for troubleshooting the apc cache.. (also, edit the apc.php file and change the password in the file.. that will allow you to 'login', which will allow you to do stuff like flush the cache etc)

Hi, sorry for slow

reynaldio's picture

Hi,

sorry for slow response.
@PlayfulWolf so, memcache is not compatible with authcache?

i checked with webwait.com, and now my web loads in 3 secs for guest and 10 secs for auth users which is a lot of improvements (50 secs before).

but my page execution time needs improvements (devel: 2607.18 ms)

I've put apc.php in my drupal directory. you can view my apc in http://bandung.warawiri.com/apc.php
i see that apc uptime is always 0, which means that it is not working. i have no idea what could have been wrong in my config.
should i enable fast cgi?

this is my apc config in php.ini

apc.enabled=1
apc.shm_segments=1
apc.optimization=0
apc.shm_size=128
apc.stat=0
apc.ttl=0
apc.user_ttl=0
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1
apc.rfc1867=0

Thanks
Reynaldi

You're site isn't using APC

jaydubb181's picture

reynaldio , I looked at your APC cache graph, and you're site isn't using APC much at all. You've only got 1 entry in the APC cache and it's your apc.php file. So either memcache or authcache is handling your caching here.

That's what i'm trying to

reynaldio's picture

That's what i'm trying to identify. i still havent figure out what i've done wrong. maybe you can point out something that could possibly the problem?

Thanks
Reynaldi

APC definitely not working.

Mixologic's picture

Thanks for putting your apc.php up.. This helps a lot. apc isnt being used at all.

What it tells me is that your httpd daemon is not staying alive between requests. This is probably happening due to the way you have apache configured, if its running in cgi mode, or as suPHP, its basically firing up a new process, parsing&compiling the php, delivering the content and then terminating.

two things you can do to dig deeper:
a. create a phpinfo.php file in the document root with the following in it:

<?php
phpinfo
();
?>

That will spew out everything about how php is running, including a lot of apache config information. if you see suPHP in there, thats probably the issue.. you'll need to switch it to run mod_php5 or mod_fastcgi. It depends on how your server is configured of course, and this can lead to some permissions issues when switching from suPHP to mod_php or mod_fastcgi, as apache will probably run as "nobody" instead of whatever user it used to run as.

It might be that apache is configured with mod_php5 or fast_cgi, yet configured to tear down immediately as well.. if thats the case you'll probably have to post your /usr/local/apache/conf/httpd.conf file for more clues.

APC

Mixologic's picture

One more note about apc, even with memcache or authcache on, apc should still do opcode caching.

There are two types of caching going on, the first is opcode caching. When the php file is compiled into opcodes, APC, xcache, and eAccelerator all take those compiled opcodes and save em in memory. The next time apache goes to compile the php files, it first checks the cache to see if they are already done (but the process still has to be alive from request to request).

The second type of caching is object (or key/value store) caching. Object caches let you store anything.. database query results, variables, entire html pages - whatever you want. APC,xcache, and eaccelerator are all object caches in addition to being opcode caches. Memcached is also an object cache, but not an opcode cache.

The main difference between memcached and apc/xcache/eaccelerator is that memcached is designed to be distributed, so that if you have 5 webservers all accessing the same data, and the same data should be cached, they can all share the same caching resource. If you only have one server however, you might as well simply use the object caching capabilities of your opcode accelerator, as memcached is just one more thing to configure and tune.

Read this link for more info

Hi, sorry for my slow

reynaldio's picture

Hi,

sorry for my slow response.

@Mixologic Thank you for your detail explanation. i do not see suPHP in phpinfo(). I've been trying to configure my hostgator account to use mod_fastcgi but to no avail. I've asked hostgator but they said they cannot help me with this and suggested me to post my question to drupal forum :(

Do you have any articles or links i can follow? I have full access to apache.conf and php.ini.
Please also note that i use domain.module, and hostgator said that this is the issue why i cant get fastcgi to work.

I put "AddHandler fcgid-script .php" in my .htaccess as hostgator suggested but still not working. Instead it pop up download page to download index.php.

Thanks in advance
Reynaldi

Below is my httpd.conf, in

reynaldio's picture

Below is my httpd.conf, in case you need it. i do see suPHP in my conf but have no idea how to change it without breaking apache :(

Thanks

httpd.conf

Mixologic's picture

Cant see your httpd.conf.. sometimes attachments dont work.. try again?

Also, if you want to pm/dm me a link to your phpinfo, that'd be useful too.

Hi, sorry, this is my

reynaldio's picture

Hi,

sorry, this is my httpd.conf

Include "/usr/local/apache/conf/includes/pre_main_global.conf"
Include "/usr/local/apache/conf/includes/pre_main_2.conf"

LoadModule frontpage_module modules/mod_frontpage.so
LoadModule bwlimited_module modules/mod_bwlimited.so
LoadModule auth_passthrough_module modules/mod_auth_passthrough.so

Include "/usr/local/apache/conf/php.conf"
Include "/usr/local/apache/conf/modsec2.conf"
Include "/usr/local/apache/conf/includes/errordocument.conf"

ErrorLog "logs/error_log"
DefaultType text/plain
ScriptAliasMatch ^/?controlpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?cpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?kpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?securecontrolpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi
ScriptAliasMatch ^/?securecpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi
ScriptAliasMatch ^/?securewhm/?$ /usr/local/cpanel/cgi-sys/swhmredirect.cgi
ScriptAliasMatch ^/?webmail/?$ /usr/local/cpanel/cgi-sys/wredirect.cgi
ScriptAliasMatch ^/?whm/?$ /usr/local/cpanel/cgi-sys/whmredirect.cgi

Alias /akopia /usr/local/cpanel/3rdparty/interchange/share/akopia/
Alias /bandwidth /usr/local/bandmin/htdocs/
Alias /img-sys /usr/local/cpanel/img-sys/
Alias /interchange /usr/local/cpanel/3rdparty/interchange/share/interchange/
Alias /interchange-5 /usr/local/cpanel/3rdparty/interchange/share/interchange-5/
Alias /java-sys /usr/local/cpanel/java-sys/
Alias /mailman/archives /usr/local/cpanel/3rdparty/mailman/archives/public/
Alias /pipermail /usr/local/cpanel/3rdparty/mailman/archives/public/
Alias /sys_cpanel /usr/local/cpanel/sys_cpanel/

ScriptAlias /cgi-sys /usr/local/cpanel/cgi-sys/
ScriptAlias /mailman /usr/local/cpanel/3rdparty/mailman/cgi-bin/
ScriptAlias /scgi-bin /usr/local/cpanel/cgi-sys/scgiwrap

Options All
AllowOverride All

Options Includes Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

Order allow,deny
Deny from all
Satisfy All

Order allow,deny
Deny from all

Satisfy All

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common

CustomLog logs/access_log common

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"

AllowOverride None
Options None
Order allow,deny
Allow from all

TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

PidFile logs/httpd.pid
LockFile logs/accept.lock
# Defined in /var/cpanel/cpanel.config: apache_port
Listen 0.0.0.0:80
Timeout 300
User nobody
Group nobody
ExtendedStatus On
ServerAdmin email(at)warawiri
ServerName warawiri(dot)com
LogLevel warn

# These can be set in WHM under 'Apache Global Configuration'

ServerSignature On

RewriteEngine on
RewriteMap LeechProtect prg:/usr/local/cpanel/bin/leechprotect
RewriteLock /usr/local/apache/logs/rewrite_lock

UserDir public_html

# DirectoryIndex is set via the WHM -> Service Configuration -> Apache Setup -> DirectoryIndex Priority
DirectoryIndex index.html.var index.htm index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml default.htm default.html home.htm index.php5 Default.html Default.htm home.html

# SSLCipherSuite can be set in WHM under 'Apache Global Configuration'

SSLPassPhraseDialog builtin
SSLSessionCache dbm:/usr/local/apache/logs/ssl_scache
SSLSessionCacheTimeout 300
SSLMutex file:/usr/local/apache/logs/ssl_mutex
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin

# Defined in /var/cpanel/cpanel.config: apache_ssl_port
Listen 0.0.0.0:443
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl

AddHandler cgi-script .cgi .pl .plx .ppl .perl
AddHandler server-parsed .shtml
AddType text/html .shtml
AddType application/x-tar .tgz
AddType text/vnd.wap.wml .wml
AddType image/vnd.wap.wbmp .wbmp
AddType text/vnd.wap.wmlscript .wmls
AddType application/vnd.wap.wmlc .wmlc
AddType application/vnd.wap.wmlscriptc .wmlsc

SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1

# SUEXEC is supported

Include "/usr/local/apache/conf/includes/pre_virtualhost_global.conf"
Include "/usr/local/apache/conf/includes/pre_virtualhost_2.conf"

# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.
NameVirtualHost 174.121.25.14:80
NameVirtualHost *
# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.

ServerName warawiri(dot)com
DocumentRoot /usr/local/apache/htdocs
ServerAdmin email(at)warawiri

suPHP_UserGroup nobody nobody

# Default vhost for unbound IPs

ServerName warawiri(dot)com
DocumentRoot /usr/local/apache/htdocs
ServerAdmin email(at)warawiri

suPHP_UserGroup nobody nobody

# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.

ServerName warawiri(dot)com
ServerAlias www(dot)warawiri(dot)com
DocumentRoot /home/warawiri_admin/public_html
ServerAdmin webadminwarawiri.com
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/warawiri(dot)com combined
CustomLog /usr/local/apache/domlogs/warawiri(dot)com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User warawiri_admin # Needed for Cpanel::ApacheConf

suPHP_UserGroup warawiri_admin warawiri_admin

SuexecUserGroup warawiri_admin warawiri_admin

ScriptAlias /cgi-bin/ /home/warawiri_admin/public_html/cgi-bin/

# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/warawiri_admin/warawiri(dot)com/*.conf"

# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.

ServerName bandung(dot)warawiri(dot)com
ServerAlias www.bandung(dot)warawiri(dot)com
DocumentRoot /home/warawiri_admin/public_html
ServerAdmin webadminbandung(dot)warawiri(dot)com
UseCanonicalName On
CustomLog /usr/local/apache/domlogs/bandung(dot)warawiri(dot)com combined
CustomLog /usr/local/apache/domlogs/bandung(dot)warawiri(dot)com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User warawiri_admin # Needed for Cpanel::ApacheConf

suPHP_UserGroup warawiri_admin warawiri_admin

SuexecUserGroup warawiri_admin warawiri_admin

ScriptAlias /cgi-bin/ /home/warawiri_admin/public_html/cgi-bin/

# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/warawiri_admin/bandung(dot)warawiri(dot)com/*.conf"

# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.

ServerName cdn1(dot)warawiri(dot)com
ServerAlias www.cdn1(dot)warawiri(dot)com
DocumentRoot /home/warawiri_admin/public_html
ServerAdmin webadmincdn1(dot)warawiri(dot)com
UseCanonicalName On
CustomLog /usr/local/apache/domlogs/cdn1(dot)warawiri(dot)com combined
CustomLog /usr/local/apache/domlogs/cdn1(dot)warawiri(dot)com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User warawiri_admin # Needed for Cpanel::ApacheConf

suPHP_UserGroup warawiri_admin warawiri_admin

SuexecUserGroup warawiri_admin warawiri_admin

ScriptAlias /cgi-bin/ /home/warawiri_admin/public_html/cgi-bin/

# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/warawiri_admin/cdn1(dot)warawiri(dot)com/*.conf"

# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.

ServerName cdn2(dot)warawiri(dot)com
ServerAlias www.cdn2(dot)warawiri(dot)com
DocumentRoot /home/warawiri_admin/public_html
ServerAdmin webadmincdn2(dot)warawiri(dot)com
UseCanonicalName On
CustomLog /usr/local/apache/domlogs/cdn2(dot)warawiri(dot)com combined
CustomLog /usr/local/apache/domlogs/cdn2(dot)warawiri(dot)com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User warawiri_admin # Needed for Cpanel::ApacheConf

suPHP_UserGroup warawiri_admin warawiri_admin

SuexecUserGroup warawiri_admin warawiri_admin

ScriptAlias /cgi-bin/ /home/warawiri_admin/public_html/cgi-bin/

# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/warawiri_admin/cdn2(dot)warawiri(dot)com/*.conf"

# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.

ServerName cdn3(dot)warawiri(dot)com
ServerAlias www.cdn3(dot)warawiri(dot)com
DocumentRoot /home/warawiri_admin/public_html
ServerAdmin webadmincdn3(dot)warawiri(dot)com
UseCanonicalName On
CustomLog /usr/local/apache/domlogs/cdn3(dot)warawiri(dot)com combined
CustomLog /usr/local/apache/domlogs/cdn3(dot)warawiri(dot)com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User warawiri_admin # Needed for Cpanel::ApacheConf

suPHP_UserGroup warawiri_admin warawiri_admin

SuexecUserGroup warawiri_admin warawiri_admin

ScriptAlias /cgi-bin/ /home/warawiri_admin/public_html/cgi-bin/

# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/warawiri_admin/cdn3(dot)warawiri(dot)com/*.conf"

# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.

ServerName facebook(dot)warawiri(dot)com
ServerAlias www.facebook(dot)warawiri(dot)com
DocumentRoot /home/warawiri_admin/public_html/facebook
ServerAdmin webadminfacebook(dot)warawiri(dot)com
UseCanonicalName On
CustomLog /usr/local/apache/domlogs/facebook(dot)warawiri(dot)com combined
CustomLog /usr/local/apache/domlogs/facebook(dot)warawiri(dot)com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User warawiri_admin # Needed for Cpanel::ApacheConf

suPHP_UserGroup warawiri_admin warawiri_admin

SuexecUserGroup warawiri_admin warawiri_admin

ScriptAlias /cgi-bin/ /home/warawiri_admin/public_html/facebook/cgi-bin/

# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/warawiri_admin/facebook(dot)warawiri(dot)com/*.conf"

# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.

Definitely running suPHP

Mixologic's picture

You are definitely running suPHP. - That can be changed to run as mod_php5, but there are a couple of caveats and things to consider before you do that.

A. Enabling mod_php5, and APC as well, will reduce cpu load on your server, however before making any changes at all, we should be sure that that cpu is definitely the bottleneck.

So: ssh into your server as root

First, check realtime stats:

'top' will show you what running right now, and show you the current calculated load average

root@host [~]# top

top - 12:21:58 up 12 days, 20:24,  1 user,  load average: 0.82, 0.88, 0.98
Tasks: 185 total,   2 running, 183 sleeping,   0 stopped,   0 zombie
Cpu(s): 10.4%us,  1.0%sy,  0.6%ni, 83.6%id,  4.2%wa,  0.0%hi,  0.2%si,  0.0%st
Mem:   4151868k total,  3661140k used,   490728k free,   638104k buffers
Swap:  5245180k total,       88k used,  5245092k free,  2328712k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                  
30238 nobody    15   0  240m 110m  17m R 27.6  2.7   0:01.12 httpd                                                                                     
29984 nobody    15   0  240m 111m  18m S  5.9  2.7   0:03.29 httpd                     

Another nifty trick is to press '1' while top is running which will split out the cpu load per cpu.. you may only have one, but this will help enlighten you as to what your load average numbers mean.

top - 12:23:26 up 12 days, 20:26,  1 user,  load average: 1.27, 1.01, 1.02
Tasks: 194 total,   2 running, 191 sleeping,   0 stopped,   1 zombie
Cpu0  :  3.0%us,  0.7%sy,  0.0%ni, 91.9%id,  4.4%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu1  :  7.4%us,  6.1%sy,  0.0%ni, 86.5%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu2  :  5.0%us,  1.3%sy,  0.0%ni, 88.6%id,  5.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu3  : 21.1%us,  2.3%sy,  0.0%ni, 76.3%id,  0.0%wa,  0.0%hi,  0.3%si,  0.0%st
Mem:   4151868k total,  3678048k used,   473820k free,   638888k buffers
Swap:  5245180k total,       88k used,  5245092k free,  2354800k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                  
17330 mysql     15   0  208m 102m 4148 S 13.0  2.5 896:43.57 mysqld                                                                                    
30343 nobody    15   0  240m 108m  15m S  7.3  2.7   0:00.22 httpd 

Key here is the load average, which are 1, 5, and 15 minute averages. Im showing a load average of 1.02 for the last 15 min in the example above, which given that I have four processesors, means that I shouldnt even consider my box bogged down until I see it up above 4.00

Next, have a look at your historical stats:
sar, or 'system activity reporter' looks at your historical logs. lets start with sar -q.

root@host [~]# sar -q
...
... truncated for brevity sake ...
11:00:01 AM   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15
11:10:01 AM         4       246      0.60      0.58      0.58
11:20:01 AM         2       257      0.45      0.58      0.58
11:30:01 AM         8       247      0.44      0.43      0.49
11:40:01 AM         3       274      0.86      0.64      0.52
11:50:01 AM         5       248      0.45      0.89      0.71
Average:            3       241      0.99      1.04      1.04

Hopefully sar exists on a vps host - it definitely does on hostgator's dedicated boxes.
What this shows is the historical cpu load average for the "previous 15 minutes", in 10 minute increments.

The load is entirely dependent upon the number of cpus/cores you have. I have 4 cores on this box above, so anything under 4 in the ldavg columns is great. If you are seeing erratic numbers all over the place, yer cpu's are getting pounded.

However, since you are sharing the underlying disk infrastructure with other vps's, its also plausible that your cpu is bound with IO wait time.

So, lets see what kind of load your cpus have on them, by just using sar by itself.

root@host [~]# sar
11:00:01 AM       CPU     %user     %nice   %system   %iowait    %steal     %idle
11:10:01 AM       all      9.46      0.00      1.73      3.37      0.00     85.44
11:20:01 AM       all      8.89      0.00      1.32      2.86      0.00     86.93
11:30:01 AM       all      7.90      0.00      1.21      2.33      0.00     88.57
11:40:01 AM       all      8.24      0.00      1.07      2.82      0.00     87.88
11:50:01 AM       all      9.61      0.01      1.66      3.05      0.00     85.68
12:00:01 PM       all     12.02      0.21      2.11      5.07      0.00     80.60
12:10:01 PM       all     11.46      0.00      2.02      2.71      0.00     83.81
12:20:01 PM       all     11.34      0.00      1.79      3.23      0.00     83.64
12:30:01 PM       all     12.17      0.00      1.80      3.26      0.00     82.76
Average:        all      7.38      1.38      1.48      7.14      0.00     82.61

Again, Im not seeing much %iowait, but if I look earlier in the day when my logs rotate and backups run, I definitely see a spike:

12:030:01 AM       CPU     %user     %nice   %system   %iowait    %steal     %idle
12:40:01 AM       all      7.09      0.00      1.18      3.85      0.00     87.88
12:50:01 AM       all      6.99      0.00      0.91      3.13      0.00     88.97
01:00:01 AM       all      6.91      0.21      0.99      4.30      0.00     87.59
01:10:01 AM       all      6.39      1.22      2.99     29.00      0.00     60.40
01:20:02 AM       all      6.66      0.07      2.34     28.54      0.00     62.39
01:30:04 AM       all      6.97      0.04      3.71     31.38      0.00     57.91
01:40:01 AM       all      7.05      0.04      2.56     30.02      0.00     60.33
01:50:01 AM       all      8.40      0.08      2.48     28.20      0.00     60.84
02:00:02 AM       all      8.41      4.53      4.25     25.57      0.00     57.24
02:10:01 AM       all      7.55     22.18      2.88     22.46      0.00     44.93
02:20:01 AM       all      7.32     21.35      3.17     14.23      0.00     53.93
02:30:01 AM       all      7.20     21.28      3.22     13.81      0.00     54.49
02:40:01 AM       all      7.92     21.49      3.39     10.68      0.00     56.53
02:50:03 AM       all      6.92      5.14      5.43     28.76      0.00     53.76
03:00:02 AM       all      6.54      3.11      4.45     24.46      0.00     61.44
03:10:01 AM       all      7.59      0.00      1.42     24.12      0.00     66.86
03:20:01 AM       all      7.56      0.00      1.43      4.26      0.00     86.74
03:30:01 AM       all      5.78      0.00      1.12      3.62      0.00     89.47

If I go back and look at my load averages for that time of the morning, sure enough, higher load average:

12:40:01 AM   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-1
12:50:01 AM         3       239      0.19      0.24      0.28
01:00:01 AM         3       238      0.37      0.47      0.36
01:10:01 AM         0       247      2.64      2.55      1.60
01:20:02 AM         2       242      4.05      3.16      2.23
01:30:04 AM         0       244      2.80      3.25      2.81
01:40:01 AM         0       243      2.48      2.76      2.83
01:50:01 AM         0       244      2.97      2.66      2.73
02:00:02 AM         2       247      2.80      3.09      2.98
02:10:01 AM         1       246      2.48      3.07      3.14
02:20:01 AM         1       243      2.33      2.60      2.84
02:30:01 AM         2       254      1.88      2.17      2.50
02:40:01 AM         0       240      2.01      1.88      2.18
02:50:03 AM         1       241      4.95      4.18      3.11
03:00:02 AM         0       243      0.84      2.70      3.17
03:10:01 AM         3       237      1.65      3.51      3.65
03:20:01 AM         3       238      1.03      1.20      2.26
03:30:01 AM         5       239      0.49      0.44      1.32
03:40:01 AM         2       237      1.48      0.89      1.07

So, this is seriously long winded, but hopefully useful for posterities sake. On how to determine if CPU is the issue, and if so, if its disk

But this all led me to yet another issue that you might want to consider. Your timezone is UTC+7. Hostgators boxes are typically in CDT, or UTC -5. Have you checked the timezone on the server itself? If not, you might be having log rotations and backups raging during the middle of your day...

Anyhow, if you've made it this far, and you see that its definitely CPU that choking on your server, then the next step is to reconfigure apache to use mod_php. (fcgid is supposed to be better for high load sites, but only if you know how to tune it properly, and I dont so...)

Major caveat
Apache is currently running as warawiri_admin, and as such has all the permissions it needs to write stuff into places like sites/default/files.

When you switch it over, it will be running as apache, which means that anywhere that apache was writing to the filesystem needs to be given permissions to do so. If everything is only writing to sites/default/files on down, then you can chgrp all the directories to be group 'nobody', and setgid those directories so that even if you ftp files in, apache can still overwrite them etc.
You should probably also add warawiri_admin to the 'nobody' group.. will make ftp/shell access much easier on you as well.
That being said, you will still probably run into permissions problems.. it just the nature of unixness.

[root@foo]# find /home/warawiri_admin/public_html/sites/default/file -type d -exec chmod g+s '{}' \;
[root@foo]# find /home/warawiri_admin/public_html/sites/default/file -type d -exec chgrp nobody '{}' \;

There's two ways to reconfigure apache:
1. Call hostgator support and pay them to do it - tell them you want your apache to run dso instead of suphp so you can run APC. Or
2. Go through the control panel and cross your fingers that you dont accidentally enable/disable something you shouldnt have..

You can use WHM's easy apache control panel to switch this

Login to http://warawiri.com:2086 with your root password and you should be able to reconfig apache here:
Main >> Software >> EasyApache (Apache Update)
Be sure to save your existing config etc. Theres a bunch of screens and options, but you should only have to make sure you turn SuPHP off.

After apache reboots you can check here and see if php is setup right..:

Main >> Service Configuration >> Apache Configuration >> PHP and SuExec Configuration

Option Value
Default PHP Version (.php files) 5
PHP 5 Handler dso
PHP 4 Handler cgi
Apache suEXEC off

I'd still recommend that you ask hostgator to do this, unless you're okay with a little bit of downtime and possible stressful learning. Final Caveat - I still think you need to run XHProf over your code to see what it is thats hogging everything up.. maybe your mysql is the bottleneck?

you are going too far...

playfulwolf's picture

@reynaldio
sorry for slow responce:

to be short - try to get vps from some smaller company, which may be 2-4$ more, but will offer some semi-managed services, personal youch, also properly configured servers. avoid huge companies.

in your case, get cacherouter + APC + authcache(stored inAPC) working is task #1 it will get you huge increase in performance, also: even without caching your site should be usable, 2-5s for crowded with elements page, so there may be some broken module OR too many of them OR vps server is not worth your money.

pm me, if you want me to take a look.

drupal+me: jeweler portfolio

sorry for slow

reynaldio's picture

sorry for slow response

@mixologic thank you for your detail explanation. i've asked hostgator to change my phphandler to dso. and it appears that with dso, my server is using lower resources (memory and cpu) :).

@PlayfulWolf unfortunately, i have 3 years contract with my current provider for a discounted price :p

I have uninstalled memcache and installed cacherouter and seems like that apc is running on my web. however, my page execution time get much higher than before. Before it was around 3000 ms and now it is 60000 ms. But i could not find a clue where i did wrong. i've changed it back to memcache since it took about 1 minute to open the homepage.

this is my apc configuration

extension = "apc.so"
extension = "uploadprogress.so"

[apc]
apc.enabled=1
apc.enable_cli=0
apc.rfc1867=1
apc.shm_segments=1
apc.optimization=0
apc.shm_size=128
apc.stat=0
apc.ttl=0
apc.user_ttl=0
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.max_file_size=10M

this is what in my settings.php

$conf['cache_inc'] = './sites/all/modules/authcache/authcache.inc';
$conf['cacherouter'] = array(
'default' => array(
'engine' => 'apc', // apc, memcache, db, file, eacc or xcache
'server' => array(), // memcached (host:port, e.g., 'localhost:11211')
'shared' => TRUE, // memcached shared single process
'prefix' => '', // cache key prefix (for multiple sites)
'path' => 'sites/default/files/filecache', // file engine cache location
'static' => FALSE, // static array cache (advanced)
'fast_cache' => TRUE,
),
);

Thanks
Reynaldi

Page execution time was 100758.23 ms.

reynaldio's picture

Executed 1059 queries in 580.43 milliseconds. Queries taking longer than 5 ms and queries executed more than once, are highlighted. Page execution time was 100758.23 ms.

i enable apc with the configuration above, and memcache with memcache api. with dso phphandler and Apache suExec off
What have i done wrong???

this is my settings.php

$conf = array(
'cache_inc' => './sites/all/modules/authcache/authcache.inc',
'memcache_servers' => array(
'localhost:11211' => 'default',
'localhost:11212' => 'block',
'localhost:11213' => 'content',
'localhost:11214' => 'filter',
'localhost:11215' => 'form',
'localhost:11216' => 'menu',
'localhost:11217' => 'page',
'localhost:11218' => 'update',
'localhost:11219' => 'views',
'localhost:11220' => 'radioactivity',
),
'memcache_bins' => array(
'cache' => 'default',
'cache_block' => 'block',
'cache_content' => 'content',
'cache_filter' => 'filter',
'cache_form' => 'form',
'cache_menu' => 'menu',
'cache_page' => 'page',
'cache_update' => 'update',
'cache_views' => 'views',
'radioactivity' => 'radioactivity',
),
);

First step

Mixologic's picture

First off, if you are on a single vps, dont bother with memcached. You arent gaining anything there. That will help you when you have more than one server.

The only thing I would recommend running at this point is APC. - when you look at apc.php is the graph full or is there some space in the piechart? If its full you've got another problem.

The next, absolutely essential step if you are ever going to get your site performing normally is to find out what the resource contention is, find out why that contention is there, and only then apply solutions like authcache and cachrouter - you could be throwing water on a greasefire without knowing the situation first.

You need to determine what exactly the problem is. sar, top, vmstat, and munin are all great server side tools to see the resources from that angle. And I will re-emphasize - Install xhprof. It will tell you in a matter of seconds exactly what pieces of your site are running so slowly.

It also appears as though something has dorked your .htaccess file. Everything is trying to download instead of execute.

Are you sure?

gchaix's picture

First off, if you are on a single vps, dont bother with memcached. You arent gaining anything there. That will help you when you have more than one server.

Are you sure about that? Memcache should still help, as it offloads the stuff that would normally be cached in the database into RAM cache. I'd agree if you were suggesting switching from memcache to using something like cacherouter and caching variables, etc. in APC's client cache. But compared to DB caching, anything is an improvement.

For a single VPS, I'd

dparkmit's picture

For a single VPS, I'd recommend using CacheRouter set to use file caching for the Drupal cache and using APC solely for opcode caching. I've been running multiple sites for years with this kind of setup and the servers are perform extremely well!

Here are the reasons why:

If you look at the benchmark at this page (http://www.mysqlperformanceblog.com/2006/08/09/cache-performance-compari...), you'll notice that a file-based cache is much faster than memcached on the same server. Initially, this may seem weird because reading from memcached's RAM storage should be an order of magnitude faster than reading from a file-based cache's storage. But file-based caches outperform memcached because the PHP clients need to read memcached's data over a network connection, which adds a ton of overhead.

In addition to being slower than a file-based cache, memcached also adds complexity to your system because there's another server, which could halt for some reason. And so you need to add a process that monitors the memcached daemon and potentially attempts to restart it.

IMO, the only time to use memcached over file-based cache is if you have multiple web servers. In that case, using memcached actually reduces complexity over file-based caching because you don't need to worry about cache consistency. Memcached clients will automatically split the cached data across all of your memcached servers. A single cached item will only reside on a single server. And so clearing caches and deleting items from caches is easy. File-based caches could keep copies of the same cached data on every single server. And so when a cache item needs to be deleted, your web server needs to figure out some way to let all other web servers know that they should clear out their caches.

Here is a quote from the memcached site (http://code.google.com/p/memcached/wiki/NewOverview) about the problem of maintaining cache consistency. "Cache Invalidation is a Hard Problem. Given memcached's centralized-as-a-cluster nature, the job of invalidating a cache entry is trivial. Instead of broadcasting data to all available hosts, clients direct in on the exact location of data to be invalidated. You may further complicate matters to your needs, and there are caveats, but you sit on a strong baseline."

Finally, you may wonder, why wouldn't you use APC instead of a file-based cache? Using APC to store user data in addition to storing just opcode cache will make your PHP server unstable due to race conditions. Here is an article that describes the problem of APC cache bombs (http://t3.dotgnu.info/blog/php/user-cache-timebomb). As the author points out: "Sooner or later, your apache, php and everything just gives up and starts dying." The worst part about the APC cache bomb is that you likely won't even start seeing it happen until your server is being hit hard, which is exactly the time when you need the cache the most. FYI, I've experienced this scenario and can assure you that it's quite painful to realize that your Apache server isn't returning any data and needs to be restarted.

By the way, we do use APC as an opcode cache and it provides significant speedup for our PHP code because the server doesn't need to recompile files. And so I do recommend APC or eAccelerator as opcode caches.

Apc still suffers from race conditions?

Mixologic's picture

I concur 100% with everything you are saying about memcached.

The user-cache-timebomb article is pretty interesting, but I thought that the apc.write_lock took care of the conditions described in the article.. hasn't APC been updated to not suffer from those race conditions in the three years that have passed since that article was written? That being said, I havent found too many instances where using APC's user object space was all that much of a performance boost over the filesystem, and since I'd rather keep the memory for more apache processes, I tend to go filesystem for caching.

In any case, APC vs Memcached vs cacherouter/filesystem etc are red herrings until one can determine what lies at the root cause(s) of the performance issues. Im suggesting that he turns off all of these "solutions" and starts turning to some probing and instrumentation tools to find out whats going on with his installation. No sense in prescribing 'disk caching' antibiotics to a site that is primarily authenticated users.

edited. for brevity's sake.

Mixologic's picture

edited. for brevity's sake.

Where do you install the xhprof commands

dparkmit's picture

@Mixlogic, thanks for your suggestion to install xhprof. I've been reading about that profiler and am now motivated to get it installed! I have a question for you though. How/where do you suggest installing the xhprof calls?

Based on reading the documentation, I think that you should add the xhprof enable and disable calls in the index.php page since all Drupal pages get invoked from index.php. Ordinarily, I wouldn't make changes to core because any modifications to core make upgrades in the future difficult. And so I install any changes as either a new module or a theme. But in this case, it seems that putting the xhprof calls in index.php is the right thing because doing so will give the most complete picture of performance.

dparkmit's picture

Hi Mixlogic,

I concur with your idea to do a root cause analysis to uncover the real culprits. My guess is that the original author is suffering from both unoptimized code and misconfigured caches. That being said, you may want to do the root cause analysis with the cache turned on because the cache's behavior can significantly alter the performance profile of the code.

For example, one of my sites has a piece of code that takes almost 30 seconds to run and even requires an expansion of the allocated memory. But we cache the results for 24 hours because it returns data that only needs to be updated once a day. If we completely turned off our cache, then a performance profiler would show that this one piece of code is the biggest memory and cpu hog in our whole system. But this result would be a red herring because there's really no way to further optimize the code because the code simply needs to crunch a ton of data. And a properly configured cache eliminates this problem.

I'm not sure if APC still suffers from the race conditions because I haven't used APC all that much for caching user data. My primary experience with it has been a problem that I had with a WordPress system where caching user data caused the site to randomly crash and show only a white screen on my browser until I restarted the Apache server. Figuring out that APC was the culprit took a long time because there was no error messages. It could be that my APC configuration was buggy. But like you, I opted to just use file-based caching because that performed just fine for our purposes.

FYI, I just looked up the documentation for APC.write_lock. It looks like that configuration setting only applies a lock when APC is caching opcode and not when APC is caching user data.

But you should still do the

Mixologic's picture

But you should still do the profiling/analysis with caching off so that you are aware of the 30 second machine killers. Then apply whatever medicine is appropriate and profile again to ensure that those 30 second number chippers are safely accounted for. Profile->tune->profile->tune.

Good to know about the userspace race conditions. I too have apc up on a pretty heavy wp site (8-10k unique visitors a day), and while I cant say I've run into any issues with it yet, the opacity of something that low level means I cant say Im not having issue with it.. who knows .. maybe its in some sort of thrashing statis with lots of collisions. Im only caching db queries there though, not pages. Found full pages to be just too consuming to be worth it, especially with 15 or so crawlers mowing through 3 year old sections of the site that nobody needs in the cache...

Worth noting that it still looks like APC isnt doing anything on the OP's site
http://bandung.warawiri.com/apc.php

But seemed like his site was down yesterday so I dunno if something changed..

This site may be a lot faster with basic steps

drupalbuilder.com's picture

I had a look on site and realized it may be a lot faster with basic steps even on normal server:

  1. CacheRouter: http://drupal.org/project/cacherouter
  2. CSS Gzip: http://drupal.org/project/css_gzip
  3. JavaScript Aggregator: http://drupal.org/project/javascript_aggregator

Enable these all and go to your site with admin access: [www.example.com]/admin/settings/performance

  1. Enable Optimize CSS files option and check GZip CSS option below that
  2. Enable Optimize and Minify JavaScript files option and check GZip JavaScript
  3. Now save configuration.

Note: As I have seen your site is having mostly active data. So. do not enable main Caching mode. Even leave disabled Page compression and Block cache or decide as per data coming over there.

  1. Open your .htaccess file and modify it for data caching / expiry as per site nature. Like:

i)

# unset ETag
Header unset ETag
FileETag None

ii)

set expiry of heavy files. Specially for images, css and video or down-loadable files. You can set it like below given with different expiry of different files as well:

<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "access plus 1 months"
Header set Cache-Control "max-age=272800, public, must-revalidate"

</FilesMatch>

You can Download Yslow tool and check your site speed, loading as well having issues over there before making these changes and after making these all changes.

You will get a lot improved. However feel free to leave a line in case you are facing any more problem even after doing these all steps?

You are most welcome!!

We want to make things faster & easy instead making it very complex and costly :)

Drupal Builder
Making Development Quick, Simple & Easy.
www.drupalbuilder.com

Hi, Thank you all for your

reynaldio's picture

Hi,

Thank you all for your comments. After a couple of hours searching, i finally found what made apc not working. it appeared that i had zend extension installed which is not compatible with apc. this is a screenshot from apc.php http://www.flickr.com/photos/44545289@N08/4624640383/

so, if i understand correctly, it would be best to use cacherouter + file based caching and APC for op-code for my vps?
This is some info from top when i tried to open my homepage.

03:07:59 up 3 days,  9:19,  1 user,  load average: 0.24, 0.13, 0.34
Tasks:  67 total,   2 running,  65 sleeping,   0 stopped,   0 zombie
Cpu(s): 79.6%us,  5.0%sy,  0.0%ni, 15.4%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1376256k total,   723924k used,   652332k free,        0k buffers
Swap:        0k total,        0k used,        0k free,        0k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
5534 nobody    15   0  363m 109m  49m S  0.0  8.1   0:13.39 httpd
19913 mysql     15   0  252m 108m 4884 S  2.3  8.0   5:17.19 mysqld
7839 nobody    15   0  360m 100m  46m S  0.0  7.5   0:06.91 httpd
20253 nobody    18   0  357m  98m  46m S 82.2  7.3   0:03.57 httpd
20273 nobody    15   0  347m  89m  45m S  0.0  6.6   0:03.94 httpd
20276 nobody    15   0  347m  84m  43m S  0.0  6.3   0:05.14 httpd
9887 nobody    15   0  327m  72m  49m S  0.0  5.4   0:06.08 httpd

As you can see, it takes up to 80% of cpu for 1 httpd process. so something must be wrong.
i'll try to install xhprof and do more tuning tommorow and post back with the results.

Regards
Reynaldi

as some of us already

playfulwolf's picture

as some of us already recomended - forget about memcache for now, personally I would recomend to try in this order:
1) Check if APC opcode is really working well, leave as it is for day or two...
2) Install Boost module, and DISABLE css, js, json and ajax caching, leaving just html caching, also I do not recomend to enable crawler
3) Install Cacherouter, play with differnet settings: db, file, APC caching
4) Authcache - enable it for all user roles, exept anonymous, as Boost took care of it (memcache is causing problems, when used with authcache..)
5) Start front end optimisations...

drupal+me: jeweler portfolio

Okay, lets redo this on more

reynaldio's picture

Okay, lets redo this on more time.

My server now has dso + apc(op-code only) + cacherouter(file caching) + boost + authcache.

APC

[apc]
extension="apc.so"
apc.enabled=1
apc.cache_by_default=1
apc.shm_segments=1
apc.shm_size=160
apc.optimization=0
apc.stat=0
apc.ttl=0
apc.user_ttl=0
apc.enable_cli=1
apc.num_files_hint=1000
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.max_file_size=10M
apc.rfc1867=0
apc.include_once_override=1

cacherouter

$conf['cache_inc'] = './sites/all/modules/authcache/authcache.inc';
$conf['cacherouter'] = array(
  'default' => array(
    'engine' => 'file',               // apc, memcache, db, file, eacc or xcache
    'server' => array(),             // memcached (host:port, e.g., 'localhost:11211')
    'shared' => TRUE,                // memcached shared single process
    'prefix' => '',                  // cache key prefix (for multiple sites)
    'path'   => 'sites/default/files/filecache',    // file engine cache location
    'static' => FALSE,               // static array cache (advanced)
    'fast_cache' => TRUE,
  ),
);

my.cnf

[mysqld]
log-slow-queries
safe-show-database
tmp_table_size = 48M
max_heap_table_size = 48M
query_cache_limit=2M
query_cache_size=48M ## 32MB for every 1GB of RAM
query_cache_type=1
max_connections=150
max_user_connections=150
collation_server=utf8_unicode_ci
character_set_server=utf8
delayed_insert_timeout=40
interactive_timeout=25
wait_timeout=1000
connect_timeout=10
thread_cache_size=32
key_buffer=36M ## 32MB for every 1GB of RAM
join_buffer=1M
join_buffer_size=2M
max_connect_errors=999999
max_allowed_packet=100M
table_cache=4096
record_buffer=1M
sort_buffer_size=1M ## 1MB for every 1GB of RAM
read_buffer_size=1M ## 1MB for every 1GB of RAM
read_rnd_buffer_size=1M  ## 1MB for every 1GB of RAM
thread_concurrency=2 ## Number of CPUs x 2
myisam_sort_buffer_size=64M

Let's see how it goes for a couple of days

Thanks guys
Reynaldi

Sweet.. seems faster. If a

Mixologic's picture

Sweet.. seems faster. If a page is in the boost cache yer getting subsecond response. If its a new pageview, its between 2 and 4 seconds.. still a little laggy, but not in the realm of holy crap this is slow.

You should definitely check your sar logs to verify that your log rotation scripts are not happening in the middle of the day, and also I would still advise a once over with xhprof to see whats making the 4 second pageviews for logged in users/non cached boost pages.

Finally since you are on hostgator, I had discovered a problem with cpanel where it was restarting apache every two hours as part of some other dorkup. Check out this thread here: http://forums.cpanel.net/f5/cpanel-11-25-log-processing-145417.html.
It mentions a different logging method they added to cpanel that will stop it..

When apache restarts it flushes your apc cache.. which isnt a huge deal now, but can really drag things down if you are super busy (as Im sure you hope to be).

Good luck!

Hi, wow, that is why my

reynaldio's picture

Hi,

wow, that is why my apache keeps restarting. Thanks alot mixologic for pointing that out.
At first, my site works pretty fast. Page load time reduced from 80000 ms to 8000 ms. (still need alot of improvements, i know :). need to check all php code, and join query). but after of couple of hours running, the page load time is back to 80000 ms :(. I havent got the time to check the logs, but i suspect that my cache is messed up. I use domain access, is there any specific configuration i need to look into?
i'll try to look into this when i have got the time.

Regards
Reynaldi

Hi, It seems that authcache

reynaldio's picture

Hi,

It seems that authcache is not working since i always get "cache_render: "First_Page_Request"" and cache age is always less than 1 minute.
I have turned off cacherouter to debug and changed authcache to cache to default engine(db), but still not working.
Setting $cookie_domain in settings.php also does not solve the problem.
I also get "Cache write error, failed to open file "sites/default/...". I think i have file permission problem with cacherouter.
My apache runs as nobody so I chown -R nobody filecache and chmod 777, but still error persists. Should i also chown modules folder to nobody?
i've also tried enabling suExec, but to no avail.

Anyone have any idea?

Thanks
reynaldi

Permissions issues, Views Issues

Mixologic's picture

You should definitely make sure your whole sites/default/files subtree is writable by nobody. a chgrp should work well:
chgrp -R nobody sites/default/files and chmod -R 775 sites/default/files. There could be all kinds of tmp folders that apache is having probs with (the downside of not running suphp - permissions issues).. particularly the js/css/ctools/tmp etc. so make sure "nobody" can write in all those dirs.

As far as domain access playing nice with authcache/cacherouter. I havent used it with those modules, but I think thats definitely worth investigating considering that

And something running fast at the start and then slowing way down later sounds like a symptom of an in memory cache filling up, using more memory than is available and being forced to page everything into/out of disk. You could do something like vmstat 10 > ~/vmstat.log after you restart it all to see if your memory is slowly decreasing, but whats putting stuff into memory in the first place?

Another thing it could be is how apache is set up as far as how many httpd listeners it keeps running. Now that they dont die inbetween each request, they start to fatten up with memory, and you start hitting those 80 second page response due to too many bloated apaches lying around, and being out of ram. worth looking at.

Finally, after looking around on your site a little, I notice one thing that may be causing your site some slowdown.

For you menu, I notice that every menu item points to something like "category/resto/restaurant"
Are you perhaps implementing that as a view? with a path of category/%/% for example? Do you have multiple menu items that are all pointing at views that take arguments? I've ran into this exact scenario before, and well.. its an issue with the way the menu is implemented in core. Basically there is a load function that gets called for each menu item, and if that menu item happens to be a view, that load function happens to be a really expensive call. Additionally the menu implementation can sometimes call the same load function again, and again, and again, and you end up with wicked slow pageloads, and it is almost all due to views being a menu item. (not to mention all the other views)

Just for grins, look at this comment here, and modify menu.inc like the second codeblock and see if it substantially drops your page view times:

http://drupal.org/node/402944#comment-2762506

You have a lot of views on your site, so this will hopefully help as well.

This is in my

reynaldio's picture

This is in my httpd.conf

<VirtualHost 174.121.25.14:80>
    ServerName bandung.warawiri.com
    ServerAlias www.bandung.warawiri.com
    DocumentRoot /home/rariwawi/public_html
    ServerAdmin webmaster@bandung.warawiri.com
    UseCanonicalName On

    ## User rariwawi # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
        suPHP_UserGroup rariwawi rariwawi
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        SuexecUserGroup rariwawi rariwawi
    </IfModule>
    ScriptAlias /cgi-bin/ /home/rariwawi/public_html/cgi-bin/


    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/std/2/rariwawi/bandung.warawiri.com/*.conf"

</VirtualHost>

"SuexecUserGroup rariwawi rariwawi" could this be the problem?

Those menus are not menu generated by views, but it does link to a view/panel that takes argument. I do have too many views and will try to remove some of them as soon i'm done with this caching thing :)

Thanks
Reynaldi

Suexec

Mixologic's picture

suexec/suphp is unlikely to be an issue: HG admins changed you to dso, and your apc is running like it should, and your top output shows the httpd processes running at nobody/nobody. - simply make sure that any sites directory that you are running has permissions for nobody to write to: (sites/default/files - or any others {cant remember if domain access gives different files directories for different sites})

And the menus are not generated by views, but they are menu items that point to views? Then you are doing exactly the same thing we were doing with a different site. I guarantee that if you fire up xhprof, and profile your code, you'll see that one of the largest culprits is views_unpack_options() - which is the expensive function call I was talking about.

Seriously.. change menu.inc and see what happens to your page load times..

R

@Mixologic. I've installed

reynaldio's picture

@Mixologic. I've installed xhprof, and you're right. I saw a lot of view:unpack options there. I've fixed this by following your comment and did see some improvements on page loading. Thanks alot.

I've set all cache folder permission to 0777. I see cache write error in devel when i use krumo theme. But if i use default theme, i occasionally see
this error "warning: strtr() [function.strtr]: The second argument is not an array in /home/rariwawi/public_html/includes/common.inc on line 941."
I also see the last error in dblog.
I'll try to ask cacherouter and authcache author to see if there are issues with domain access module and post back for my findings.
In the mean time, i'll go over my views and themes and see if i can make some improvements there.

Thanks
reynaldi

Previous have been using

skolesnyk's picture

Previous have been using Nginx 0.8.52+PHP-FPM+APC 3.1.2 (and 3.1.3p for testing) along with boost installed.

Performance was fine until APC cache memory was filled with compiled scripts. Then php-fpm sometimes was unresponsive, which meant it had to be restarted manually.

Decided to try out eAccelerator -- now my vps is running quite stable and fast.

strtr

DaPooch's picture

Installed XHProf and found out that strtr() funciton is taking 19+s to run in certain instances (saving modules page, creating new fields page). Seems to be tied to the db_prefix_tables function too. Makes developing unbearably slow. Not sure what to do with this info though. Anyone have any ideas?

Turns out this was an issue

DaPooch's picture

Turns out this was an issue with CIVICRM and the views integration. Since I had the Civicrm DB separate from drupal the instructions said to add table prefixes via the settings file which slowed down a ton of my queries. I ended up merging the two DBs and that solved my issue.

@alanpuccinelli you might

dalin's picture

@alanpuccinelli you might want to review this patch
http://drupal.org/node/561422
Benchmarked to show significant performance improvement when a lot of table prefixes are present.

--


Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his

Subscribing

uptil4music's picture

Subscribing

I am in the middle of this

socialnicheguru's picture

I am in the middle of this too.
I installed apc.
I had to play with the apc.ini file
/etc/php5/apache2/conf.d/apc.ini

some settings allow for quotes others do not. That was very frustrating.

this is what mine looked like:
extension=apc.so

apc.enabled=1

apc.max_file_size= 10M #overkill for testing
apc.shm_size= 200

apc.ttl=7200

apc.user_ttl=7200

apc.shm_segments=1

notice that apc.shm_size =200 which is 200 megabytes
I thought I could make it "200M" or just 200M but neither worked while apc.max_file_size = 10M does work and apc.max_file_size =10 just allocates 10 bytes. It is just weird.

I am using aegir and could not figure out how to use boost with it. Aegir modifies all httpd files.

also use devel to see which queries are slow
use firebug to see how long certain queries take and what is taking so long to load
reduce the number of modules you have even if they are not installed. My drupal install reads them regardless and they do not seem to be cached.
modify your page.tpl.php to move "print $script" to the end before print $closure. This might reek havoc with some modules though.
take a look at your apc log and see which queries are large and modify the max file size appropriately.

I hope that helps.

This site may be allot faster with basic steps

drupalbuilder.com's picture

I had a look on site and realized it may be allot faster with basic steps even on normal server:

  1. CacheRouter: http://drupal.org/project/cacherouter
  2. CSS Gzip: http://drupal.org/project/css_gzip
  3. JavaScript Aggregator: http://drupal.org/project/javascript_aggregator

Enable these all and go to your site with admin access: [www.example.com]/admin/settings/performance

  1. Enable Optimize CSS files option and check GZip CSS option below that
  2. Enable Optimize and Minify JavaScript files option and check GZip JavaScript
  3. Now save configuration.

Note: As I have seen your site is having mostly active data. So. do not enable main Caching mode. Even leave disabled Page compression and Block cache or decide as per data coming over there.

  1. Open your .htaccess file and modify it for data caching / expiry as per site nature. Like:

i)

# unset ETag
Header unset ETag
FileETag None

ii)

set expiry of heavy files. Specially for images, css and video or down-loadable files. You can set it like below given with different expiry of different files as well:

<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "access plus 1 months"
Header set Cache-Control "max-age=272800, public, must-revalidate"

</FilesMatch>

You can Download Yslow tool and check your site speed, loading as well having issues over there before making these changes and after making these all changes.

You will get allot improved. However feel free to leave a line in case you are facing any more problem even after doing these all steps?

You are most welcome!!

We want to make things faster & easy instead making it very complex and costly :)

Drupal Builder
Making Development Quick, Simple & Easy.
www.drupalbuilder.com

Why did you post this

Garrett Albright's picture

Why did you post this twice?

Anyway, I recommend against the CSS Gzip module. Instead, you should configure your server to send CSS and JS (and other uncompressed) files as gzipped and let it do the work, not PHP.

Also, "a lot" and "allot" are two entirely different words/phrases.

Configure Server to send files as gzipped ...

drupalbuilder.com's picture

YES, Configure Server to send files as gzipped is also very good option.

And Thanks for your time and review of comments. It helps to keep thread clean.

... will take care.

http://groups.drupal.org/node/61638#comment-342034 has been corrected but I think here is no option to updated replied comments.

Drupal Builder
Making Development Quick, Simple & Easy.
www.drupalbuilder.com

High performance

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: