SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
Scaling WordPress
Handling the bittersweet pain of success
All the photos used are from Unsplash
Principal Software Engineer, Telenor Health
Anam Ahmed
@theanam
Efficient Use of existing
Resources
When and how
To increase resource
Finding points of improvement
Static Resources
HTTP/2
Decreases & Compresses
Headers
Decreases the amount
Of open connection.
Reduces to 1
Server can push
Necessary files
beforehand
Fully Backward
Compatible
You should really go HTTP/2 because
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
root /path/to/public;
ssl_certificate /path/to/certificate.crt;
ssl_certificate_key /path/to/private.key;
ssl_protocols TLSv1.2;
}
Enabling HTTP/2 in Nginx
Enabling HTTP/2 in Apache
Step 1 : Enable HTTP/2 Module in Apache
Sudo a2enmod http2
sudo apachectl restart
Step 2 : Configure The web server to use HTTP2
<VirtualHost *:443>
Protocols h2 http/1.1
ServerAdmin you@your-awesome-site.com
ServerName your-awesome-site.com
...
</VirtualHost>
Facts
• Most CDN and Specialized File cloud comes with HTTP/2 pre enabled
like, Amazon S3, google Cloud Storage and most others have option to
enable it. 

• HTTP/2 must be served over HTTPS. Otherwise most browsers will ignore
it.

• HTTP/2 will not fix your bad code.
Compression
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
gzip on;
gzip_disable “msie6”;
gzip_proxied any;
server_name example.com;
root /path/to/public;
ssl_certificate /path/to/certificate.crt;
ssl_certificate_key /path/to/private.key;
ssl_protocols TLSv1.2;
}
Enabling gzip Compression in Nginx
Enabling gzip in Apache
Step 1 : Enable deflate Module in Apache
Sudo a2enmod deflate
sudo apachectl restart
Step 2 : Configure The web server to use gzip compression
<Directory /var/www/html/>
<IfModule mod_mime.c>
AddType application/x-javascript .js
AddType text/css .css
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/plain text/xml application/
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
</IfModule>
</IfModule>
Header append Vary User-Agent env=!dont-vary
</Directory>
[Too Big for the slide]
Help your browser cache better
Send proper cache-control headers
Cache-Control on nginx
location ~* .(?:manifest|appcache|html?|xml|json)$ {
expires -1;
}
# Media: images, icons, video, audio, HTC
location ~* .(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* .(?:css|js)$ {
expires 1y;
add_header Cache-Control "public";
}
Apache?
You already know the drill
What else can we do?
Google PageSpeed module ✨
Small Things matter
• Use SVG for logo and icons (Avoid icon fonts if not needed)

• Use JPG images instead of png. JPG has a better compression

• Use a CSS processor to clean up your CSS file
Where to measure progress?
Google Pagespeed Insight
What does performance have to
do with Scaling?
If your web application is efficient
You’ll be able to serve more users
With the same resource.
- It’s true but nobody quoted it
Dynamic Contents
Let’s Dockerize 🐳
What’s the Advantage?
• Easy to spawn multiple instances

• Easy to shift

• Easy to update core

• Easy to develop

• Easy to deploy
Official WordPress Docker Image
Before we start, Let’s think like
Docker 🚀
• WordPress application

• PHP

• All required PHP extensions

• Web Server (In many cases)

• Default Plugins and themes
• A database

• A way to add own plugin and themes

• A way to back up/keep all the file changes

• A way to access WordPress from outside

• This point is here to fix alignment in slide.
What’s Available? What else do we need?
Introducing Docker Compose
Image with Tag
For Themes and plugins
Localhost:8080
Database Settings
Name of the database service
Service for the Database, Mysql
Persistent data in database
Docker-compose up -d
Grab a cup of ☕ while it finishes its work
http://localhost:8080
All the default themes
and plugins will be
automatically
populated in the
folders we created
http://bit.ly/wordcamp-compose
So, How do we scale with
Docker?
With These tools
Or simply by adding multiple
services with Compose
Things to remember
• Use cloud native solutions if possible, for example if you are using AWS or
GCP, use their database solution. That’s much easier to scale.

• Use Sticky Session (IP hash) for load balancers, Otherwise PHP session
will be lost

• It’s better to create many smaller instances rather than one gigantic
instance. It will be less prone to failure
There’s A lot to talk about
Scaling
But Maybe some other day.
Thank you.

Contenu connexe

Tendances

High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
vnsavage
 
ServerBeach and WordPress BlogWorldExpo 2007
ServerBeach and WordPress BlogWorldExpo 2007ServerBeach and WordPress BlogWorldExpo 2007
ServerBeach and WordPress BlogWorldExpo 2007
Barry Abrahamson
 

Tendances (20)

Speed Up WordPress Websites - Part 1 - WordPress Cairo Meetup
Speed Up WordPress Websites - Part 1 - WordPress Cairo MeetupSpeed Up WordPress Websites - Part 1 - WordPress Cairo Meetup
Speed Up WordPress Websites - Part 1 - WordPress Cairo Meetup
 
Adobe CQ5 for Developers - Introduction
Adobe CQ5 for Developers - IntroductionAdobe CQ5 for Developers - Introduction
Adobe CQ5 for Developers - Introduction
 
Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notes
 
Introdcution to Adobe CQ
Introdcution to Adobe CQIntrodcution to Adobe CQ
Introdcution to Adobe CQ
 
WordPress Meetup 17th Oct, 2015 at TechHub (ASTP) Lahore, Pakistan
WordPress Meetup 17th Oct, 2015 at TechHub (ASTP) Lahore, PakistanWordPress Meetup 17th Oct, 2015 at TechHub (ASTP) Lahore, Pakistan
WordPress Meetup 17th Oct, 2015 at TechHub (ASTP) Lahore, Pakistan
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on Steroids
 
High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APC
 
High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
 
High Performance WordPress II
High Performance WordPress IIHigh Performance WordPress II
High Performance WordPress II
 
ServerBeach and WordPress BlogWorldExpo 2007
ServerBeach and WordPress BlogWorldExpo 2007ServerBeach and WordPress BlogWorldExpo 2007
ServerBeach and WordPress BlogWorldExpo 2007
 
How to cache your static resources
How to cache your static resourcesHow to cache your static resources
How to cache your static resources
 
Reducing latency on the web with the Azure CDN - DevSum - SWAG
Reducing latency on the web with the Azure CDN - DevSum - SWAGReducing latency on the web with the Azure CDN - DevSum - SWAG
Reducing latency on the web with the Azure CDN - DevSum - SWAG
 
Scale Apache with Nginx
Scale Apache with NginxScale Apache with Nginx
Scale Apache with Nginx
 
Reducing latency on the web with the Azure CDN- TechDays NL 2014
Reducing latency on the web with the Azure CDN- TechDays NL 2014Reducing latency on the web with the Azure CDN- TechDays NL 2014
Reducing latency on the web with the Azure CDN- TechDays NL 2014
 
Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!
 
How to reduce database load using Memcache
How to reduce database load using MemcacheHow to reduce database load using Memcache
How to reduce database load using Memcache
 
Sofia WP User Group Presentation
Sofia WP User Group PresentationSofia WP User Group Presentation
Sofia WP User Group Presentation
 
Scalable talk notes
Scalable talk notesScalable talk notes
Scalable talk notes
 
Web agencies: An analysis of the OVH infrastructure to optimise your web proj...
Web agencies: An analysis of the OVH infrastructure to optimise your web proj...Web agencies: An analysis of the OVH infrastructure to optimise your web proj...
Web agencies: An analysis of the OVH infrastructure to optimise your web proj...
 

Similaire à WordPress At Scale. WordCamp Dhaka 2019

LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
Luis Rodríguez Castromil
 
How to? Drupal developer toolkit. Dennis Povshedny.
How to? Drupal developer toolkit. Dennis Povshedny.How to? Drupal developer toolkit. Dennis Povshedny.
How to? Drupal developer toolkit. Dennis Povshedny.
DrupalCampDN
 

Similaire à WordPress At Scale. WordCamp Dhaka 2019 (20)

Caching 101
Caching 101Caching 101
Caching 101
 
Rock Solid WordPress
Rock Solid WordPressRock Solid WordPress
Rock Solid WordPress
 
Performance and Scalability
Performance and ScalabilityPerformance and Scalability
Performance and Scalability
 
Using MAMP for Web Development
Using MAMP for Web DevelopmentUsing MAMP for Web Development
Using MAMP for Web Development
 
Drupal performance optimization Best Practices
Drupal performance optimization Best PracticesDrupal performance optimization Best Practices
Drupal performance optimization Best Practices
 
Optimize wordpress
Optimize wordpressOptimize wordpress
Optimize wordpress
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
How to? Drupal developer toolkit. Dennis Povshedny.
How to? Drupal developer toolkit. Dennis Povshedny.How to? Drupal developer toolkit. Dennis Povshedny.
How to? Drupal developer toolkit. Dennis Povshedny.
 
AEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser CachingAEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser Caching
 
WordPress MU 101
WordPress MU 101WordPress MU 101
WordPress MU 101
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax Applications
 
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101
 
Drupal 7x Installation - Introduction to Drupal Concepts
Drupal 7x Installation - Introduction to Drupal ConceptsDrupal 7x Installation - Introduction to Drupal Concepts
Drupal 7x Installation - Introduction to Drupal Concepts
 
Drupal development
Drupal development Drupal development
Drupal development
 
I Can Haz More Performanz?
I Can Haz More Performanz?I Can Haz More Performanz?
I Can Haz More Performanz?
 
Drupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case StudyDrupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case Study
 
Mastering WordPress Vol.1
Mastering WordPress Vol.1Mastering WordPress Vol.1
Mastering WordPress Vol.1
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 

WordPress At Scale. WordCamp Dhaka 2019

  • 1. Scaling WordPress Handling the bittersweet pain of success All the photos used are from Unsplash
  • 2. Principal Software Engineer, Telenor Health Anam Ahmed @theanam
  • 3. Efficient Use of existing Resources When and how To increase resource
  • 4. Finding points of improvement
  • 7. Decreases & Compresses Headers Decreases the amount Of open connection. Reduces to 1 Server can push Necessary files beforehand Fully Backward Compatible You should really go HTTP/2 because
  • 8. server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name example.com; root /path/to/public; ssl_certificate /path/to/certificate.crt; ssl_certificate_key /path/to/private.key; ssl_protocols TLSv1.2; } Enabling HTTP/2 in Nginx
  • 9. Enabling HTTP/2 in Apache Step 1 : Enable HTTP/2 Module in Apache Sudo a2enmod http2 sudo apachectl restart Step 2 : Configure The web server to use HTTP2 <VirtualHost *:443> Protocols h2 http/1.1 ServerAdmin you@your-awesome-site.com ServerName your-awesome-site.com ... </VirtualHost>
  • 10. Facts • Most CDN and Specialized File cloud comes with HTTP/2 pre enabled like, Amazon S3, google Cloud Storage and most others have option to enable it. • HTTP/2 must be served over HTTPS. Otherwise most browsers will ignore it. • HTTP/2 will not fix your bad code.
  • 12. server { listen 443 ssl http2; listen [::]:443 ssl http2; gzip on; gzip_disable “msie6”; gzip_proxied any; server_name example.com; root /path/to/public; ssl_certificate /path/to/certificate.crt; ssl_certificate_key /path/to/private.key; ssl_protocols TLSv1.2; } Enabling gzip Compression in Nginx
  • 13. Enabling gzip in Apache Step 1 : Enable deflate Module in Apache Sudo a2enmod deflate sudo apachectl restart Step 2 : Configure The web server to use gzip compression <Directory /var/www/html/> <IfModule mod_mime.c> AddType application/x-javascript .js AddType text/css .css </IfModule> <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/plain text/xml application/ <IfModule mod_setenvif.c> BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4.0[678] no-gzip BrowserMatch bMSIE !no-gzip !gzip-only-text/html </IfModule> </IfModule> Header append Vary User-Agent env=!dont-vary </Directory> [Too Big for the slide]
  • 14. Help your browser cache better Send proper cache-control headers
  • 15. Cache-Control on nginx location ~* .(?:manifest|appcache|html?|xml|json)$ { expires -1; } # Media: images, icons, video, audio, HTC location ~* .(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { expires 1M; add_header Cache-Control "public"; } # CSS and Javascript location ~* .(?:css|js)$ { expires 1y; add_header Cache-Control "public"; }
  • 17. What else can we do?
  • 19. Small Things matter • Use SVG for logo and icons (Avoid icon fonts if not needed) • Use JPG images instead of png. JPG has a better compression • Use a CSS processor to clean up your CSS file
  • 20. Where to measure progress?
  • 22.
  • 23.
  • 24.
  • 25. What does performance have to do with Scaling?
  • 26. If your web application is efficient You’ll be able to serve more users With the same resource. - It’s true but nobody quoted it
  • 29. What’s the Advantage? • Easy to spawn multiple instances • Easy to shift • Easy to update core • Easy to develop • Easy to deploy
  • 31. Before we start, Let’s think like Docker 🚀
  • 32. • WordPress application • PHP • All required PHP extensions • Web Server (In many cases) • Default Plugins and themes • A database • A way to add own plugin and themes • A way to back up/keep all the file changes • A way to access WordPress from outside • This point is here to fix alignment in slide. What’s Available? What else do we need?
  • 34. Image with Tag For Themes and plugins Localhost:8080 Database Settings Name of the database service Service for the Database, Mysql Persistent data in database
  • 35. Docker-compose up -d Grab a cup of ☕ while it finishes its work
  • 37. All the default themes and plugins will be automatically populated in the folders we created
  • 39. So, How do we scale with Docker?
  • 41. Or simply by adding multiple services with Compose
  • 42. Things to remember • Use cloud native solutions if possible, for example if you are using AWS or GCP, use their database solution. That’s much easier to scale. • Use Sticky Session (IP hash) for load balancers, Otherwise PHP session will be lost • It’s better to create many smaller instances rather than one gigantic instance. It will be less prone to failure
  • 43. There’s A lot to talk about Scaling
  • 44. But Maybe some other day.