SlideShare a Scribd company logo
©2016 Acquia Inc. — Confidential and Proprietary
Erin Rasmussen, Support Engineer,
Acquia
PHP Performance
Tuning
for Drupal 8
©2016 Acquia Inc. — Confidential and Proprietary
Make that Drupal 8 site fly!!
– Brief glance over Best Practices for Performance
Tuning.
– PHP tuning including Opcache, Interned strings and
apcu
– Varnish, Memcache, and Database tips
– The Software Stack, with Drupal 8 integration tips.
©2016 Acquia Inc. — Confidential and Proprietary
Mitigate against Failure by planning for Success!!
– Test, test and then Test again! (Include Load & Security
Testing!)
– Performance Review is Key: Understand the factors
that Affect your Site’s Performance
– Incorporate these strategies in your Continuous
Improvement Process
We want your project to succeed as much as you do!
©2016 Acquia Inc. — Confidential and Proprietary
This is an example stack, there
are multiple ways configure
them, your software may be
different.
Note: Development environments are
almost always Different than
Production environments.
Know the Stack, Love the Stack
Balancer / Varnish
Memcached
Apache PHP/FPM
MySQL
File System
Code Repo
©2016 Acquia Inc. — Confidential and Proprietary
Multi-Tier, the Stack gets bigger
With multi-tier, these the
software stack can be split
among server instances.
With redundancy and
failover.
Balancer / Varnish
Balancer / Varnish
Memcached
Apache PHP/FPM
Apache PHP/FPM
MySQL & File System
MySQL & File System
Code Repo
Server AMI Type #Cores Date Time 1m 5m 15m
bal-1*5*8 m3.2xlarge 8 2017-02-20 00:08:21 0.00 0.03 0.08
bal-1*5*9 m3.2xlarge 8 2017-02-20 00:08:22 0.33 0.29 0.25
web-18**7 c3.large 2 2017-02-20 00:08:21 0.02 0.03 0.05
web-18**8 c3.large 2 2017-02-20 00:08:21 0.00 0.01 0.05
fsdb-1**25 c3.large 2 2017-02-20 00:08:22 0.07 0.05 0.05
fsdb-1**26 c3.large 2 2017-02-20 00:08:23 0.03 0.04 0.05
©2016 Acquia Inc. — Confidential and Proprietary
Balancers / Caching a short intro
Drupal 7, has URL-based page caching
and empties the page cache for every edited piece of content!
2009-2011 Varnish wasn’t widely used, so Drupal 7 caches
pages, but doesn’t invalidate them intelligently.
Cache-Control = public, max-age=300
Works great – until there’s a DDOS or back-end server issue
Cache-Control = public, max-age=31536000
Works great – until content updates aren’t reflected on the site.
©2016 Acquia Inc. — Confidential and Proprietary
Drupal 8 Caching is re-architected
• Has a proper internal cache API, allows tagging of cache
items.
• Each single item is described with tags.
Tags "bubble" up to all rendering parents.
These tags are stored in the cache API.
Cache::invalidateTags(["tag"])
CacheTagsListenersInterface
The content API's call ::invalidateTags().
The render and page caches are transparently invalidated.
©2016 Acquia Inc. — Confidential and Proprietary
Varnish https://varnish-cache.org
Support for Drupal 8 Cache Tags with Varnish
Acquia Purge for Drupal 8 is a fully-featured API
and you plug in a 'purger' to it, to support your CDN
©2016 Acquia Inc. — Confidential and Proprietary
PHP / FPM http://php.net https://php-fpm.org
– Memory Limits
– Max Execution Time
– Zend OPcache
– APC user cache
– Memory Allocation Math
©2016 Acquia Inc. — Confidential and Proprietary
PHP Memory Limit http://php.net/manual/en/ini.core.php#ini.memory-
limit
The PHP memory_limit is the maximum number of M (in
integers) that a single PHP/FPM proc can consume, by
default memory_limit =128M
Clear signs this is set too low:
– php-errors.log: [20-Feb-2017 19:26:10 America/New_York] PHP Fatal error: Allowed memory
size of 268435456 bytes exhausted (tried to allocate 15990062 bytes) in
docroot/includes/database/database.inc on line 2227
– PHP WSOD errors or “Temporarily Unavailable” errors.
©2016 Acquia Inc. — Confidential and Proprietary
Max Execution Time
http://php.net/manual/en/features.connection-handling.php
The amount of time a single PHP process can run (in
seconds) max_execution_time
– Resolve this problems by identifying slow processes
and resolving the request or set_time_limit() function.
Clear signs that your processes are taking too long
–fpm-error.log max_children errors
–White Screen of Death (Temporary Unavailable) errors.
©2016 Acquia Inc. — Confidential and Proprietary
OPcache (opcode cache) http://php.net/manual/en/intro.opcache.php
Caches pre-compiled bytecode. Faster than using PHP of
load & parse each script for each & every HTTP request.
key variable: opcache.memory_consumption(128M)
Needs to be large enough to store compiled code for your
applications PHP scripts Clear sign that this is too small:
– php-errors.log Warning: require_once() [function.require-once]: Unable to allocate memory for
pool.
OPcache Status monitor: https://github.com/rlerdorf/opcache-status
©2016 Acquia Inc. — Confidential and Proprietary
OPcache http://php.net/manual/en/book.opcache.php
Interned Strings - the amount of memory (M) used to store
identical strings (detected by PHP). By default this is a shared
buffer allowing all Drupal PHP processes to reference it across multiple
PHP/FPM procs - saving memory.
Clear sign that this is set too low:
– Fpm-error.log: Warning Interned string buffer overflow
More indepth information:
http://jpauli.github.io/2015/03/05/opcache.html
©2016 Acquia Inc. — Confidential and Proprietary
APC User Cache http://php.net/manual/en/intro.apcu.php
APC User cache is PHP APC minus OPcache, rarely
used in Drupal 7 (apc.shm_size= 8M is ok), increase for
Drupal 8 (apc.shm_size=16 or 32M)
Clear sign that the APC User cache is set too small:
– In php-errors.log : [20-Feb-2017 13:54:16 America/New_York] PHP Warning: apcu_store(): Unable to allocate
memory for pool. in /mnt/www/html/somenamedev/docroot/core/lib/Drupal/Core/Cache/ApcuBackend.php on line
177
Get usage Details!: use apc.php script in the docroot and
view in your browser: note: the charts are less accurate than the text
©2016 Acquia Inc. — Confidential and Proprietary
APC User Cache
Drupal 8.3 will reduce the amount stored in APC user
cache in response to community issues:
– Rationalize use of the 'discovery' cache bin, since it's stored in the limited
size APCu by default https://www.drupal.org/node/2765271
– Change ViewsData to use the default cache bin instead of discovery
https://www.drupal.org/node/2824547
©2016 Acquia Inc. — Confidential and Proprietary
PHP Procs and PHP Memory Math
Total RAM 3860
OS 50
MySQL 1930
Memcache 64
Sites 4
Sitename Memory Limit Opcache APCu FPM
d7sitedev 256 128 8 1
d7sitestg 256 128 8 1
d8sitedev 128 96 16 1
d8sitestg 128 96 16 1
Calculate the available
memory for PHP
(Total - OS - MySQL -Memcache )
Memory use by 1 Process:
– Use top
– memory_get_peak_usage()
– Devel (Drupal 7 & 8)
Calculate how many procs
you can afford.
©2016 Acquia Inc. — Confidential and Proprietary
PHP/FPM max_children errors
When there are more incoming requests than PHP/FPM
can handle you get max_children errors.
Clear sign that the site is exhausting PHP/FPM procs:
– fpm-error.log srv-**35m notice [22-Feb-2017 16:32:38] WARNING: [pool someuser]
server reached max_children setting (27), consider raising it.
Causes are Varied – Large amount of HTTP traffic,
PHP/FPM procs that are looping, or not terminating effectively. Or calls to External Services
hanging/timing out
©2016 Acquia Inc. — Confidential and Proprietary
Adding the Impact of Traffic
What happens when the new site launches – or it gets
retweeted a million times:
©2016 Acquia Inc. — Confidential and Proprietary
What’s in that Traffic?
©2016 Acquia Inc. — Confidential and Proprietary
Memcached https://memcached.org
Is a open source, high-performance, distributed memory object caching system
Drupal 8 Memcache Module is Alpha
https://www.drupal.org/project/memcache
The Drupal 8 module will make GETS and SETS with
properly configured Memcached, and supports
key_prefixing.
However, Memcached slabs are not encrypted by default
Community Development is needed for a Stable Release
of the Memcahed Drupal modue
©2016 Acquia Inc. — Confidential and Proprietary
Keep the Database Layer Happy
– Enable Syslog, disable database Watchdog Logging.
– Caching to the Database does not always Scale, keep
an eye on your capacity and I/O errors.
– Optimize queries, and keep an eye on database tables.
Even the most efficient Views query will be slow on a 50 Gb table.
©2016 Acquia Inc. — Confidential and Proprietary
Keep the Front End Performant
– Compress Site Images, PDFs and other Files before
uploading them to the site. (Even a cached 7MB photo is a major
performance hog when used 27 times on a site.)
– Compress your CSS, and minify your JS.
– Keep an eye on External calls. Use timeouts, and allow your
application to fail gracefully when those resources cannot be reached.
©2016 Acquia Inc. — Confidential and Proprietary
Thank you!  Drupal
✩ Modern PHP: New Features and Good Practices by
Josh Lockhart http://shop.oreilly.com/product/0636920033868.do
✩ Drupal 8 Cache API https://www.drupal.org/docs/8/api/cache-api/cache-
api
✩ Acquia Purge https://www.drupal.org/project/acquia_purge
✩ Drupal’s PHP requirements https://www.drupal.org/docs/7/system-
requirements/php
Ad

Recommended

Vectores isac
Vectores isac
ORIOL SAÚL VIDAL TREJO
 
Episode 4: Personalization Best Practices
Episode 4: Personalization Best Practices
Acquia
 
Episode 3: How to Execute a Persona-based Content Strategy at Scale
Episode 3: How to Execute a Persona-based Content Strategy at Scale
Acquia
 
Acquia Lift for Site Builders: How to Define Campaigns, Set Up Tests, and Int...
Acquia Lift for Site Builders: How to Define Campaigns, Set Up Tests, and Int...
Acquia
 
Learn How to Use Atomic Design to Make Your Site Manageable and Adaptable
Learn How to Use Atomic Design to Make Your Site Manageable and Adaptable
Acquia
 
OpenEDU - A Drupal 8 Distribution to Jumpstart Higher Education Websites
OpenEDU - A Drupal 8 Distribution to Jumpstart Higher Education Websites
Acquia
 
Across the spectrum different approaches to progressively decoupled drupal (...
Across the spectrum different approaches to progressively decoupled drupal (...
Acquia
 
Personalization Using Acquia Lift 2.0
Personalization Using Acquia Lift 2.0
Boston Interactive
 
Questions To Ask Before a Drupal Project Kickoff
Questions To Ask Before a Drupal Project Kickoff
Acquia
 
Episode 5: Using Technology to Accelerate Your Personalization Initiative
Episode 5: Using Technology to Accelerate Your Personalization Initiative
Acquia
 
A Crash Course in Building Site Reliability
A Crash Course in Building Site Reliability
Acquia
 
Drupal 8 Lessons From the Field: What is Continuous Delivery and Why it’s imp...
Drupal 8 Lessons From the Field: What is Continuous Delivery and Why it’s imp...
Acquia
 
Episode 2: Define Customer Segments Using a Data-driven Approach
Episode 2: Define Customer Segments Using a Data-driven Approach
Acquia
 
Tomorrow’s Personalization Today: Increase User Engagement with Content in Co...
Tomorrow’s Personalization Today: Increase User Engagement with Content in Co...
Acquia
 
Acquia Content Hub: Connect Technologies & Extend Systems to Source Content
Acquia Content Hub: Connect Technologies & Extend Systems to Source Content
Acquia
 
Acquia Partner Program Update
Acquia Partner Program Update
Acquia
 
Customer Journey Orchestration: The Secret to Effective Omnichannel Experiences
Customer Journey Orchestration: The Secret to Effective Omnichannel Experiences
Acquia
 
Personalization How-To: Driving Conversions with Acquia Lift
Personalization How-To: Driving Conversions with Acquia Lift
Acquia
 
Build Personalization into Your Culture: Create Engaging Experiences for Ever...
Build Personalization into Your Culture: Create Engaging Experiences for Ever...
Acquia
 
A Professional Software Engineer's Checklist
A Professional Software Engineer's Checklist
Acquia
 
Webinar: Vodafone and The Connected Customer Journey [10.19.2017]
Webinar: Vodafone and The Connected Customer Journey [10.19.2017]
Acquia
 
How to Use the Salesforce Suite with Drupal 8: A Quick Start Guide
How to Use the Salesforce Suite with Drupal 8: A Quick Start Guide
Acquia
 
Lightning Distribution for Drupal: Build Advanced Authoring Experiences in Dr...
Lightning Distribution for Drupal: Build Advanced Authoring Experiences in Dr...
Acquia
 
Building a foundation for the future of digital experience (oct 31, 2017)
Building a foundation for the future of digital experience (oct 31, 2017)
Acquia
 
Webinar : Acquia Lift for a optimized and personalized user experience
Webinar : Acquia Lift for a optimized and personalized user experience
Cyril Reinhard
 
アステラス製薬 - グローバルWebブランディングとガバナンス [動画あり]
アステラス製薬 - グローバルWebブランディングとガバナンス [動画あり]
CI&T Japan
 
Performance and Scalability
Performance and Scalability
Mediacurrent
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve Internet
Achieve Internet
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve Internet
Achieve Internet
 
Drupal performance
Drupal performance
Piyuesh Kumar
 

More Related Content

Viewers also liked (18)

Questions To Ask Before a Drupal Project Kickoff
Questions To Ask Before a Drupal Project Kickoff
Acquia
 
Episode 5: Using Technology to Accelerate Your Personalization Initiative
Episode 5: Using Technology to Accelerate Your Personalization Initiative
Acquia
 
A Crash Course in Building Site Reliability
A Crash Course in Building Site Reliability
Acquia
 
Drupal 8 Lessons From the Field: What is Continuous Delivery and Why it’s imp...
Drupal 8 Lessons From the Field: What is Continuous Delivery and Why it’s imp...
Acquia
 
Episode 2: Define Customer Segments Using a Data-driven Approach
Episode 2: Define Customer Segments Using a Data-driven Approach
Acquia
 
Tomorrow’s Personalization Today: Increase User Engagement with Content in Co...
Tomorrow’s Personalization Today: Increase User Engagement with Content in Co...
Acquia
 
Acquia Content Hub: Connect Technologies & Extend Systems to Source Content
Acquia Content Hub: Connect Technologies & Extend Systems to Source Content
Acquia
 
Acquia Partner Program Update
Acquia Partner Program Update
Acquia
 
Customer Journey Orchestration: The Secret to Effective Omnichannel Experiences
Customer Journey Orchestration: The Secret to Effective Omnichannel Experiences
Acquia
 
Personalization How-To: Driving Conversions with Acquia Lift
Personalization How-To: Driving Conversions with Acquia Lift
Acquia
 
Build Personalization into Your Culture: Create Engaging Experiences for Ever...
Build Personalization into Your Culture: Create Engaging Experiences for Ever...
Acquia
 
A Professional Software Engineer's Checklist
A Professional Software Engineer's Checklist
Acquia
 
Webinar: Vodafone and The Connected Customer Journey [10.19.2017]
Webinar: Vodafone and The Connected Customer Journey [10.19.2017]
Acquia
 
How to Use the Salesforce Suite with Drupal 8: A Quick Start Guide
How to Use the Salesforce Suite with Drupal 8: A Quick Start Guide
Acquia
 
Lightning Distribution for Drupal: Build Advanced Authoring Experiences in Dr...
Lightning Distribution for Drupal: Build Advanced Authoring Experiences in Dr...
Acquia
 
Building a foundation for the future of digital experience (oct 31, 2017)
Building a foundation for the future of digital experience (oct 31, 2017)
Acquia
 
Webinar : Acquia Lift for a optimized and personalized user experience
Webinar : Acquia Lift for a optimized and personalized user experience
Cyril Reinhard
 
アステラス製薬 - グローバルWebブランディングとガバナンス [動画あり]
アステラス製薬 - グローバルWebブランディングとガバナンス [動画あり]
CI&T Japan
 
Questions To Ask Before a Drupal Project Kickoff
Questions To Ask Before a Drupal Project Kickoff
Acquia
 
Episode 5: Using Technology to Accelerate Your Personalization Initiative
Episode 5: Using Technology to Accelerate Your Personalization Initiative
Acquia
 
A Crash Course in Building Site Reliability
A Crash Course in Building Site Reliability
Acquia
 
Drupal 8 Lessons From the Field: What is Continuous Delivery and Why it’s imp...
Drupal 8 Lessons From the Field: What is Continuous Delivery and Why it’s imp...
Acquia
 
Episode 2: Define Customer Segments Using a Data-driven Approach
Episode 2: Define Customer Segments Using a Data-driven Approach
Acquia
 
Tomorrow’s Personalization Today: Increase User Engagement with Content in Co...
Tomorrow’s Personalization Today: Increase User Engagement with Content in Co...
Acquia
 
Acquia Content Hub: Connect Technologies & Extend Systems to Source Content
Acquia Content Hub: Connect Technologies & Extend Systems to Source Content
Acquia
 
Acquia Partner Program Update
Acquia Partner Program Update
Acquia
 
Customer Journey Orchestration: The Secret to Effective Omnichannel Experiences
Customer Journey Orchestration: The Secret to Effective Omnichannel Experiences
Acquia
 
Personalization How-To: Driving Conversions with Acquia Lift
Personalization How-To: Driving Conversions with Acquia Lift
Acquia
 
Build Personalization into Your Culture: Create Engaging Experiences for Ever...
Build Personalization into Your Culture: Create Engaging Experiences for Ever...
Acquia
 
A Professional Software Engineer's Checklist
A Professional Software Engineer's Checklist
Acquia
 
Webinar: Vodafone and The Connected Customer Journey [10.19.2017]
Webinar: Vodafone and The Connected Customer Journey [10.19.2017]
Acquia
 
How to Use the Salesforce Suite with Drupal 8: A Quick Start Guide
How to Use the Salesforce Suite with Drupal 8: A Quick Start Guide
Acquia
 
Lightning Distribution for Drupal: Build Advanced Authoring Experiences in Dr...
Lightning Distribution for Drupal: Build Advanced Authoring Experiences in Dr...
Acquia
 
Building a foundation for the future of digital experience (oct 31, 2017)
Building a foundation for the future of digital experience (oct 31, 2017)
Acquia
 
Webinar : Acquia Lift for a optimized and personalized user experience
Webinar : Acquia Lift for a optimized and personalized user experience
Cyril Reinhard
 
アステラス製薬 - グローバルWebブランディングとガバナンス [動画あり]
アステラス製薬 - グローバルWebブランディングとガバナンス [動画あり]
CI&T Japan
 

Similar to PHP Performance tuning for Drupal 8 (20)

Performance and Scalability
Performance and Scalability
Mediacurrent
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve Internet
Achieve Internet
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve Internet
Achieve Internet
 
Drupal performance
Drupal performance
Piyuesh Kumar
 
Caching
Caching
Aaron Scherer
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talk
Bryan Ollendyke
 
Jeff Rigby on Scaling Drupal in the Enterprise
Jeff Rigby on Scaling Drupal in the Enterprise
Joe Bachana
 
High Performance Drupal
High Performance Drupal
Chapter Three
 
Improving Website Performance and Scalability with Memcached
Improving Website Performance and Scalability with Memcached
Acquia
 
Drupal 7 performance and optimization
Drupal 7 performance and optimization
Shafqat Hussain
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalability
Wim Godden
 
DrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an Afterthought
Nick Santamaria
 
Drupal7 MEMCACHE
Drupal7 MEMCACHE
Pankaj Chauhan
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorial
Wim Godden
 
2013 - Dustin whittle - Escalando PHP en la vida real
2013 - Dustin whittle - Escalando PHP en la vida real
PHP Conference Argentina
 
Bottom to Top Stack Optimization with LAMP
Bottom to Top Stack Optimization with LAMP
katzgrau
 
Bottom to Top Stack Optimization - CICON2011
Bottom to Top Stack Optimization - CICON2011
CodeIgniter Conference
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalability
Wim Godden
 
Caching Strategies for Scaling Drupal: Common Missteps vs Best Practices
Caching Strategies for Scaling Drupal: Common Missteps vs Best Practices
Acquia
 
Drupal performance and scalability
Drupal performance and scalability
Twinbit
 
Performance and Scalability
Performance and Scalability
Mediacurrent
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve Internet
Achieve Internet
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve Internet
Achieve Internet
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talk
Bryan Ollendyke
 
Jeff Rigby on Scaling Drupal in the Enterprise
Jeff Rigby on Scaling Drupal in the Enterprise
Joe Bachana
 
High Performance Drupal
High Performance Drupal
Chapter Three
 
Improving Website Performance and Scalability with Memcached
Improving Website Performance and Scalability with Memcached
Acquia
 
Drupal 7 performance and optimization
Drupal 7 performance and optimization
Shafqat Hussain
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalability
Wim Godden
 
DrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an Afterthought
Nick Santamaria
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorial
Wim Godden
 
2013 - Dustin whittle - Escalando PHP en la vida real
2013 - Dustin whittle - Escalando PHP en la vida real
PHP Conference Argentina
 
Bottom to Top Stack Optimization with LAMP
Bottom to Top Stack Optimization with LAMP
katzgrau
 
Bottom to Top Stack Optimization - CICON2011
Bottom to Top Stack Optimization - CICON2011
CodeIgniter Conference
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalability
Wim Godden
 
Caching Strategies for Scaling Drupal: Common Missteps vs Best Practices
Caching Strategies for Scaling Drupal: Common Missteps vs Best Practices
Acquia
 
Drupal performance and scalability
Drupal performance and scalability
Twinbit
 
Ad

More from Acquia (20)

Acquia_Adcetera Webinar_Marketing Automation.pdf
Acquia_Adcetera Webinar_Marketing Automation.pdf
Acquia
 
Acquia Webinar Deck - 9_13 .pdf
Acquia Webinar Deck - 9_13 .pdf
Acquia
 
Taking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next Level
Acquia
 
CDP for Retail Webinar with Appnovation - Q2 2022.pdf
CDP for Retail Webinar with Appnovation - Q2 2022.pdf
Acquia
 
May Partner Bootcamp 2022
May Partner Bootcamp 2022
Acquia
 
April Partner Bootcamp 2022
April Partner Bootcamp 2022
Acquia
 
How to Unify Brand Experience: A Hootsuite Story
How to Unify Brand Experience: A Hootsuite Story
Acquia
 
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Acquia
 
Improve Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Improve Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Acquia
 
September Partner Bootcamp
September Partner Bootcamp
Acquia
 
August partner bootcamp
August partner bootcamp
Acquia
 
July 2021 Partner Bootcamp
July 2021 Partner Bootcamp
Acquia
 
May Partner Bootcamp
May Partner Bootcamp
Acquia
 
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
Acquia
 
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Acquia
 
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia
 
April partner bootcamp deck cookieless future
April partner bootcamp deck cookieless future
Acquia
 
How to enhance cx through personalised, automated solutions
How to enhance cx through personalised, automated solutions
Acquia
 
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
Acquia
 
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Acquia
 
Acquia_Adcetera Webinar_Marketing Automation.pdf
Acquia_Adcetera Webinar_Marketing Automation.pdf
Acquia
 
Acquia Webinar Deck - 9_13 .pdf
Acquia Webinar Deck - 9_13 .pdf
Acquia
 
Taking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next Level
Acquia
 
CDP for Retail Webinar with Appnovation - Q2 2022.pdf
CDP for Retail Webinar with Appnovation - Q2 2022.pdf
Acquia
 
May Partner Bootcamp 2022
May Partner Bootcamp 2022
Acquia
 
April Partner Bootcamp 2022
April Partner Bootcamp 2022
Acquia
 
How to Unify Brand Experience: A Hootsuite Story
How to Unify Brand Experience: A Hootsuite Story
Acquia
 
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Acquia
 
Improve Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Improve Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Acquia
 
September Partner Bootcamp
September Partner Bootcamp
Acquia
 
August partner bootcamp
August partner bootcamp
Acquia
 
July 2021 Partner Bootcamp
July 2021 Partner Bootcamp
Acquia
 
May Partner Bootcamp
May Partner Bootcamp
Acquia
 
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
Acquia
 
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Acquia
 
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia
 
April partner bootcamp deck cookieless future
April partner bootcamp deck cookieless future
Acquia
 
How to enhance cx through personalised, automated solutions
How to enhance cx through personalised, automated solutions
Acquia
 
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
Acquia
 
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Acquia
 
Ad

Recently uploaded (20)

cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 

PHP Performance tuning for Drupal 8

  • 1. ©2016 Acquia Inc. — Confidential and Proprietary Erin Rasmussen, Support Engineer, Acquia PHP Performance Tuning for Drupal 8
  • 2. ©2016 Acquia Inc. — Confidential and Proprietary Make that Drupal 8 site fly!! – Brief glance over Best Practices for Performance Tuning. – PHP tuning including Opcache, Interned strings and apcu – Varnish, Memcache, and Database tips – The Software Stack, with Drupal 8 integration tips.
  • 3. ©2016 Acquia Inc. — Confidential and Proprietary Mitigate against Failure by planning for Success!! – Test, test and then Test again! (Include Load & Security Testing!) – Performance Review is Key: Understand the factors that Affect your Site’s Performance – Incorporate these strategies in your Continuous Improvement Process We want your project to succeed as much as you do!
  • 4. ©2016 Acquia Inc. — Confidential and Proprietary This is an example stack, there are multiple ways configure them, your software may be different. Note: Development environments are almost always Different than Production environments. Know the Stack, Love the Stack Balancer / Varnish Memcached Apache PHP/FPM MySQL File System Code Repo
  • 5. ©2016 Acquia Inc. — Confidential and Proprietary Multi-Tier, the Stack gets bigger With multi-tier, these the software stack can be split among server instances. With redundancy and failover. Balancer / Varnish Balancer / Varnish Memcached Apache PHP/FPM Apache PHP/FPM MySQL & File System MySQL & File System Code Repo Server AMI Type #Cores Date Time 1m 5m 15m bal-1*5*8 m3.2xlarge 8 2017-02-20 00:08:21 0.00 0.03 0.08 bal-1*5*9 m3.2xlarge 8 2017-02-20 00:08:22 0.33 0.29 0.25 web-18**7 c3.large 2 2017-02-20 00:08:21 0.02 0.03 0.05 web-18**8 c3.large 2 2017-02-20 00:08:21 0.00 0.01 0.05 fsdb-1**25 c3.large 2 2017-02-20 00:08:22 0.07 0.05 0.05 fsdb-1**26 c3.large 2 2017-02-20 00:08:23 0.03 0.04 0.05
  • 6. ©2016 Acquia Inc. — Confidential and Proprietary Balancers / Caching a short intro Drupal 7, has URL-based page caching and empties the page cache for every edited piece of content! 2009-2011 Varnish wasn’t widely used, so Drupal 7 caches pages, but doesn’t invalidate them intelligently. Cache-Control = public, max-age=300 Works great – until there’s a DDOS or back-end server issue Cache-Control = public, max-age=31536000 Works great – until content updates aren’t reflected on the site.
  • 7. ©2016 Acquia Inc. — Confidential and Proprietary Drupal 8 Caching is re-architected • Has a proper internal cache API, allows tagging of cache items. • Each single item is described with tags. Tags "bubble" up to all rendering parents. These tags are stored in the cache API. Cache::invalidateTags(["tag"]) CacheTagsListenersInterface The content API's call ::invalidateTags(). The render and page caches are transparently invalidated.
  • 8. ©2016 Acquia Inc. — Confidential and Proprietary Varnish https://varnish-cache.org Support for Drupal 8 Cache Tags with Varnish Acquia Purge for Drupal 8 is a fully-featured API and you plug in a 'purger' to it, to support your CDN
  • 9. ©2016 Acquia Inc. — Confidential and Proprietary PHP / FPM http://php.net https://php-fpm.org – Memory Limits – Max Execution Time – Zend OPcache – APC user cache – Memory Allocation Math
  • 10. ©2016 Acquia Inc. — Confidential and Proprietary PHP Memory Limit http://php.net/manual/en/ini.core.php#ini.memory- limit The PHP memory_limit is the maximum number of M (in integers) that a single PHP/FPM proc can consume, by default memory_limit =128M Clear signs this is set too low: – php-errors.log: [20-Feb-2017 19:26:10 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 15990062 bytes) in docroot/includes/database/database.inc on line 2227 – PHP WSOD errors or “Temporarily Unavailable” errors.
  • 11. ©2016 Acquia Inc. — Confidential and Proprietary Max Execution Time http://php.net/manual/en/features.connection-handling.php The amount of time a single PHP process can run (in seconds) max_execution_time – Resolve this problems by identifying slow processes and resolving the request or set_time_limit() function. Clear signs that your processes are taking too long –fpm-error.log max_children errors –White Screen of Death (Temporary Unavailable) errors.
  • 12. ©2016 Acquia Inc. — Confidential and Proprietary OPcache (opcode cache) http://php.net/manual/en/intro.opcache.php Caches pre-compiled bytecode. Faster than using PHP of load & parse each script for each & every HTTP request. key variable: opcache.memory_consumption(128M) Needs to be large enough to store compiled code for your applications PHP scripts Clear sign that this is too small: – php-errors.log Warning: require_once() [function.require-once]: Unable to allocate memory for pool. OPcache Status monitor: https://github.com/rlerdorf/opcache-status
  • 13. ©2016 Acquia Inc. — Confidential and Proprietary OPcache http://php.net/manual/en/book.opcache.php Interned Strings - the amount of memory (M) used to store identical strings (detected by PHP). By default this is a shared buffer allowing all Drupal PHP processes to reference it across multiple PHP/FPM procs - saving memory. Clear sign that this is set too low: – Fpm-error.log: Warning Interned string buffer overflow More indepth information: http://jpauli.github.io/2015/03/05/opcache.html
  • 14. ©2016 Acquia Inc. — Confidential and Proprietary APC User Cache http://php.net/manual/en/intro.apcu.php APC User cache is PHP APC minus OPcache, rarely used in Drupal 7 (apc.shm_size= 8M is ok), increase for Drupal 8 (apc.shm_size=16 or 32M) Clear sign that the APC User cache is set too small: – In php-errors.log : [20-Feb-2017 13:54:16 America/New_York] PHP Warning: apcu_store(): Unable to allocate memory for pool. in /mnt/www/html/somenamedev/docroot/core/lib/Drupal/Core/Cache/ApcuBackend.php on line 177 Get usage Details!: use apc.php script in the docroot and view in your browser: note: the charts are less accurate than the text
  • 15. ©2016 Acquia Inc. — Confidential and Proprietary APC User Cache Drupal 8.3 will reduce the amount stored in APC user cache in response to community issues: – Rationalize use of the 'discovery' cache bin, since it's stored in the limited size APCu by default https://www.drupal.org/node/2765271 – Change ViewsData to use the default cache bin instead of discovery https://www.drupal.org/node/2824547
  • 16. ©2016 Acquia Inc. — Confidential and Proprietary PHP Procs and PHP Memory Math Total RAM 3860 OS 50 MySQL 1930 Memcache 64 Sites 4 Sitename Memory Limit Opcache APCu FPM d7sitedev 256 128 8 1 d7sitestg 256 128 8 1 d8sitedev 128 96 16 1 d8sitestg 128 96 16 1 Calculate the available memory for PHP (Total - OS - MySQL -Memcache ) Memory use by 1 Process: – Use top – memory_get_peak_usage() – Devel (Drupal 7 & 8) Calculate how many procs you can afford.
  • 17. ©2016 Acquia Inc. — Confidential and Proprietary PHP/FPM max_children errors When there are more incoming requests than PHP/FPM can handle you get max_children errors. Clear sign that the site is exhausting PHP/FPM procs: – fpm-error.log srv-**35m notice [22-Feb-2017 16:32:38] WARNING: [pool someuser] server reached max_children setting (27), consider raising it. Causes are Varied – Large amount of HTTP traffic, PHP/FPM procs that are looping, or not terminating effectively. Or calls to External Services hanging/timing out
  • 18. ©2016 Acquia Inc. — Confidential and Proprietary Adding the Impact of Traffic What happens when the new site launches – or it gets retweeted a million times:
  • 19. ©2016 Acquia Inc. — Confidential and Proprietary What’s in that Traffic?
  • 20. ©2016 Acquia Inc. — Confidential and Proprietary Memcached https://memcached.org Is a open source, high-performance, distributed memory object caching system Drupal 8 Memcache Module is Alpha https://www.drupal.org/project/memcache The Drupal 8 module will make GETS and SETS with properly configured Memcached, and supports key_prefixing. However, Memcached slabs are not encrypted by default Community Development is needed for a Stable Release of the Memcahed Drupal modue
  • 21. ©2016 Acquia Inc. — Confidential and Proprietary Keep the Database Layer Happy – Enable Syslog, disable database Watchdog Logging. – Caching to the Database does not always Scale, keep an eye on your capacity and I/O errors. – Optimize queries, and keep an eye on database tables. Even the most efficient Views query will be slow on a 50 Gb table.
  • 22. ©2016 Acquia Inc. — Confidential and Proprietary Keep the Front End Performant – Compress Site Images, PDFs and other Files before uploading them to the site. (Even a cached 7MB photo is a major performance hog when used 27 times on a site.) – Compress your CSS, and minify your JS. – Keep an eye on External calls. Use timeouts, and allow your application to fail gracefully when those resources cannot be reached.
  • 23. ©2016 Acquia Inc. — Confidential and Proprietary Thank you!  Drupal ✩ Modern PHP: New Features and Good Practices by Josh Lockhart http://shop.oreilly.com/product/0636920033868.do ✩ Drupal 8 Cache API https://www.drupal.org/docs/8/api/cache-api/cache- api ✩ Acquia Purge https://www.drupal.org/project/acquia_purge ✩ Drupal’s PHP requirements https://www.drupal.org/docs/7/system- requirements/php