15
Designing Enterprise Drupal How to scale Drupal server infrastructure ENVIRONMENT S

Designing Enterprise Drupal

Embed Size (px)

DESCRIPTION

Designing Enterprise Drupal. Environments. How to scale Drupal server infrastructure. Jason Burnett ( [email protected] ) NeoSpire Director of Network Services Ben Chavet ( [email protected] ) NeoSpire Senior Engineer Brian Skowron ( [email protected] ) - PowerPoint PPT Presentation

Citation preview

Page 1: Designing Enterprise Drupal

Designing Enterprise Drupal

How to scale Drupal server infrastructureENVIRONMENTS

Page 2: Designing Enterprise Drupal

INTRODUCTIONS

• Jason Burnett ([email protected]) NeoSpire Director of Network Services

• Ben Chavet ([email protected])NeoSpire Senior Engineer

• Brian Skowron ([email protected])NeoSpire Account Executive

Page 3: Designing Enterprise Drupal

SO…FIRST THING’S FIRST

• Prerequisites that you’ll need (or at least want).– A good, reliable network with plenty of capacity– At least one expert Systems Administrator

• You don’t necessarily need this:

Page 4: Designing Enterprise Drupal

BUT YOU DON’T WANT THIS:

(hopefully this isn’t you)

Page 5: Designing Enterprise Drupal

AFTER YOU’VE FIRED THAT GUY,

Default Stack Performance Stack

LET’S TALK STACKS

Page 6: Designing Enterprise Drupal

FIRST, DON’T USE DRUPAL (WELL, SORTA)

• Drop-in replacement for Drupal 6.x• Support for database replication• Support for reverse proxy caching• Optimization for MySQL• Optimization for PHP 5 • Available at: http://fourkitchens.com/pressflow-makes-drupal-scale

Page 7: Designing Enterprise Drupal

AFTER PRESSFLOW, IT’S ALL ABOUT CACHE

• Varnish is a reverse proxy cache•Caches content based on HTTP headers• Uses kernel-based virtual memory•Watch out for cookies, authenticated users• Available at http://varnish-cache.org/

Page 8: Designing Enterprise Drupal

HTTP PIPELINEApache Configuration Varnish Configuration

NameVirtualHost *:8080Listen 8080

<VirtualHost *:8080>[…]</VirtualHost>

backend default { .host = "127.0.0.1"; .port = "8080";}

Page 9: Designing Enterprise Drupal

HTTP LOGGING• VarnishNCSA daemon handles logging• Default Apache logs will always show 127.0.0.1• Define a new log format to use X-Forwarded-For

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined_proxy

CustomLog /var/log/apache2/access.log combined_proxy

Page 10: Designing Enterprise Drupal

CACHING WITH COOKIESsub vcl_recv { // Remove has_js and Google Analytics __* cookies. set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(__[a-z]+|has_js)=[^;]*", "");

// Remove a ";" prefix, if present. set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");

// Remove empty cookies. if (req.http.Cookie ~ "^\s*$") { unset req.http.Cookie; }}

sub vcl_hash { // Include cookie in cache hash if (req.http.Cookie) { set req.hash += req.http.Cookie; }}

Page 11: Designing Enterprise Drupal

BASIC SECURITY// Define the internal network subnetsacl internal { "127.0.0.0"/8; "10.0.0.0"/8;}

sub vcl_recv {

[…]

// Do not allow outside access to cron.php if (req.url ~ "^/cron\.php(\?.*)?$" && !client.ip ~ internal) { set req.url = "/404-cron.php"; }}

Page 12: Designing Enterprise Drupal

VARNISH IS SUPER-FAST

/etc/security/limits.conf

• Able to handle many more connections than Apache• Needs a large number of file handles

* soft nofile 131072* hard nofile 131072

Page 13: Designing Enterprise Drupal

APACHE OPTIMIZATIONS

• Tune apache to match your hardware• Setting MaxClients too high is

asking for trouble• Every application is different• A good starting point is total

amount of memory allocated to Apache divided by 40MB• One of the areas that will

need to be monitored and updated on an ongoing basis

Page 14: Designing Enterprise Drupal

STILL ALL ABOUT CACHE• APC Opcode Cache

• APC is an Opcode cache• Officially supported by PHP• Prevents unnecessary PHP

parsing and compiling• Reduces load on Memory

and CPU

Page 15: Designing Enterprise Drupal

ALLOCATE ENOUGH MEMORY

extension=apc.soapc.shm_size=120apc.ttl=300

kernel.shmmax=134217728

Php.ini Sysctl.conf

FOR APC