Contenu connexe
Similaire à turbocharge your php with nginx - errazudin - phpnw2010 (20)
turbocharge your php with nginx - errazudin - phpnw2010
- 1. Turbocharge Your PHP
with Nginx
Errazudin Ishak
www.mimos.my © 2009 MIMOS Berhad. All Rights Reserved.
- 2. Agenda
• me
• “engine X”
• nginx.conf
• ..with PHP
• Benchmark
• Samples
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 3. "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 © 2010 MIMOS Berhad. All Rights Reserved.
- 4. Me
• Senior engineer @ Mimos Malaysia
• Focuses on web application development,
deployment, performance and stability.
• 2009 : foss.my , MyGOSSCON
• 2010 : Entp. PHP Techtalk, BarcampKL, PHP
Meetup, MOSC2010
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 6. nginx
• Free
• X platform
• open-source
• (high-performance)
• lightweight
• HTTP server
• reverse proxy
• IMAP/POP3 proxy server
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 11. Numbers
http://www.scoobyworld.co.uk/catalog/images/BFamber-1.jpg
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 12. Market Share for Top Servers Across All Domains
213,458,815
Source :
Netcraft
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 13. Market Share for Top Servers Across the Million Busiest
Sites
Source :
Netcraft
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 14. Market Share for Top Servers Across All Domains
227,225,642
Source :
Netcraft
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 15. Market Share for Top Servers Across the Million Busiest
Sites
Source :
Netcraft
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 20. We all love nginx…
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 21. Modules
Mail, 3rd
Party
Optional
HTTP
Standard
HTTP
Core
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 22. 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 © 2010 MIMOS Berhad. All Rights Reserved.
- 23. Nginx with PHP
• FastCGI
• PHP-FPM (FastCGI Process Manager)
• Bundled with PHP 5.3.3
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 24. 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 © 2010 MIMOS Berhad. All Rights Reserved.
- 25. 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 © 2010 MIMOS Berhad. All Rights Reserved.
- 26. 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 © 2010 MIMOS Berhad. All Rights Reserved.
- 28. Benchmark : Specs
• AMD Turion 64
• 1MB L2 Cache, 1.8 GHz
• 1GB RAM
• OS- Karmic Koala
• (my old 4 y.o. Acer)
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 33. Benchmark : Findings
Apache 2.2.12 Nginx 0.7.62
Concurrency 500 500
Doc size 2195 bytes 2195 bytes
Complete 100% 100%
Request
Req per secs 327 3003
Longest Req 15269ms 296ms
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 34. “Every nanoseconds count!” - My Big Boss
(your boss also)
http://geekonfilm.files.wordpress.com/2009/09/vader.jpg
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 35. Resources
• http://wiki.nginx.org/Main
• Nedelcu’s book http://goo.gl/67OA
• http://php-fpm.org/
• http://nginx.org
• #nginx
www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
- 37. THANK YOU
@errazudin
http://joind.in/2067
* All images, logos and data are the copyright of
their respective owners
www.mimos.my © 2009 MIMOS Berhad. All Rights Reserved.