turbocharge your php with nginx - errazudin - phpnw2010

  • 3,069 views
Uploaded on

turbocharge your php with nginx by @errazudin #phpnw2010

turbocharge your php with nginx by @errazudin #phpnw2010

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
3,069
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
32
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 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.
  • 5. 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.
  • 7. http://noisetu.be/mirrors/jet_beetle/ “I'm the author of nginx (pronounced "engine x")- Igor Sysoev (nginx creator) www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  • 8. http://image.importtuner.com/f/miscellaneous/new-tomei-turbo-kits-for-sr/29774779/tomei-bolt-on-turbo-kit-for-sr.jpg Load Balance Static Content, Index files Reverse Proxy (with cache) Streaming www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  • 9. http://www.litchfieldimports.co.uk/forum/gtr-engine-bay.jpg Loads of Request Less memory footprint Use less CPU C10K Certified www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  • 10. http://www.gtrblog.com/wp-content/uploads/2008/11/gtr-gt2-nurburgring-001.jpg Apache -------- ---------- Async model Processes Single Thread Threads Low Memory High Memory Less CPU CPU Overhead PHP as separate proc. PHP included as over FastCGI module (mod_php) 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.
  • 16. http://www.autoguide.com/auto-news/wp-content/uploads/2010/09/The_Stig_Top_Gear_Eight.jpg Who? www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  • 17. Me uses nginx www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  • 18. Me uses nginx www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  • 19. We also.. 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.
  • 27. Benchmark http://www.myshutterspace.com/profile/AthonySaucedo 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.
  • 29. Benchmark : apacheBench • -n 5000 • -c 500 www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  • 30. Benchmark : nginx www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  • 31. Benchmark : apache (runs..) www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  • 32. Benchmark : apache (end) 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.
  • 36. http://goo.gl/EbTI Demo 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.