Making Joomla! site fly with nginx : Joomla! day Malaysia 2011

Post on 19-May-2015

4,611 views 3 download

transcript

www.mimos.my © 2009 MIMOS Berhad. All Rights Reserved.

Errazudin Ishak

Making Joomla! Site fly with Nginx

Joomla! Day Malaysia 2011

• Me

• Joomla!

• “engine X”

• Benchmarks

• Samples

Agenda

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

• 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, Wordpress Conf. Asia

About Me

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Joomla!

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

23.5mil Techcrunch June 11th;

http://goo.gl/DTveS

*downloads

Joomla! 1.6

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

+2.5mil Techcrunch June 11th;

http://goo.gl/DTveS

*downloads

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

• Free

• X platform

• open-source

• (high-performance)

• lightweight

• HTTP server

• reverse proxy

• IMAP/POP3 proxy server

nginx

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

“I'm the author of nginx (pronounced "engine x")- Igor Sysoev (nginx creator)

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

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

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

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

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Loads of Request Less memory footprint Use less CPU C10K Certified

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

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

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

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

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

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Numbers

Boston.com

Market Share for Top Servers Across All Domains

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Source :

Netcraft

Market Share for Top Servers Across All Domains

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Source :

Netcraft

Market Share for Top Servers Across the Million Busiest Sites

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Source :

Netcraft

Market Share for Top Servers Across the Million Busiest Sites

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Source :

Netcraft

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Who?

http://goo.gl/KJC8H

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.

Modules

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Mail, 3rd

Party

Optional

HTTP

Standard HTTP

Core

Modules

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Main, Events

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

HTTP Addition, Emb. Perl, FLV, Gzip Precompression, Random Index, GeoIP, Real IP, SSL, Stub Status, Substitution, WebDAV, Google Perftools,

XSLT, Secure Link, Image Filter

Mail Core, Mail Auth, Mail Proxy, Mail SSL

• FastCGI

• PHP-FPM (FastCGI Process Manager)

• Bundled with PHP 5.3.3

Nginx with PHP

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

• 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.

Nginx with PHP : FastCGI

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

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;

}

}

Nginx with PHP : FastCGI

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

server {

server_name yourdomain.com;

large_client_header_buffers 4 8k;

root /var/www/joomla;

index index.php index.html;

location / {

try_files $uri $uri/ /index.php?q=$request_uri;

}

location ~ \.php$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi_params;

fastcgi_param SCRIPT_FILENAME

$document_root$fastcgi_script_name;

}

}

Nginx with Joomla!

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

• 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

PHP-FPM

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Benchmarks

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

• Intel Core Duo

• T2400, 1.83 GHz

• 2GB RAM

• OS- Fedora 12

Benchmark : Specs

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

• -n 100

• -c 20

Benchmark : apacheBench

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 : Findings

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Apache 2.2.15 Nginx 0.7.67

Concurrency 20 20

Doc size 674600bytes 658000bytes

Complete Request

100% 100%

Req per secs 7.2 8.8

Longest Req 4848ms 2638ms

• -n 500

• -c 50

Benchmark : apacheBench

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 : Findings

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Apache 2.2.12 Nginx 0.7.62

Concurrency 50 50

Doc size 3373300 bytes 3290000 bytes

Complete Request

100% 100%

Req per secs 7.93 8.47

Longest Req 12154 ms 6374 ms

• -n 1000

• -c 100

Benchmark : apacheBench

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 : Findings

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Apache 2.2.12 Nginx 0.7.62

Concurrency 100 100

Doc size 6746000 bytes 6580000 bytes

Complete Request

100% 100%

Req per secs 7.91 8.48

Longest Req 19268 ms 12196 ms

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

“Every nanoseconds count!” - My Big Boss (your boss also)

http://goo.gl/4SAnf

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

Demo

http://goo.gl/xmdsy

Resources

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

• http://wiki.nginx.org/Main

• Nedelcu’s book http://goo.gl/67OA

• Nginx 1 Web Server Implementation Cookbook http://goo.gl/46UYq

• http://php-fpm.org/

• http://nginx.org

THANK YOU

www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.

errazudin.ishak@mimos.my

* All images, logos and data are the copyright of their respective owners

errazudin.ishak@gmail.com

@errazudin