nginx-wpconfasia2011.pdf - Google Drive

4 downloads 18 Views 4MB Size Report
Focuses on web application development,. deployment, performance and stability. • 2009 : foss.my , MyGOSSCON. • 2010
WordConf Asia 2011

Me, Wordpress and Nginx Errazudin Ishak

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Agenda

• Me • Wordpress • “engine X” • Benchmarks • Samples

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

"Apache is like Microsoft Word, it has a million options but you only need six. Nginx does those six things, and it does five of them 50 times faster than Apache." - Chris Lea, ChrisLea.com

http://www.abacuspub.com/fsd/catalog/s574.htm

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

About Me • • • •

Errazudin Ishak @errazudin Senior engineer @ Mimos Bhd Malaysia Focuses on web application development, deployment, performance and stability. • 2009 : foss.my , MyGOSSCON • 2010 : Entp. PHP Techtalk, BarcampKL, PHP Meetup, MOSC2010, PHP Northwest UK, MyGOSSCON • 2011 : INTAN Tech Update www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Wordpress • • • •

www.mimos.my

Since 2003 Latest 3.1 (Django Reinhardt) Largest self-hosted blogging tool Has been downloaded…

© 2011 MIMOS Berhad. All Rights Reserved.

Wordpress

9, 176, 298*

*as of 2:33am 14 May 2011

http://wordpress.org/download/counter

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

nginx

• Free • X platform • open-source • (high-performance) • lightweight • HTTP server • reverse proxy • IMAP/POP3 proxy server www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

http://commons.wikimedia.org/wiki/File:Whittle_Jet_Engine_W2-700.JPG

“I'm the author of nginx (pronounced "engine x")Igor Sysoev (nginx creator) www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

http://www.litchfieldimports.co.uk/forum/gtr-engine-bay.jpg

Load Balance Static Content, Index files Reverse Proxy (with cache) Streaming

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

http://noisetu.be/mirrors/jet_beetle/

Loads of Request Less memory footprint Use less CPU C10K Certified

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

http://www.gtrblog.com/wp-content/uploads/2008/11/gtr-gt2-nurburgring-001.jpg

Apache ---------Processes Threads High Memory CPU Overhead PHP included as module (mod_php)

www.mimos.my

-------Async model Single Thread Low Memory Less CPU PHP as separate proc. over FastCGI

© 2011 MIMOS Berhad. All Rights Reserved.

http://www.zerotohundred.com/newforums/engine-and-performance/305020-nrg-racing-meters-9.html

Numbers

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Market Share for Top Servers Across All Domains

Source : Netcraft www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Market Share for Top Servers Across All Domains

Source : Netcraft www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Market Share for Top Servers Across the Million Busiest Sites

Source : Netcraft www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Market Share for Top Servers Across the Million Busiest Sites

Source : Netcraft www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

http://noisetu.be/mirrors/jet_beetle/

Who?

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Me uses nginx

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Me uses nginx

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

We also..

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

We all love nginx…

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

The most important is… :)

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Modules Mail, 3rd Party Optional HTTP Standard HTTP

Core www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Modules Mail Core, Mail Auth, Mail Proxy, Mail SSL

HTTP Addition, Emb. Perl, FLV, Gzip Precompression, Random Index, GeoIP, Real IP, SSL, Stub Status, Substitution, WebDAV, Google Perftools, XSLT, Secure Link, Image Filter HTTP Core, HTTP Upstream, HTTP Access, HTTP Auth Basic, HTTP Auto Index, Browser, Charset, Empty gif, FastCGI, Geo, Gzip, HTTP Headers, Index, HTTP Referer, HTTP Limit Zone, HTTP Limit Requests, Log, Map, Memchached, HTTP Proxy, Rewrite, SSI, User ID

Main, Events www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Nginx with PHP • FastCGI • PHP-FPM (FastCGI Process Manager) • Bundled with PHP 5.3.3

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Nginx with PHP : FastCGI • persistent processes, ability to handle multiple requests. • web server and gateway application communicate with sockets such as TCP • web server forwards the client request to the gateway and receives the response within a single connection • can be implemented on any platform with any programming language.

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Nginx with PHP : FastCGI server { server_name mysite.com; listen 80; root /usr/share/mysite/www; index index.html; location / { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include fastcgi_params; } }

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

PHP-FPM • FastCGI Process Manager • Daemonizes PHP > background proc • provides a command-line script for managing PHP proc • configuration of FastCGI pools • enhances some of the FastCGI internals • increases error reporting • script termination www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmarks http://www.myshutterspace.com/profile/AthonySaucedo

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmark : Specs • • • •

www.mimos.my

Intel Core Duo T2400, 1.83 GHz 2GB RAM OS- Fedora 12

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmark : apacheBench • -n 100 • -c 20

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmark : nginx

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmark : nginx

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmark : apache

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmark : apache

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmark : Findings

Apache 2.2.15 Nginx 0.7.67

Concurrency Doc size Complete Request Req per secs Longest Req

www.mimos.my

20 30600 bytes 100%

20 46200 bytes 100%

8.4 5302ms

10.98 2103ms

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmark : Specs • • • •

www.mimos.my

AMD Turion 64 1MB L2 Cache, 1.8 GHz 1GB RAM OS- Karmic Koala

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmark : apacheBench • -n 5000 • -c 500

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmark : nginx

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmark : apache (runs..)

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmark : apache (end)

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Benchmark : Findings

Concurrency Doc size Complete Request Req per secs Longest Req

www.mimos.my

Apache 2.2.12 500 2195 bytes 100%

Nginx 0.7.62 500 2195 bytes 100%

327

3003

15269ms

296ms

© 2011 MIMOS Berhad. All Rights Reserved.

“Every nanoseconds count!” - My Big Boss (your boss also) http://www.flickr.com/photos/20509716@N00/4162719773/sizes/m/

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

http://www.greenpeace.org/australia/solutions/

Demo

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

Resources • • • •

http://wiki.nginx.org/Main Nedelcu’s book http://goo.gl/67OA http://php-fpm.org/ http://nginx.org

www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.

THANK YOU @errazudin [email protected] [email protected] * All images, logos and data are the copyright of their respective owners www.mimos.my

© 2011 MIMOS Berhad. All Rights Reserved.