SlideShare a Scribd company logo
Maximizing Drupal 8
Performance with
NGINX
Wednesday, 20 January 2016
MORE INFORMATION AT
NGINX.COM
Your Questions
1. Who are we?
● Floyd Smith, Technical Marketing Writer. Author of NGINX blog post, “8 Tips for Drupal 8
Performance”.
● Faisal Memon, Product Marketer
2. What’s new in Drupal 8?
3. How can I implement a high-performance site?
4. How do NGINX and NGINX Plus fit into my efforts?
MORE INFORMATION AT
NGINX.COM
Agenda
● What’s New in Drupal 8
● Planning Site Architecture
● Replacing Your Web Server
● Drupal Specifics
- Drupal 8 Configuration
● Caching
- Why cache with NGINX?
- Microcaching
- Cache Purging with NGINX Plus
● Reverse Proxy Server
- Load Balancing
- Session Persistence
- Bonus: SSL/TLS and HTTP/2
● Questions?
MORE INFORMATION AT
NGINX.COM
What’s New in Drupal 8
1. Mobile improvements. Full support for mobile site templates and easy backend
administration from a mobile device.
2. Data and presentation layer uncoupling. The Drupal API is now fully RESTful, making it
easier to use with Angular.js, Ember.js, and other client-side content extraction and display
tools.
3. Support for Symfony2. Symfony 2 is an up-to-date, object-oriented PHP framework, well
known for customer relationship management (CRM) integration.
4. Twig support. Twig is a frontend library and template engine that eliminates some
disadvantages of pure PHP while embracing the latest PHP standards.
5. Security improvements. New features offer additional ways to make systems more secure.
MORE INFORMATION AT
NGINX.COM
Agenda
● What’s New in Drupal 8
● Planning Site Architecture
● Replacing Your Web Server
● Drupal Specifics
- Drupal 8 Configuration
● Caching
- Why cache with NGINX?
- Microcaching
- Cache Purging with NGINX Plus
● Reverse Proxy Server
- Load Balancing
- Session Persistence
- Bonus: SSL/TLS and HTTP/2
● Questions?
MORE INFORMATION AT
NGINX.COM
Planning Your Site Architecture
1. Current architecture. Evaluate your current site traffic and performance.
2. Goals. Immediate problems, future growth
3. Estimate impact of changes. Open source NGINX or NGINX Plus as web server, reverse
proxy server, load balancer, more.
4. Plan for growth. Estimate likely and possible growth and speed of growth.
5. Factor in the cloud. Use cloud from scratch, expand into the cloud, move into the cloud.
MORE INFORMATION AT
NGINX.COM
Agenda
● What’s New in Drupal 8
● Planning Site Architecture
● Replacing Your Web Server
● Drupal Specifics
- Drupal 8 Configuration
● Caching
- Why cache with NGINX?
- Microcaching
- Cache Purging with NGINX Plus
● Reverse Proxy Server
- Load Balancing
- Session Persistence
- Bonus: SSL/TLS and HTTP/2
● Questions?
MORE INFORMATION AT
NGINX.COM
Replacing Your Web Server
1. Replace Apache with NGINX or NGINX Plus. Immediate performance fix. Enables caching
for static and dynamic content. (More on this soon.) Does not enable multiple app servers.
2. More performance on same hardware. Event loop replaces thread-per-connection, solves
C10K problem.
3. Requires new server configuration. Replace
familiar Apache configuration with tighter, more
efficient (IMHO) NGINX configuration.
4. Independent of NGINX as reverse proxy
server. You can use NGINX as a reverse
proxy server with or without using NGINX as your web server; very flexible.
MORE INFORMATION AT
NGINX.COM
Agenda
● What’s New in Drupal 8
● Planning Site Architecture
● Replacing Your Web Server
● Drupal Specifics
- Drupal 8 Configuration
● Caching
- Why cache with NGINX?
- Microcaching
- Cache Purging with NGINX Plus
● Reverse Proxy Server
- Load Balancing
- Session Persistence
- Bonus: SSL/TLS and HTTP/2
● Questions?
MORE INFORMATION AT
NGINX.COM
NGINX configuration for Drupal
• Minor changes to nginx.conf for Drupal 8
• Mostly related to update.php front controller
• Sample configuration available on NGINX wiki
• https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/
MORE INFORMATION AT
NGINX.COM
Change #1: Accommodating update.php front controller
location ~ '.php$ {
...
}
location ~ '.php$|^/update.php' {
...
}
• To accommodate URIs such as: /update.php/selection
• Without this change NGINX will return a 404 error
• Less strict (and more future proof) alternative:
• Will match (and break) legacy Drupal URIs such as /blog/index.php/legacy
location ~ '.php$(/|$) {
MORE INFORMATION AT
NGINX.COM
Change #2: Non-greedy match
fastcgi_split_path_info ^(.+.php)(.*)$; fastcgi_split_path_info ^(.+?.php)(|/.*)$;
• To accommodate URIs such as: /core/authorize.php/core/authorize.php
• Without this change NGINX will return a 404 error
• Greedy match (left side) means entire URI will be SCRIPT_FILENAME
• Non-greedy match (right side) means first authorize.php will be matched
MORE INFORMATION AT
NGINX.COM
Change #3: Default location
location / {
try_files $uri @rewrite;
}
location /{
try_files $uri /index.php?$query_string;
}
• Change was made for Drupal 7
• Older version can cause query string to be altered
MORE INFORMATION AT
NGINX.COM
Agenda
● What’s New in Drupal 8
● Planning Site Architecture
● Replacing Your Web Server
● Drupal Specifics
- Drupal 8 Configuration
● Caching
- Why cache with NGINX?
- Microcaching
- Cache Purging with NGINX Plus
● Reverse Proxy Server
- Load Balancing
- Session Persistence
- Bonus: SSL/TLS and HTTP/2
● Conclusion
● Questions?
MORE INFORMATION AT
NGINX.COM
Why Cache with NGINX?
Source: http://bbc.in/1O8qHbi
MORE INFORMATION AT
NGINX.COM
Microcaching with NGINX
• Cache content for a short time, as little as 1 second
• Site content is out of date for max 1 second
• Significant performance gains even for that short of a time
MORE INFORMATION AT
NGINX.COM
Microcaching with NGINX
proxy_cache_path /tmp/cache keys_zone=cache:10m levels=1:2
inactive=600s max_size=100m;
server {
proxy_cache cache;
proxy_cache_valid 200 1s;
...
}
• Cache 200 responses for 1 second
MORE INFORMATION AT
NGINX.COM
Optimized Microcaching with NGINX
server {
proxy_cache cache;
proxy_cache_valid 200 1s;
proxy_cache_lock on;
proxy_cache_use_stale updating;
...
}
• proxy_cache_lock – If multiple simultaneous requests for the same
uncached or stale content, only one request allowed through. Other is
queued.
• proxy_cache_use_stale – Serve stale content when while cached entry is
being updated
MORE INFORMATION AT
NGINX.COM
Cache Purging with NGINX Plus
proxy_cache_path /tmp/cache keys_zone=mycache:10m levels=1:2
inactive=60s;
map $request_method $purge_method {
PURGE 1;
default 0;
}
server {
proxy_cache mycache;
proxy_cache_purge $purge_method;
}
$ curl -X PURGE -D – "http://www.example.com/*"
HTTP/1.1 204 No Content
…
MORE INFORMATION AT
NGINX.COM
Agenda
● What’s New in Drupal 8
● Planning Site Architecture
● Replacing Your Web Server
● Drupal Specifics
- Drupal 8 Configuration
● Caching
- Why cache with NGINX?
- Microcaching
- Cache Purging with NGINX Plus
● Reverse Proxy Server
- Load Balancing
- Session Persistence
- Bonus: SSL/TLS and HTTP/2
● Questions?
MORE INFORMATION AT
NGINX.COM
Load Balancing with NGINX
MORE INFORMATION AT
NGINX.COM
Session Persistence with NGINX Plus
• Stick client to the same server for duration of a session
• Multiple methods:
• NGINX tracks application session cookie: PHPSESSIONID
• NGINX inserts its own cookie
• Stick Route: Persistence based on cookie, HTTP header, etc.
• IP Hash (Available in Open Source)
• Session Draining: Gracefully remove servers from the load balancing pool
MORE INFORMATION AT
NGINX.COM
SSL offloading with NGINX
MORE INFORMATION AT
NGINX.COM
HTTP/2 with NGINX
NGINX translates HTTP/2 to the language your application speaks
MORE INFORMATION AT
NGINX.COM
Agenda
● What’s New in Drupal 8
● Planning Site Architecture
● Replacing Your Web Server
● Drupal Specifics
- Drupal 8 Configuration
● Caching
- Why cache with NGINX?
- Microcaching
- Cache Purging with NGINX Plus
● Reverse Proxy Server
- Load Balancing
- Session Persistence
- Bonus: SSL/TLS and HTTP/2
● Questions?

More Related Content

What's hot (17)

KEY
Nginx - Tips and Tricks.
Harish S
 
PPT
Nginx internals
liqiang xu
 
PPTX
Load Balancing and Scaling with NGINX
NGINX, Inc.
 
PPTX
What's New in NGINX Plus R7?
NGINX, Inc.
 
PPTX
Supercharge Application Delivery to Satisfy Users
NGINX, Inc.
 
PDF
Nginx dhruba mandal
Dhrubaji Mandal ♛
 
PPTX
5 things you didn't know nginx could do
sarahnovotny
 
PPTX
how to mesure web performance metrics
Marc Cortinas Val
 
PDF
Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
Severalnines
 
KEY
Nginx in production
Graham Weldon
 
PPTX
The 3 Models in the NGINX Microservices Reference Architecture
NGINX, Inc.
 
PPTX
NGINX Installation and Tuning
NGINX, Inc.
 
PPTX
Learn nginx in 90mins
Larry Cai
 
PDF
WordCamp RVA
codearachnid_test
 
PDF
Extending functionality in nginx, with modules!
Trygve Vea
 
PPTX
High Availability Content Caching with NGINX
NGINX, Inc.
 
PPTX
NGINX: Basics and Best Practices
NGINX, Inc.
 
Nginx - Tips and Tricks.
Harish S
 
Nginx internals
liqiang xu
 
Load Balancing and Scaling with NGINX
NGINX, Inc.
 
What's New in NGINX Plus R7?
NGINX, Inc.
 
Supercharge Application Delivery to Satisfy Users
NGINX, Inc.
 
Nginx dhruba mandal
Dhrubaji Mandal ♛
 
5 things you didn't know nginx could do
sarahnovotny
 
how to mesure web performance metrics
Marc Cortinas Val
 
Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
Severalnines
 
Nginx in production
Graham Weldon
 
The 3 Models in the NGINX Microservices Reference Architecture
NGINX, Inc.
 
NGINX Installation and Tuning
NGINX, Inc.
 
Learn nginx in 90mins
Larry Cai
 
WordCamp RVA
codearachnid_test
 
Extending functionality in nginx, with modules!
Trygve Vea
 
High Availability Content Caching with NGINX
NGINX, Inc.
 
NGINX: Basics and Best Practices
NGINX, Inc.
 

Similar to Drupal 8 and NGINX (20)

PPTX
Maximizing PHP Performance with NGINX
NGINX, Inc.
 
PDF
What is Nginx and Why You Should to Use it with Wordpress Hosting
WPSFO Meetup Group
 
PDF
NGINX: The Past, Present and Future of the Modern Web
Kevin Jones
 
PDF
ITB2017 - Nginx ppf intothebox_2017
Ortus Solutions, Corp
 
PDF
NGINX: Basics and Best Practices EMEA
NGINX, Inc.
 
PDF
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
Ortus Solutions, Corp
 
PPTX
NGINX High-performance Caching
NGINX, Inc.
 
PPTX
NGINX 101 - now with more Docker
sarahnovotny
 
PPTX
NGINX 101 - now with more Docker
Sarah Novotny
 
PDF
NGINX ADC: Basics and Best Practices
NGINX, Inc.
 
PDF
NGINX ADC: Basics and Best Practices – EMEA
NGINX, Inc.
 
PPTX
NGINX: Basics & Best Practices - EMEA Broadcast
NGINX, Inc.
 
PPTX
NGINX: High Performance Load Balancing
NGINX, Inc.
 
PDF
Using NGINX as an Effective and Highly Available Content Cache
Kevin Jones
 
PPTX
NGINX: Back to Basics – APCJ
NGINX, Inc.
 
PPTX
Delivering High Performance Websites with NGINX
NGINX, Inc.
 
PPTX
3 Ways to Automate App Deployments with NGINX
NGINX, Inc.
 
PDF
High Availability Content Caching with NGINX
Kevin Jones
 
PPTX
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
Amit Aggarwal
 
PPTX
NGINX: High Performance Load Balancing
NGINX, Inc.
 
Maximizing PHP Performance with NGINX
NGINX, Inc.
 
What is Nginx and Why You Should to Use it with Wordpress Hosting
WPSFO Meetup Group
 
NGINX: The Past, Present and Future of the Modern Web
Kevin Jones
 
ITB2017 - Nginx ppf intothebox_2017
Ortus Solutions, Corp
 
NGINX: Basics and Best Practices EMEA
NGINX, Inc.
 
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
Ortus Solutions, Corp
 
NGINX High-performance Caching
NGINX, Inc.
 
NGINX 101 - now with more Docker
sarahnovotny
 
NGINX 101 - now with more Docker
Sarah Novotny
 
NGINX ADC: Basics and Best Practices
NGINX, Inc.
 
NGINX ADC: Basics and Best Practices – EMEA
NGINX, Inc.
 
NGINX: Basics & Best Practices - EMEA Broadcast
NGINX, Inc.
 
NGINX: High Performance Load Balancing
NGINX, Inc.
 
Using NGINX as an Effective and Highly Available Content Cache
Kevin Jones
 
NGINX: Back to Basics – APCJ
NGINX, Inc.
 
Delivering High Performance Websites with NGINX
NGINX, Inc.
 
3 Ways to Automate App Deployments with NGINX
NGINX, Inc.
 
High Availability Content Caching with NGINX
Kevin Jones
 
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
Amit Aggarwal
 
NGINX: High Performance Load Balancing
NGINX, Inc.
 
Ad

More from NGINX, Inc. (20)

PDF
【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法
NGINX, Inc.
 
PDF
【NGINXセミナー】 NGINXのWAFとは?その使い方と設定方法 解説セミナー
NGINX, Inc.
 
PDF
【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法
NGINX, Inc.
 
PPTX
Get Hands-On with NGINX and QUIC+HTTP/3
NGINX, Inc.
 
PPTX
Managing Kubernetes Cost and Performance with NGINX & Kubecost
NGINX, Inc.
 
PDF
Manage Microservices Chaos and Complexity with Observability
NGINX, Inc.
 
PDF
Accelerate Microservices Deployments with Automation
NGINX, Inc.
 
PDF
Unit 2: Microservices Secrets Management 101
NGINX, Inc.
 
PDF
Unit 1: Apply the Twelve-Factor App to Microservices Architectures
NGINX, Inc.
 
PDF
NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!
NGINX, Inc.
 
PDF
Easily View, Manage, and Scale Your App Security with F5 NGINX
NGINX, Inc.
 
PDF
NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!
NGINX, Inc.
 
PDF
Keep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINX
NGINX, Inc.
 
PPTX
Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...
NGINX, Inc.
 
PPTX
Protecting Apps from Hacks in Kubernetes with NGINX
NGINX, Inc.
 
PPTX
NGINX Kubernetes API
NGINX, Inc.
 
PPTX
Successfully Implement Your API Strategy with NGINX
NGINX, Inc.
 
PPTX
Installing and Configuring NGINX Open Source
NGINX, Inc.
 
PPTX
Shift Left for More Secure Apps with F5 NGINX
NGINX, Inc.
 
PPTX
How to Avoid the Top 5 NGINX Configuration Mistakes.pptx
NGINX, Inc.
 
【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法
NGINX, Inc.
 
【NGINXセミナー】 NGINXのWAFとは?その使い方と設定方法 解説セミナー
NGINX, Inc.
 
【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法
NGINX, Inc.
 
Get Hands-On with NGINX and QUIC+HTTP/3
NGINX, Inc.
 
Managing Kubernetes Cost and Performance with NGINX & Kubecost
NGINX, Inc.
 
Manage Microservices Chaos and Complexity with Observability
NGINX, Inc.
 
Accelerate Microservices Deployments with Automation
NGINX, Inc.
 
Unit 2: Microservices Secrets Management 101
NGINX, Inc.
 
Unit 1: Apply the Twelve-Factor App to Microservices Architectures
NGINX, Inc.
 
NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!
NGINX, Inc.
 
Easily View, Manage, and Scale Your App Security with F5 NGINX
NGINX, Inc.
 
NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!
NGINX, Inc.
 
Keep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINX
NGINX, Inc.
 
Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...
NGINX, Inc.
 
Protecting Apps from Hacks in Kubernetes with NGINX
NGINX, Inc.
 
NGINX Kubernetes API
NGINX, Inc.
 
Successfully Implement Your API Strategy with NGINX
NGINX, Inc.
 
Installing and Configuring NGINX Open Source
NGINX, Inc.
 
Shift Left for More Secure Apps with F5 NGINX
NGINX, Inc.
 
How to Avoid the Top 5 NGINX Configuration Mistakes.pptx
NGINX, Inc.
 
Ad

Recently uploaded (20)

PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 

Drupal 8 and NGINX

  • 1. Maximizing Drupal 8 Performance with NGINX Wednesday, 20 January 2016
  • 2. MORE INFORMATION AT NGINX.COM Your Questions 1. Who are we? ● Floyd Smith, Technical Marketing Writer. Author of NGINX blog post, “8 Tips for Drupal 8 Performance”. ● Faisal Memon, Product Marketer 2. What’s new in Drupal 8? 3. How can I implement a high-performance site? 4. How do NGINX and NGINX Plus fit into my efforts?
  • 3. MORE INFORMATION AT NGINX.COM Agenda ● What’s New in Drupal 8 ● Planning Site Architecture ● Replacing Your Web Server ● Drupal Specifics - Drupal 8 Configuration ● Caching - Why cache with NGINX? - Microcaching - Cache Purging with NGINX Plus ● Reverse Proxy Server - Load Balancing - Session Persistence - Bonus: SSL/TLS and HTTP/2 ● Questions?
  • 4. MORE INFORMATION AT NGINX.COM What’s New in Drupal 8 1. Mobile improvements. Full support for mobile site templates and easy backend administration from a mobile device. 2. Data and presentation layer uncoupling. The Drupal API is now fully RESTful, making it easier to use with Angular.js, Ember.js, and other client-side content extraction and display tools. 3. Support for Symfony2. Symfony 2 is an up-to-date, object-oriented PHP framework, well known for customer relationship management (CRM) integration. 4. Twig support. Twig is a frontend library and template engine that eliminates some disadvantages of pure PHP while embracing the latest PHP standards. 5. Security improvements. New features offer additional ways to make systems more secure.
  • 5. MORE INFORMATION AT NGINX.COM Agenda ● What’s New in Drupal 8 ● Planning Site Architecture ● Replacing Your Web Server ● Drupal Specifics - Drupal 8 Configuration ● Caching - Why cache with NGINX? - Microcaching - Cache Purging with NGINX Plus ● Reverse Proxy Server - Load Balancing - Session Persistence - Bonus: SSL/TLS and HTTP/2 ● Questions?
  • 6. MORE INFORMATION AT NGINX.COM Planning Your Site Architecture 1. Current architecture. Evaluate your current site traffic and performance. 2. Goals. Immediate problems, future growth 3. Estimate impact of changes. Open source NGINX or NGINX Plus as web server, reverse proxy server, load balancer, more. 4. Plan for growth. Estimate likely and possible growth and speed of growth. 5. Factor in the cloud. Use cloud from scratch, expand into the cloud, move into the cloud.
  • 7. MORE INFORMATION AT NGINX.COM Agenda ● What’s New in Drupal 8 ● Planning Site Architecture ● Replacing Your Web Server ● Drupal Specifics - Drupal 8 Configuration ● Caching - Why cache with NGINX? - Microcaching - Cache Purging with NGINX Plus ● Reverse Proxy Server - Load Balancing - Session Persistence - Bonus: SSL/TLS and HTTP/2 ● Questions?
  • 8. MORE INFORMATION AT NGINX.COM Replacing Your Web Server 1. Replace Apache with NGINX or NGINX Plus. Immediate performance fix. Enables caching for static and dynamic content. (More on this soon.) Does not enable multiple app servers. 2. More performance on same hardware. Event loop replaces thread-per-connection, solves C10K problem. 3. Requires new server configuration. Replace familiar Apache configuration with tighter, more efficient (IMHO) NGINX configuration. 4. Independent of NGINX as reverse proxy server. You can use NGINX as a reverse proxy server with or without using NGINX as your web server; very flexible.
  • 9. MORE INFORMATION AT NGINX.COM Agenda ● What’s New in Drupal 8 ● Planning Site Architecture ● Replacing Your Web Server ● Drupal Specifics - Drupal 8 Configuration ● Caching - Why cache with NGINX? - Microcaching - Cache Purging with NGINX Plus ● Reverse Proxy Server - Load Balancing - Session Persistence - Bonus: SSL/TLS and HTTP/2 ● Questions?
  • 10. MORE INFORMATION AT NGINX.COM NGINX configuration for Drupal • Minor changes to nginx.conf for Drupal 8 • Mostly related to update.php front controller • Sample configuration available on NGINX wiki • https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/
  • 11. MORE INFORMATION AT NGINX.COM Change #1: Accommodating update.php front controller location ~ '.php$ { ... } location ~ '.php$|^/update.php' { ... } • To accommodate URIs such as: /update.php/selection • Without this change NGINX will return a 404 error • Less strict (and more future proof) alternative: • Will match (and break) legacy Drupal URIs such as /blog/index.php/legacy location ~ '.php$(/|$) {
  • 12. MORE INFORMATION AT NGINX.COM Change #2: Non-greedy match fastcgi_split_path_info ^(.+.php)(.*)$; fastcgi_split_path_info ^(.+?.php)(|/.*)$; • To accommodate URIs such as: /core/authorize.php/core/authorize.php • Without this change NGINX will return a 404 error • Greedy match (left side) means entire URI will be SCRIPT_FILENAME • Non-greedy match (right side) means first authorize.php will be matched
  • 13. MORE INFORMATION AT NGINX.COM Change #3: Default location location / { try_files $uri @rewrite; } location /{ try_files $uri /index.php?$query_string; } • Change was made for Drupal 7 • Older version can cause query string to be altered
  • 14. MORE INFORMATION AT NGINX.COM Agenda ● What’s New in Drupal 8 ● Planning Site Architecture ● Replacing Your Web Server ● Drupal Specifics - Drupal 8 Configuration ● Caching - Why cache with NGINX? - Microcaching - Cache Purging with NGINX Plus ● Reverse Proxy Server - Load Balancing - Session Persistence - Bonus: SSL/TLS and HTTP/2 ● Conclusion ● Questions?
  • 15. MORE INFORMATION AT NGINX.COM Why Cache with NGINX? Source: http://bbc.in/1O8qHbi
  • 16. MORE INFORMATION AT NGINX.COM Microcaching with NGINX • Cache content for a short time, as little as 1 second • Site content is out of date for max 1 second • Significant performance gains even for that short of a time
  • 17. MORE INFORMATION AT NGINX.COM Microcaching with NGINX proxy_cache_path /tmp/cache keys_zone=cache:10m levels=1:2 inactive=600s max_size=100m; server { proxy_cache cache; proxy_cache_valid 200 1s; ... } • Cache 200 responses for 1 second
  • 18. MORE INFORMATION AT NGINX.COM Optimized Microcaching with NGINX server { proxy_cache cache; proxy_cache_valid 200 1s; proxy_cache_lock on; proxy_cache_use_stale updating; ... } • proxy_cache_lock – If multiple simultaneous requests for the same uncached or stale content, only one request allowed through. Other is queued. • proxy_cache_use_stale – Serve stale content when while cached entry is being updated
  • 19. MORE INFORMATION AT NGINX.COM Cache Purging with NGINX Plus proxy_cache_path /tmp/cache keys_zone=mycache:10m levels=1:2 inactive=60s; map $request_method $purge_method { PURGE 1; default 0; } server { proxy_cache mycache; proxy_cache_purge $purge_method; } $ curl -X PURGE -D – "http://www.example.com/*" HTTP/1.1 204 No Content …
  • 20. MORE INFORMATION AT NGINX.COM Agenda ● What’s New in Drupal 8 ● Planning Site Architecture ● Replacing Your Web Server ● Drupal Specifics - Drupal 8 Configuration ● Caching - Why cache with NGINX? - Microcaching - Cache Purging with NGINX Plus ● Reverse Proxy Server - Load Balancing - Session Persistence - Bonus: SSL/TLS and HTTP/2 ● Questions?
  • 21. MORE INFORMATION AT NGINX.COM Load Balancing with NGINX
  • 22. MORE INFORMATION AT NGINX.COM Session Persistence with NGINX Plus • Stick client to the same server for duration of a session • Multiple methods: • NGINX tracks application session cookie: PHPSESSIONID • NGINX inserts its own cookie • Stick Route: Persistence based on cookie, HTTP header, etc. • IP Hash (Available in Open Source) • Session Draining: Gracefully remove servers from the load balancing pool
  • 23. MORE INFORMATION AT NGINX.COM SSL offloading with NGINX
  • 24. MORE INFORMATION AT NGINX.COM HTTP/2 with NGINX NGINX translates HTTP/2 to the language your application speaks
  • 25. MORE INFORMATION AT NGINX.COM Agenda ● What’s New in Drupal 8 ● Planning Site Architecture ● Replacing Your Web Server ● Drupal Specifics - Drupal 8 Configuration ● Caching - Why cache with NGINX? - Microcaching - Cache Purging with NGINX Plus ● Reverse Proxy Server - Load Balancing - Session Persistence - Bonus: SSL/TLS and HTTP/2 ● Questions?