Serving Up Your Rails App On A Mongrel Cluster

32
Serving up your Rails app on a Mongrel cluster Andy Lo-A-Foe [email protected]

description

Andy Lo-A-Foe's slide's of his presentation at the RubyenRails 2007 conf in Amsterdam.

Transcript of Serving Up Your Rails App On A Mongrel Cluster

Page 1: Serving Up Your Rails App On A Mongrel Cluster

Serving up your Rails app on a

Mongrel cluster

Andy [email protected]

Page 2: Serving Up Your Rails App On A Mongrel Cluster

$ whoami

Page 3: Serving Up Your Rails App On A Mongrel Cluster

$ whoami

• Brood: Web ontwikkelaar / Linux

Page 4: Serving Up Your Rails App On A Mongrel Cluster

$ whoami

• Brood: Web ontwikkelaar / Linux

• Deed: PHP / Java

Page 5: Serving Up Your Rails App On A Mongrel Cluster

$ whoami

• Brood: Web ontwikkelaar / Linux

• Deed: PHP / Java

• Doet: Rails / Architectuur / etc..

Page 6: Serving Up Your Rails App On A Mongrel Cluster

$ whoami

• Brood: Web ontwikkelaar / Linux

• Deed: PHP / Java

• Doet: Rails / Architectuur / etc..

• Bij: IndependentIP

Page 7: Serving Up Your Rails App On A Mongrel Cluster

Wat is Mongrel?

Page 8: Serving Up Your Rails App On A Mongrel Cluster

Wat is Mongrel?

• http://mongrel.rubyforge.org

Page 9: Serving Up Your Rails App On A Mongrel Cluster

Wat is Mongrel?

• http://mongrel.rubyforge.org• Mongrel is a fast HTTP library and

server for Ruby that is intended for hosting Ruby web applications of any kind using plain HTTP rather than FastCGI or SCGI.

Page 10: Serving Up Your Rails App On A Mongrel Cluster

Wat is Mongrel?

• http://mongrel.rubyforge.org• Mongrel is a fast HTTP library and

server for Ruby that is intended for hosting Ruby web applications of any kind using plain HTTP rather than FastCGI or SCGI.

• Ontwikkelt door Zed Shaw (http://www.zedshaw.com) en anderen..

Page 11: Serving Up Your Rails App On A Mongrel Cluster

Waarom Mongrel? (IMHO)

Page 12: Serving Up Your Rails App On A Mongrel Cluster

Waarom Mongrel? (IMHO)

• Snelheid? nope

Page 13: Serving Up Your Rails App On A Mongrel Cluster

Waarom Mongrel? (IMHO)

• Snelheid? nope

• FastCGI zuigt? nope

Page 14: Serving Up Your Rails App On A Mongrel Cluster

Waarom Mongrel? (IMHO)

• Snelheid? nope

• FastCGI zuigt? nope

• Koelheid? yep!

Page 15: Serving Up Your Rails App On A Mongrel Cluster

Waarom Mongrel? (IMHO)

• Snelheid? nope

• FastCGI zuigt? nope

• Koelheid? yep!

• Eenvoudig? yep!

Page 16: Serving Up Your Rails App On A Mongrel Cluster

Waarom Mongrel? (IMHO)

• Snelheid? nope

• FastCGI zuigt? nope

• Koelheid? yep!

• Eenvoudig? yep!

• Monitoring? yep!

Page 17: Serving Up Your Rails App On A Mongrel Cluster

Installatie

Page 18: Serving Up Your Rails App On A Mongrel Cluster

Installatie

• Uitgebreide documentatie op het web: http://mongrel.rubyforge.org

Page 19: Serving Up Your Rails App On A Mongrel Cluster

Installatie

• Uitgebreide documentatie op het web: http://mongrel.rubyforge.org

• $ sudo gem install mongrel mongrel_cluster --include-dependencies

Page 20: Serving Up Your Rails App On A Mongrel Cluster

Installatie

• Uitgebreide documentatie op het web: http://mongrel.rubyforge.org

• $ sudo gem install mongrel mongrel_cluster --include-dependencies

• $ sudo gem install fastthread

Page 21: Serving Up Your Rails App On A Mongrel Cluster

Installatie

• Uitgebreide documentatie op het web: http://mongrel.rubyforge.org

• $ sudo gem install mongrel mongrel_cluster --include-dependencies

• $ sudo gem install fastthread

• $ cd rails_app_root

Page 22: Serving Up Your Rails App On A Mongrel Cluster

Installatie

• Uitgebreide documentatie op het web: http://mongrel.rubyforge.org

• $ sudo gem install mongrel mongrel_cluster --include-dependencies

• $ sudo gem install fastthread

• $ cd rails_app_root

• $ mongrel_rails start

Page 23: Serving Up Your Rails App On A Mongrel Cluster

Installatie

• Uitgebreide documentatie op het web: http://mongrel.rubyforge.org

• $ sudo gem install mongrel mongrel_cluster --include-dependencies

• $ sudo gem install fastthread

• $ cd rails_app_root

• $ mongrel_rails start

• Profit!

Page 24: Serving Up Your Rails App On A Mongrel Cluster

Clusters/Apache/.../

Lighttpd(1.5.0)NginxPound

...

Share nothing

Page 25: Serving Up Your Rails App On A Mongrel Cluster

Apache configRewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -fRewriteCond %{SCRIPT_FILENAME} !maintenance.htmlRewriteRule ^.*$ /system/maintenance.html [L]

# Redirect all non-static requests to clusterRewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-fRewriteRule ^/(.*)$ balancer://filmpjes_cluster% {REQUEST_URI} [P,QSA,L]

<Proxy balancer://filmpjes_cluster> BalancerMember http://127.0.0.1:9000 BalancerMember http://127.0.0.1:9001 BalancerMember http://127.0.0.1:9002 BalancerMember http://127.0.0.1:9003 ....... </Proxy>

Page 26: Serving Up Your Rails App On A Mongrel Cluster

Performance

Page 27: Serving Up Your Rails App On A Mongrel Cluster

Performance

• Statische content door Apache (of lighty..)

Page 28: Serving Up Your Rails App On A Mongrel Cluster

Performance

• Statische content door Apache (of lighty..)

• Dynamische content door cluster

Page 29: Serving Up Your Rails App On A Mongrel Cluster

Performance

• Statische content door Apache (of lighty..)

• Dynamische content door cluster

• Cache, cache, cache

Page 30: Serving Up Your Rails App On A Mongrel Cluster

Caching

• Page / Action / Fragment

• /dyn/140x104/11126/2.jpg

• mapping

• controller rendered en schrijft resultaat weg in public/dyn/140x104/111126/2.jpg

• serveert via send_file :disposition => true

• volgende request via Apache

Page 31: Serving Up Your Rails App On A Mongrel Cluster

Monitoring

• MONIT!!

• http://www.tildeslash.com/monit/

Page 32: Serving Up Your Rails App On A Mongrel Cluster

Vragen?

• Meer info op http://www.railsguru.com