Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Drupal 8 and NGINX

985 views

Published on

Drupal 8 is an even more powerful tool for creating large, fast, capable applications. With architectural improvements, support for Symfony 2, enhanced security, and better mobile integration, Drupal 8 has been eagerly awaited by the worldwide Drupal community.

As your Drupal site traffic grows, you're likely to run up against performance constraints inherent to Apache and Drupal (or any PHP-based framework). In this webinar, we'll show you how to smoothly bypass performance bottlenecks and scale your Drupal site far beyond its current limitations.

Watch the webinar on demand: https://www.nginx.com/resources/webinars/drupal-8-performance/

Published in: Technology

Drupal 8 and NGINX

  1. 1. Maximizing Drupal 8 Performance with NGINX Wednesday, 20 January 2016
  2. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 15. MORE INFORMATION AT NGINX.COM Why Cache with NGINX? Source: http://bbc.in/1O8qHbi
  16. 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. 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. 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. 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. 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. 21. MORE INFORMATION AT NGINX.COM Load Balancing with NGINX
  22. 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. 23. MORE INFORMATION AT NGINX.COM SSL offloading with NGINX
  24. 24. MORE INFORMATION AT NGINX.COM HTTP/2 with NGINX NGINX translates HTTP/2 to the language your application speaks
  25. 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?

×