NGINX for FUN
& PERFORMANCE
PHILIPP KRENN @xeraa ecosio
Slide 2
Slide 2 text
Vienna
Slide 3
Slide 3 text
ViennaDB
Papers We Love Vienna
Slide 4
Slide 4 text
Electronic Data Interchange (EDI)
Slide 5
Slide 5 text
nginx
Slide 6
Slide 6 text
there's this russian server nginx. all the
porn sites use it. it must be decent.
— Jonathan VanascoJV
JV http://www.destructuring.net/2006/10/09/nginx/
Event-driven
SINGLE NONBLOCKING THREAD
ONE PROCESS PER CORE — NODE.JS, REDIS,...
STABLE MEMORY USAGE, NO CONTEXT SWITCHES
Slide 23
Slide 23 text
Event-driven
1. Receive request
2. Trigger events in a process
3. Process handles events and returns output
http://en.wikipedia.org/wiki/Reactor_pattern
GoAccess
HTTP://GOACCESS.IO
"REAL-TIME WEB LOG
ANALYZER"
Slide 50
Slide 50 text
No content
Slide 51
Slide 51 text
ServerDensity
HTTPS://BLOG.SERVERDENSITY.COM/MONITOR-NGINX/
SAAS: PARSES OUTPUT FOR
GRAPHS AND ALERTS
REQUIRES RECOMPILE WITH HTTP://NGINX.ORG/EN/DOCS/HTTP/
NGX_HTTP_STUB_STATUS_MODULE.HTML
Slide 52
Slide 52 text
Munin
GOOD OLD MUNIN...
HTTP://WWW.NGINXTIPS.COM/NGINX-CONFIGURATION-FOR-MUNIN/
Slide 53
Slide 53 text
No content
Slide 54
Slide 54 text
!
Slide 55
Slide 55 text
Apache is like Microsoft Word, it has a
million options but you only need six.
Slide 56
Slide 56 text
nginx does those six things, and it does
five of them 50 times faster than
Apache.
— Chris LeaCL
CL http://maisonbisson.com/post/12249/chris-lea-on-nginx-and-wordpress/
Slide 57
Slide 57 text
GREAT! BUT...
Slide 58
Slide 58 text
...IT DOESN'T WORK THE
Apache WAY
FOR EXAMPLE .htaccess
Slide 59
Slide 59 text
FOR EVERY REQUEST, CHECK
EVERY DIRECTORY, READ AND
PARSE EVERY FILE
Changes effective immediately
$ ab -n 25000 -c 10 http://188.226.151.84/codemotion_intro.png
...
Server Software: nginx/1.4.6
Server Hostname: 188.226.151.84
Server Port: 80
Document Path: /codemotion_intro.png
Document Length: 2461 bytes
Concurrency Level: 10
Time taken for tests: 7.734 seconds
Complete requests: 25000
Failed requests: 0
Total transferred: 67575000 bytes
HTML transferred: 61525000 bytes
Requests per second: 3232.56 [#/sec] (mean)
Time per request: 3.094 [ms] (mean)
Time per request: 0.309 [ms] (mean, across all concurrent requests)
Transfer rate: 8532.82 [Kbytes/sec] received
...
ab -n 2500 -c 10 -l http://188.226.151.84/info.php
Concurrency Level: 10
Time taken for tests: 4.920 seconds
Complete requests: 2500
Failed requests: 0
Total transferred: 164667204 bytes
HTML transferred: 164252204 bytes
Requests per second: 508.18 [#/sec] (mean)
Time per request: 19.678 [ms] (mean)
Time per request: 1.968 [ms] (mean, across all concurrent requests)
Transfer rate: 32687.80 [Kbytes/sec] received
Slide 75
Slide 75 text
No content
Slide 76
Slide 76 text
BENCHMARK YOUR PROJECTS
BUILD
BENCHMARK
REPEAT
Slide 77
Slide 77 text
No content
Slide 78
Slide 78 text
Say Apache one
more time...
Slide 79
Slide 79 text
Questions?
NOW OR @XERAA
HTTPS://SPEAKERDECK.COM/XERAA/