SlideShare a Scribd company logo
1
Tips and tricks for high performance websites
Harald Zeitlhofer
June 2015
Boost your website by running
PHP on Nginx
@HZeitlhofer
harald.zeitlhofer@dynatrace.com
2
• Technology Strategist at Dynatrace
• Database and Web Development
• PHP for more than 15 years
• Love to discover new things
Harald Zeitlhofer
3
Tips and tricks for high performance websites
4
Web Applications
5
6
Modern Web Pages: lots of static content
434 Resources in total on that page:
230 JPEGs, 75 PNGs, 50 GIFs, …
more than 20MB page size
7
cached content
can still create roundtrips
to the network!
8
Web Request handling
10
Web Request handling
11
PHP
run modes
Apache Module
– traditional approach
– used for most PHP environments
PHP-FPM
– fast process manager
– run multiple PHP worker processes to
serve FastCGI requests
HHVM
– Virtual machine for HipHop
– fast PHP engine
– can serve FastCGI requests
12
PHP-FPM
FastCGI Process Manager
Available since 5.3.3
Stable since 5.4.1
13
• Installation
• Pool configuration
/etc/php5/fpm/pool.d/www.conf
PHP-FPM
[www]
user = www-data
group = www-data
listen = 127.0.0.1:9000 # for Unix socket: unix:/var/run/php5-fpm.sock;
root@hzvm01:/etc/nginx/sites-enabled# ps -ef | grep php
root 6435 1 0 14:39 ? 00:00:32 php-fpm: master process (/etc/php5/fpm/php-
fpm.conf)
spelix 6439 6435 0 14:39 ? 00:00:00 php-fpm: pool batch
spelix 6440 6435 0 14:39 ? 00:00:00 php-fpm: pool batch
www-data 10576 6435 1 18:45 ? 00:00:48 php-fpm: pool www
www-data 10920 6435 1 18:47 ? 00:00:47 php-fpm: pool www
www-data 10927 6435 1 18:47 ? 00:00:46 php-fpm: pool www
sudo apt-get install php5-fpm
14
HHVM
HipHop Virtual Machine
Facebook's PHP engine
JIT compiler
supports PHP and Hack
15
• Installation
• start server
cd /your/root/folder
hhvm --mode server -vServer.Type=fastcgi -vServer.Port=9000
echo deb http://dl.hhvm.com/ubuntu trusty main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
sudo apt-get install hhvm
hhvm --mode server -vServer.Type=fastcgi –vServer.FileSocket=/var/run/hhvm.sock
16
Nginx
Lightweight HTTP server
Event based request handling
Fast especially at high load
Open Source project (BSD)
Commercial version NGINX Plus
18
/etc/nginx/nginx.conf
# max_clients = worker_processes * worker_connections
worker_processes 8; # number of CPUs
events {
worker_connections 1024;
multi_accept on;
}
19
• Static content to be served by Nginx
• Dynamic requests to be sent to PHP
Integration
server {
listen 80;
server_name www.yourdomain.com;
root /var/www/test;
index index.php index.html index.htm;
location ~* .(html|js|css|gif|jpg|jpe|jpeg|png|bmp|tif|pdf|ico)$ {
try_files $uri =404;
}
location / {
try_files $uri $uri/ =404;
}
location ~* .php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1;
include fastcgi_params;
}
}
20
Communication via sockets
• TCP vs Unix
• Unix slightly faster when used on localhost
• Use TCP for high load
location ~* .php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
fastcgi_pass unix:/var/run/php5-fpm.sock;
21
Transaction flow
22
http://www.mysite.com/news/browse/2014
 to be processed by index.php
URL rewrite
...
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php
...
23
http://www.mysite.com/news/browse/2014
 to be processed by index.php
URL rewrite
upstream php {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
root /var/www;
index index.php index.html index.htm;
server_name www.mysite.com;
location / {
try_files $uri $uri/ @missing;
}
location @missing {
rewrite (.*) /index.php;
}
location ~ .php$ {
fastcgi_index index.php;
include fastcgi_params;
fastcgi_pass php;
}
}
24
using Nginx/PHP-FPM there’s a better way:
URL rewrite
upstream php {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
root /var/www;
index index.php index.html index.htm;
server_name www.mysite.com;
location /images {
try_files $uri =404;
}
location /scripts {
try_files $uri =404;
}
location / {
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME
/var/www/index.php;
fastcgi_pass php;
}
}
<?php
$params = explode('/', $_SERVER["DOCUMENT_URI"]);
...
29
Nginx and Caching
30
• Part of Nginx' FastCGI module
Nginx FastCGI cache
fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=APPKEY:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
location ~* .php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_cache APPKEY;
fastcgi_cache_valid 200 60m;
}
31
FastCGI cache in action
32
FastCGI cache in action
<?php
echo time()."n";
?>
33
FastCGI cache in action
<?php
echo time()."n";
?>
34
Full page cache with Memcached
<?php
...
function __construct () {
$this->c = new Memcached();
$this->c->addServer('localhost',11211);
}
function setCache ($key, $content) {
$this->c->set($key, $content);
}
...
// get HTML content
$html = $this->renderPage();
$this->setCache($_SERVER['REQUEST_URI'], $html);
...
?>
35
Data cache with Memcached
<?php
...
function __construct () {
$this->c = new Memcached();
$this->c->addServer('localhost',11211);
}
function setCache ($key, $content) {
$this->c->set($key, $content);
}
...
// get data structure
$newslist = $this->getNewsList();
$this->setCache('/data/news/getlist', json_encode($newslist));
...
?>
36
• ngx_http_memcached_module
Full page / data cache with Nginx and Memcached
upstream php {
server unix:/var/run/php5-fpm.sock;
}
server {
location / {
set $memcached_key "$uri";
memcached_pass localhost:11211;
error_page 404 502 504 = @notincache;
}
location @notincache {
fastcgi_pass php;
}
}
37
PHP, 5k requests, concurrency 100
0
1
2
3
4
5
6
7
8
Apache+PHP Nginx+PHP Nginx+Memcached
<?php
echo "Hello World";
?>
7,28 4,6 3,05
38
• set HTTP response expires header
Client Side Caching
location ~ .(html|js|css|gif|jpg|jpe|jpeg|png|bmp|tif|pdf|ico)$ {
expires 90d;
access_log off;
error_log off;
try_files $uri =404;
}
39
• keep handlers for requested static files open
Filehandle Caching
open_file_cache max=1000 inactive=5m;
open_file_cache_valid 60s;
open_file_cache_min_uses 5;
open_file_cache_errors off;
40
Load balancing
upstream php {
ip_hash;
server unix:/var/run/php5-fpm.sock weight=5;
server 192.168.56.12:9000 weight=2;
server 192.168.56.13:9000;
server 192.168.56.14:9000 backup;
}
server {
listen 80;
root /home/www/test;
server_name test.hzvm01;
location / {
try_files $uri =405;
}
location ~ .php$ {
fastcgi_pass php;
fastcgi_index index.php;
include fastcgi_params;
}
}
41
• Methods
• round-robin
• least-connected (least_conn)
• session persistence (ip_hash)
• Weighted load balancing
• Health checks
• max_fails
• fail_timeout
Load balancing
42
• Nginx running with default settings
• Apache
• AllowOverride None
• Multi-process (prefork) mode
to allow usage of mod_php
Benchmarking Nginx vs Apache
43
Static HTML, 10k requests
0
1
2
3
4
5
6
7
8
9
100 500 1000 2000
Apache/2.4.9
nginx/1.1.19
concurrency
Totalresponsetime[sec]
44
Performance Monitoring
45
Performance Tools
51
• Load Generator
(Apache Benchmark, Selenium, JMeter)
• Firebug, Google Developer Tools
Dynatrace Ajax Edition
• Dynatrace Free Trial
• Free trial license for 30 days
• Free personal license for developers
My favorite performance tools
http://bit.ly/dttrial
52
www.dynatrace.com
Thank you !!!
Harald Zeitlhofer
Senior Technology Strategist
#HZeitlhofer
harald.zeitlhofer@dynatrace.com
http://blog.dyntrace.com

More Related Content

PDF
Running php on nginx
PDF
Scaling PHP web apps
PPTX
Boost your website by running PHP on Nginx
PDF
Running PHP on Nginx
PDF
Slow Database in your PHP stack? Don't blame the DBA!
PDF
NginX - good practices, tips and advanced techniques
PDF
Running PHP on nginx
PDF
Content Caching with NGINX and NGINX Plus
Running php on nginx
Scaling PHP web apps
Boost your website by running PHP on Nginx
Running PHP on Nginx
Slow Database in your PHP stack? Don't blame the DBA!
NginX - good practices, tips and advanced techniques
Running PHP on nginx
Content Caching with NGINX and NGINX Plus

What's hot (19)

PDF
Stupid Boot Tricks: using ipxe and chef to get to boot management bliss
PDF
Caching with Memcached and APC
PDF
Rails Caching Secrets from the Edge
PDF
ReplacingSquidWithATS
PDF
Integrated Cache on Netscaler
PDF
Fluentd and WebHDFS
PDF
Background Tasks in Node - Evan Tahler, TaskRabbit
PDF
Memcached Study
PDF
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
PDF
How to monitor NGINX
PPT
Apache Traffic Server
PDF
HTTP Caching in Web Application
PDF
Altitude SF 2017: Advanced VCL: Shielding and Clustering
PDF
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
PDF
PHP projects beyond the LAMP stack
PPT
Oscon 2010 - ATS
PDF
Caching basics in PHP
PDF
Kea DHCP – the new open source DHCP server from ISC
PDF
Into The Box 2018 Going live with commandbox and docker
Stupid Boot Tricks: using ipxe and chef to get to boot management bliss
Caching with Memcached and APC
Rails Caching Secrets from the Edge
ReplacingSquidWithATS
Integrated Cache on Netscaler
Fluentd and WebHDFS
Background Tasks in Node - Evan Tahler, TaskRabbit
Memcached Study
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
How to monitor NGINX
Apache Traffic Server
HTTP Caching in Web Application
Altitude SF 2017: Advanced VCL: Shielding and Clustering
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
PHP projects beyond the LAMP stack
Oscon 2010 - ATS
Caching basics in PHP
Kea DHCP – the new open source DHCP server from ISC
Into The Box 2018 Going live with commandbox and docker
Ad

Similar to PHP conference Berlin 2015: running PHP on Nginx (20)

PDF
Nginx pres
PDF
Nginx, PHP, Apache and Spelix
PDF
Running PHP on Nginx / PHP wgtn
PDF
10 Million hits a day with WordPress using a $15 VPS
PDF
Deploying nginx with minimal system resources
PPTX
20151229 wnmp & phalcon micro app - part I
DOC
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web server
PDF
23 LAMP Stack #burningkeyboards
ODP
Modern Application Stacks
PDF
Php through the eyes of a hoster confoo
PDF
Speed up your development environment PHP + Nginx + Fedora + PG
PDF
Scale Apache with Nginx
KEY
SydPHP March 2012 Meetup
PDF
Cluster Fudge: Recipes for WordPress in the Cloud (WordCamp Austin 2014 Speaker)
PDF
Cluster Fudge: Recipes for WordPress in the Cloud (WordCamp Austin 2014 Speaker)
PDF
A look at FastCgi & Mod_PHP architecture
PDF
Nginx Workshop Aftermath
ODP
Caching and tuning fun for high scalability
PDF
Magento's Imagine eCommerce Conference 2011 - Hosting Magento: Performance an...
Nginx pres
Nginx, PHP, Apache and Spelix
Running PHP on Nginx / PHP wgtn
10 Million hits a day with WordPress using a $15 VPS
Deploying nginx with minimal system resources
20151229 wnmp & phalcon micro app - part I
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web server
23 LAMP Stack #burningkeyboards
Modern Application Stacks
Php through the eyes of a hoster confoo
Speed up your development environment PHP + Nginx + Fedora + PG
Scale Apache with Nginx
SydPHP March 2012 Meetup
Cluster Fudge: Recipes for WordPress in the Cloud (WordCamp Austin 2014 Speaker)
Cluster Fudge: Recipes for WordPress in the Cloud (WordCamp Austin 2014 Speaker)
A look at FastCgi & Mod_PHP architecture
Nginx Workshop Aftermath
Caching and tuning fun for high scalability
Magento's Imagine eCommerce Conference 2011 - Hosting Magento: Performance an...
Ad

More from Harald Zeitlhofer (8)

PDF
PHP and databases
PDF
Improve Magento Performance
PDF
PHP App Performance / Sydney PHP
PDF
PHP application performance
PDF
PHP Application Performance
PDF
Nginx performance monitoring with Dynatrace
PDF
Nginx, PHP and Node.js
PDF
Performance optimisation - scaling a hobby project to serious business
PHP and databases
Improve Magento Performance
PHP App Performance / Sydney PHP
PHP application performance
PHP Application Performance
Nginx performance monitoring with Dynatrace
Nginx, PHP and Node.js
Performance optimisation - scaling a hobby project to serious business

Recently uploaded (20)

PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
cuic standard and advanced reporting.pdf
PPTX
Cloud computing and distributed systems.
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Modernizing your data center with Dell and AMD
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Big Data Technologies - Introduction.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Network Security Unit 5.pdf for BCA BBA.
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
cuic standard and advanced reporting.pdf
Cloud computing and distributed systems.
Transforming Manufacturing operations through Intelligent Integrations
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
MYSQL Presentation for SQL database connectivity
Advanced Soft Computing BINUS July 2025.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Per capita expenditure prediction using model stacking based on satellite ima...
The AUB Centre for AI in Media Proposal.docx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Weekly Chronicles - August'25 Week I
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Modernizing your data center with Dell and AMD
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

PHP conference Berlin 2015: running PHP on Nginx

  • 1. 1 Tips and tricks for high performance websites Harald Zeitlhofer June 2015 Boost your website by running PHP on Nginx @HZeitlhofer [email protected]
  • 2. 2 • Technology Strategist at Dynatrace • Database and Web Development • PHP for more than 15 years • Love to discover new things Harald Zeitlhofer
  • 3. 3 Tips and tricks for high performance websites
  • 5. 5
  • 6. 6 Modern Web Pages: lots of static content 434 Resources in total on that page: 230 JPEGs, 75 PNGs, 50 GIFs, … more than 20MB page size
  • 7. 7 cached content can still create roundtrips to the network!
  • 10. 11 PHP run modes Apache Module – traditional approach – used for most PHP environments PHP-FPM – fast process manager – run multiple PHP worker processes to serve FastCGI requests HHVM – Virtual machine for HipHop – fast PHP engine – can serve FastCGI requests
  • 11. 12 PHP-FPM FastCGI Process Manager Available since 5.3.3 Stable since 5.4.1
  • 12. 13 • Installation • Pool configuration /etc/php5/fpm/pool.d/www.conf PHP-FPM [www] user = www-data group = www-data listen = 127.0.0.1:9000 # for Unix socket: unix:/var/run/php5-fpm.sock; root@hzvm01:/etc/nginx/sites-enabled# ps -ef | grep php root 6435 1 0 14:39 ? 00:00:32 php-fpm: master process (/etc/php5/fpm/php- fpm.conf) spelix 6439 6435 0 14:39 ? 00:00:00 php-fpm: pool batch spelix 6440 6435 0 14:39 ? 00:00:00 php-fpm: pool batch www-data 10576 6435 1 18:45 ? 00:00:48 php-fpm: pool www www-data 10920 6435 1 18:47 ? 00:00:47 php-fpm: pool www www-data 10927 6435 1 18:47 ? 00:00:46 php-fpm: pool www sudo apt-get install php5-fpm
  • 13. 14 HHVM HipHop Virtual Machine Facebook's PHP engine JIT compiler supports PHP and Hack
  • 14. 15 • Installation • start server cd /your/root/folder hhvm --mode server -vServer.Type=fastcgi -vServer.Port=9000 echo deb http://dl.hhvm.com/ubuntu trusty main | sudo tee /etc/apt/sources.list.d/hhvm.list sudo apt-get update sudo apt-get install hhvm hhvm --mode server -vServer.Type=fastcgi –vServer.FileSocket=/var/run/hhvm.sock
  • 15. 16 Nginx Lightweight HTTP server Event based request handling Fast especially at high load Open Source project (BSD) Commercial version NGINX Plus
  • 16. 18 /etc/nginx/nginx.conf # max_clients = worker_processes * worker_connections worker_processes 8; # number of CPUs events { worker_connections 1024; multi_accept on; }
  • 17. 19 • Static content to be served by Nginx • Dynamic requests to be sent to PHP Integration server { listen 80; server_name www.yourdomain.com; root /var/www/test; index index.php index.html index.htm; location ~* .(html|js|css|gif|jpg|jpe|jpeg|png|bmp|tif|pdf|ico)$ { try_files $uri =404; } location / { try_files $uri $uri/ =404; } location ~* .php$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1; include fastcgi_params; } }
  • 18. 20 Communication via sockets • TCP vs Unix • Unix slightly faster when used on localhost • Use TCP for high load location ~* .php$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } fastcgi_pass unix:/var/run/php5-fpm.sock;
  • 20. 22 http://www.mysite.com/news/browse/2014  to be processed by index.php URL rewrite ... RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php ...
  • 21. 23 http://www.mysite.com/news/browse/2014  to be processed by index.php URL rewrite upstream php { server unix:/var/run/php5-fpm.sock; } server { listen 80; root /var/www; index index.php index.html index.htm; server_name www.mysite.com; location / { try_files $uri $uri/ @missing; } location @missing { rewrite (.*) /index.php; } location ~ .php$ { fastcgi_index index.php; include fastcgi_params; fastcgi_pass php; } }
  • 22. 24 using Nginx/PHP-FPM there’s a better way: URL rewrite upstream php { server unix:/var/run/php5-fpm.sock; } server { listen 80; root /var/www; index index.php index.html index.htm; server_name www.mysite.com; location /images { try_files $uri =404; } location /scripts { try_files $uri =404; } location / { fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /var/www/index.php; fastcgi_pass php; } } <?php $params = explode('/', $_SERVER["DOCUMENT_URI"]); ...
  • 24. 30 • Part of Nginx' FastCGI module Nginx FastCGI cache fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=APPKEY:100m inactive=60m; fastcgi_cache_key "$scheme$request_method$host$request_uri"; location ~* .php$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_cache APPKEY; fastcgi_cache_valid 200 60m; }
  • 26. 32 FastCGI cache in action <?php echo time()."n"; ?>
  • 27. 33 FastCGI cache in action <?php echo time()."n"; ?>
  • 28. 34 Full page cache with Memcached <?php ... function __construct () { $this->c = new Memcached(); $this->c->addServer('localhost',11211); } function setCache ($key, $content) { $this->c->set($key, $content); } ... // get HTML content $html = $this->renderPage(); $this->setCache($_SERVER['REQUEST_URI'], $html); ... ?>
  • 29. 35 Data cache with Memcached <?php ... function __construct () { $this->c = new Memcached(); $this->c->addServer('localhost',11211); } function setCache ($key, $content) { $this->c->set($key, $content); } ... // get data structure $newslist = $this->getNewsList(); $this->setCache('/data/news/getlist', json_encode($newslist)); ... ?>
  • 30. 36 • ngx_http_memcached_module Full page / data cache with Nginx and Memcached upstream php { server unix:/var/run/php5-fpm.sock; } server { location / { set $memcached_key "$uri"; memcached_pass localhost:11211; error_page 404 502 504 = @notincache; } location @notincache { fastcgi_pass php; } }
  • 31. 37 PHP, 5k requests, concurrency 100 0 1 2 3 4 5 6 7 8 Apache+PHP Nginx+PHP Nginx+Memcached <?php echo "Hello World"; ?> 7,28 4,6 3,05
  • 32. 38 • set HTTP response expires header Client Side Caching location ~ .(html|js|css|gif|jpg|jpe|jpeg|png|bmp|tif|pdf|ico)$ { expires 90d; access_log off; error_log off; try_files $uri =404; }
  • 33. 39 • keep handlers for requested static files open Filehandle Caching open_file_cache max=1000 inactive=5m; open_file_cache_valid 60s; open_file_cache_min_uses 5; open_file_cache_errors off;
  • 34. 40 Load balancing upstream php { ip_hash; server unix:/var/run/php5-fpm.sock weight=5; server 192.168.56.12:9000 weight=2; server 192.168.56.13:9000; server 192.168.56.14:9000 backup; } server { listen 80; root /home/www/test; server_name test.hzvm01; location / { try_files $uri =405; } location ~ .php$ { fastcgi_pass php; fastcgi_index index.php; include fastcgi_params; } }
  • 35. 41 • Methods • round-robin • least-connected (least_conn) • session persistence (ip_hash) • Weighted load balancing • Health checks • max_fails • fail_timeout Load balancing
  • 36. 42 • Nginx running with default settings • Apache • AllowOverride None • Multi-process (prefork) mode to allow usage of mod_php Benchmarking Nginx vs Apache
  • 37. 43 Static HTML, 10k requests 0 1 2 3 4 5 6 7 8 9 100 500 1000 2000 Apache/2.4.9 nginx/1.1.19 concurrency Totalresponsetime[sec]
  • 40. 51 • Load Generator (Apache Benchmark, Selenium, JMeter) • Firebug, Google Developer Tools Dynatrace Ajax Edition • Dynatrace Free Trial • Free trial license for 30 days • Free personal license for developers My favorite performance tools http://bit.ly/dttrial
  • 41. 52 www.dynatrace.com Thank you !!! Harald Zeitlhofer Senior Technology Strategist #HZeitlhofer [email protected] http://blog.dyntrace.com

Editor's Notes

  • #8: 304 conditional caching with Entity Tag (E-Tag) header set