You are on page 1of 47

Web server

Optimizations
who am i?
pants: on
“walkah”
LAMP
Apache
Unnecessary modules

• Default apache tends to have lots of


modules enabled
• includes (SSI), status (ExtendedStatus)
• Dependent on server needs
Minimal RAM usage
MaxClients

• Maximum # of child processes spawned by


Apache
• Not enough - Apache blocks
• Too many - uses all system RAM
• Swapping is bad
System RAM
/ Per-process RAM
= MaxClients
Use less RAM
KeepAliveTimeout

• KeepAliveTimeout will keep child processes


open for subsequent requests
• Might wasting child process time if too high
• Typical settings (5-15s) probably be fine
AllowOverrides
• Typical Drupal installs set AllowOverride all
for .htaccess
• File check for every filename component -
per request
• Put Drupal’s .htaccess contents in
VirtualHost settings
• AllowOverride none
Don’t forget
files .htaccess
SymLinks

• Options FollowSymLinks &


SymLinksIfOwnerMatch
• Require additional system calls on each
filename component if enabled
• Keep them off (if possible)
Don’t touch the disks
DNS Lookups

• HostnameLookups off (now default) for


logs
• Allow or Deny - use IP’s only
• Lag incurred from performing DNS lookups
Reduce Bandwidth

• mod_gzip / mod_deflate - html, css, js


• CPU usage vs. bandwidth transfer
• compress pngs / graphics
• content caching
mod_expires

• Allows Drupal to send the Expires header


• Encourage browsers to cache content
• Fewer transfers
# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
# Enable expirations.
ExpiresActive On
# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600
# Do not cache dynamically generated pages.
ExpiresByType text/html A1
</IfModule>
http://httpd.apache.org/docs/misc/perf-tuning.html
other web servers
lighttpd

• “Lightweight” == faster
• Clean URL configuration - on your own
• PHP as (fast)cgi
How much faster?

http://buytaert.net/drupal-webserver-configurations-compared
but...

http://buytaert.net/drupal-webserver-configurations-compared
PHP
fastcgi vs. mod_php

• Configure-time PHP build options


• CGI for security / mass hosting
• Privilege separation
• fastcgi to minimize forking of traditional
CGI
mod_php if you can

http://buytaert.net/drupal-webserver-configurations-compared
Unnecessary modules
Unnecessary modules
php.ini

• memory_limit
• log_errors
• safe_mode / open_basedir
Opcode cache

• 2 phases : compile - execute


• Opcode cache eliminates (minimizes)
step 1
• Easiest way to double (or more) Drupal
performance
Reduce CPU usage
xcache

• Part of the lighttpd project


• http://trac.lighttpd.net/xcache/
• Relatively new
• Issues with PHP5
eAccelerator

• Formerly Turk MMcache


• Very fast - often benchmarks fastest
• Development has .... slowed. Issues with
PHP5
APC

• Install via PECL


• pecl install APC
• Maintained by core PHP developers
• Uses shmem by default
(rather than file cache)
APC Options

• apc.shm_size
• reduce RAM
• apc.stat = 0
• don’t touch the disk
• needs restart for new files
Architecture
DNS Round Robin

• Currently utilized by drupal.org


• Clients get stuck
• No failover if 1 web box goes down
Load balancing

• Maximum requests per second


• More web servers
• Horizontal scalability
Diagram by Rasmus Lerdorf
Open Source Options

• pound
• ha-proxy
• squid
• etc...
Commercial Appliances
Static files

• File cache
• Squid
• Apache mod_cache
• Serve files from RAM
Media files

• Separate httpd (tux, minimal apache, etc)


• Separate machines
• Proxy (squid / apache)
• Patch drupal file_url()
hungry?
questions?

You might also like