Date post: | 18-Dec-2015 |
Category: |
Documents |
Upload: | victoria-terry |
View: | 214 times |
Download: | 0 times |
Who is this guy?
Chris Porter - [email protected] Consultant – Acquia8 years of Drupal Experience4.5yrs Professional Services
Doesn’t learn from mistakes
Level 1: PHP is Crazy
Nervous?
Q: How many files does a single freshly installed Drupal page include? A: ~80 files
Q: How many files does my current client’s “events” page include? A: 2830* (well, actually it was ~680)
CRAZY: What about 1000 requests?
How many times did PHP meet the definition of insane? Crazy = includes * (requests - 1)• Stock Drupal: 79,920• My Client: 2,150,000 (!!!!)
Actual traffic pattern for that client:3MM page views per month! 100K per day!
Crazy Medicine: PHP OPCode Caching
Opcode Caching is hands down the:• Easiest• Fastest• Most over-lookedSingle performance improvement you can make.It makes the PHP engine *not crazy*
OPCode Caching
• Caches the pseudo compiled version of a file
• Caches the filesystem permissions
• Stores the cache in memory• Shares the memory with other
PHP processes• Some even provide fast acting
data memory space
Use APC – Its Easy
1) Install APC2) Add the following lines to
your php.ini file
extension=apc.soapc.enabled=1apc.shm_segments=1apc.shm_size=64apc.stat=0
3) Drink a beer
More Detail at: https://drupal.org/node/1777090
This Means its working!
10
APC Magic in Action50s!
15s!
APC Configuration Applied
Local doc root fix
300ms
Level 2:Your code
What you are probably doing that is totally bonkers.
We’ve all done this at least once
*This is not real code, I made it up entirely
Lets break it down:
1 request results in: 1 db query+ 100 service calls
1000 requests results in: 1000 db queries 100,000 service calls
That’s a lot of crazy: about 99,900 to be exact.
The Cure
Try Drupal’s Cache APIhttps://api.drupal.org/api/drupal/includes%21cache.inc/7
Use the functions: cache_get() and cache_set()If you like data organization, implement your own cache table!
Infrequent updates? Cache the
whole thing!
Now who’s crazy?
• 1 request = 100 webservice calls• 1,000 requests = 100 webservice calls• 1,000,000 requests = 100 webservice calls• No more crazy here!
Level 3: Drupal
How you are configuring Drupal to be crazy
Mass Delusion: You are making all of your users crazy
Max simultaneous requests time gap
Substantially reduce client requests
Views Caching
• Views Caching
Panels Caching
• Panels Caching
Page Caching
• Page Caching
Level 4: Your Webserver
Your webserver is acting crazier than you think. It probably has a gnarly case of OCD.
100 pages and 1,000,000 requests
Q: How many times did Drupal “bootstrap”?A: 1,000,000 (at least)
Q: What’s the definition of crazy here?A: Requests – Pages = CRAZY
Your webserver was crazy 999,900 times!
OCD Training: Front-end Caching
Things to consider about front end caches:
• Provide extremely fast content delivery• Take Drupal out of the equation for almost all
requests.• Only works for anonymous users* (mostly)
OCD Meds: Varnish
• Install Varnish (*nix only)• Read Lullabot’s amazing varnish tutorial• Use Lullabot’s pre-written “high availability
VCL”• Get Drupal’s Varnish Module• Configure Drupal’s page cache options.• Wonder where your server load went
Level 5: Your Infrastructure
Your network is delivering the same content over and over again for no other reason than because it can.
Your network needs a Quaalude.
Deep thoughts:
What happens if your servers network goes down?What happens if your systems fail? (it happens)Why should users in Japan get content delivered from Colorado?
Ever wonder why websites say “server down” on one page, but not another?
CDN’s to the rescue
Content Delivery Networks distribute your content around the world.Main modes of operation:• Reverse Proxy – point your DNS at them, let
the magic happen.• File Server – put static assets such as images
up on the CDN– serve fewer requests.
Pro’s• Rapidly scale your anonymous content globally• Deliver content in very short routes to consumers• Reduce the load on your serverCon’s• You pay by the byte of data• Do it wrong, and you’ll pay for 2x the bytes of
data• Clearing the cache can take a whileNotes:• Somewhere around 150 endpoints to deal with
Checking out
You just made the front page of:• Reddit• Slashdot• Drudge report
Are you still crazy?
Calming Meds: Expected Traffic
• The CDN will server all of that traffic except:100 pages * 150 endpoints = 15,000 requests.
• Varnish will server all previously served page requests:15,000 – 100 unique pages = 4,900 requests
• Drupal will bootstrap: 100 times
• PHP will include: 698 files[SANE]
Summary: Main problem areas
• PHP – Lack of Opcode Caching• Code – Cache things you should only do once• Webserver – Use Compression• Cluster – Use reverse proxy caching• Cloud – Use a CDN
That’s It!
Questions?
Resources:• Lullabot’s Varnish Writuphttp
://www.lullabot.com/blog/article/configuring-varnish-high-availability-multiple-web-servers
• Configure APC for Drupal: https://drupal.org/node/1777090• CDN Discussions: http://wimleers.com/article/key-properties-of-a-cdn• Drupal Cache API: https://api.drupal.org/api/drupal/includes%21cache.inc/7• Drupal Performance Tips:
http://www.achieveinternet.com/enterprise-drupal-blogs/enterprise-drupal-performance-caching-hosting/5-things-you-can-do-improve-performance-and-scal