Turbocharge Your PHP
                                      with Nginx




                                       Errazudin...
Agenda

        • me
        • “engine X”
        • nginx.conf
        • ..with PHP
        • Benchmark
        • Samples
...
"Apache is like Microsoft Word, it has a million options
      but you only need six. Nginx does those six things, and it
...
Me
        • Senior engineer @ Mimos Malaysia
        • Focuses on web application development,
          deployment, perf...
www.mimos.my   © 2010 MIMOS Berhad. All Rights Reserved.
nginx

        • Free
        • X platform
        • open-source
        • (high-performance)
        • lightweight
      ...
http://noisetu.be/mirrors/jet_beetle/



        “I'm the author of nginx (pronounced "engine x")-
        Igor Sysoev
   ...
http://image.importtuner.com/f/miscellaneous/new-tomei-turbo-kits-for-sr/29774779/tomei-bolt-on-turbo-kit-for-sr.jpg




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




               Loads of Request
               Less memory...
http://www.gtrblog.com/wp-content/uploads/2008/11/gtr-gt2-nurburgring-001.jpg




                                        ...
Numbers

                                                           http://www.scoobyworld.co.uk/catalog/images/BFamber-1....
Market Share for Top Servers Across All Domains
                                                                    213,45...
Market Share for Top Servers Across the Million Busiest
          Sites




Source :
Netcraft
  www.mimos.my             ©...
Market Share for Top Servers Across All Domains

                                                                    227,2...
Market Share for Top Servers Across the Million Busiest
          Sites




Source :
Netcraft
  www.mimos.my             ©...
http://www.autoguide.com/auto-news/wp-content/uploads/2010/09/The_Stig_Top_Gear_Eight.jpg




                            ...
Me uses nginx




www.mimos.my        © 2010 MIMOS Berhad. All Rights Reserved.
Me uses nginx




www.mimos.my        © 2010 MIMOS Berhad. All Rights Reserved.
We also..




www.mimos.my        © 2010 MIMOS Berhad. All Rights Reserved.
We all love nginx…




www.mimos.my        © 2010 MIMOS Berhad. All Rights Reserved.
Modules

                          Mail, 3rd
                           Party
                           Optional
        ...
Modules


               Mail Core, Mail Auth, Mail Proxy, Mail SSL


 HTTP Addition, Emb. Perl, FLV, Gzip Precompression,...
Nginx with PHP

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




...
Nginx with PHP : FastCGI

        • persistent processes, ability to handle multiple
          requests.
        • web ser...
Nginx with PHP : FastCGI

     server {
       server_name mysite.com;
       listen 80;
       root /usr/share/mysite/www...
PHP-FPM

        • FastCGI Process Manager
        • Daemonizes PHP > background proc
        • provides a command-line sc...
Benchmark
http://www.myshutterspace.com/profile/AthonySaucedo



        www.mimos.my                                  © 2...
Benchmark : Specs

        •      AMD Turion 64
        •      1MB L2 Cache, 1.8 GHz
        •      1GB RAM
        •     ...
Benchmark : apacheBench

        • -n 5000
        • -c 500




www.mimos.my        © 2010 MIMOS Berhad. All Rights Reserv...
Benchmark : nginx




www.mimos.my        © 2010 MIMOS Berhad. All Rights Reserved.
Benchmark : apache (runs..)




www.mimos.my        © 2010 MIMOS Berhad. All Rights Reserved.
Benchmark : apache (end)




www.mimos.my        © 2010 MIMOS Berhad. All Rights Reserved.
Benchmark : Findings


                Apache 2.2.12               Nginx 0.7.62
Concurrency     500                       ...
“Every nanoseconds count!” - My Big Boss
               (your boss also)
                                                 ...
Resources


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




                                        Demo


www.mimos.my   © 2010 MIMOS Berhad. All Rights Reser...
THANK YOU

                                                                                                    @errazudin
...
Upcoming SlideShare
Loading in …5
×

turbocharge your php with nginx - errazudin - phpnw2010

3,525 views

Published on

turbocharge your php with nginx by @errazudin #phpnw2010

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
3,525
On SlideShare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
35
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

turbocharge your php with nginx - errazudin - phpnw2010

  1. 1. Turbocharge Your PHP with Nginx Errazudin Ishak www.mimos.my © 2009 MIMOS Berhad. All Rights Reserved.
  2. 2. Agenda • me • “engine X” • nginx.conf • ..with PHP • Benchmark • Samples www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  3. 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. 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. 5. www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  6. 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. 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. 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. 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. 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. 11. Numbers http://www.scoobyworld.co.uk/catalog/images/BFamber-1.jpg www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  12. 12. Market Share for Top Servers Across All Domains 213,458,815 Source : Netcraft www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  13. 13. Market Share for Top Servers Across the Million Busiest Sites Source : Netcraft www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  14. 14. Market Share for Top Servers Across All Domains 227,225,642 Source : Netcraft www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  15. 15. Market Share for Top Servers Across the Million Busiest Sites Source : Netcraft www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  16. 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. 17. Me uses nginx www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  18. 18. Me uses nginx www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  19. 19. We also.. www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  20. 20. We all love nginx… www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  21. 21. Modules Mail, 3rd Party Optional HTTP Standard HTTP Core www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  22. 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. 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. 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. 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. 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. 27. Benchmark http://www.myshutterspace.com/profile/AthonySaucedo www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  28. 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. 29. Benchmark : apacheBench • -n 5000 • -c 500 www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  30. 30. Benchmark : nginx www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  31. 31. Benchmark : apache (runs..) www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  32. 32. Benchmark : apache (end) www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  33. 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. 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. 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. 36. http://goo.gl/EbTI Demo www.mimos.my © 2010 MIMOS Berhad. All Rights Reserved.
  37. 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.

×