Fisl - Deployment
Upcoming SlideShare
Loading in...5
×
 

Fisl - Deployment

on

  • 3,192 views

Histórico das maneiras de deployment de Ruby on Rails, até o Passenger, na FISL em Porto Alegre.

Histórico das maneiras de deployment de Ruby on Rails, até o Passenger, na FISL em Porto Alegre.

Statistics

Views

Total Views
3,192
Views on SlideShare
3,156
Embed Views
36

Actions

Likes
4
Downloads
28
Comments
0

4 Embeds 36

http://www.akitaonrails.com 27
http://akitaonrails.com 5
http://www.slideshare.net 3
http://192.168.10.100 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Fisl - Deployment Fisl - Deployment Presentation Transcript

  • Deployment de Rails Fabio Akita www.akitaonrails.com
  • Deployment de Rails
  • +7000 pessoas no WWR
  • +7000 pessoas no WWR +3 anos
  • +7000 pessoas no WWR +3 anos +8M hits no Google
  • “Rails Escala?”
  • “Sim, Rails Escala!”
  • Rails 1.0 em 2005
  • Rails 1.0 em 2005 MySQL
  • Rails 1.0 em 2005 MySQL LightTPD + Fast CGI
  • Database/Storage
  • Database/Storage “Rails Stack”
  • Database/Storage “Rails Stack” HTTP Server/Load Balancer
  • Database
  • MySQL PostgreSQL Oracle/SQL Server/Informix/Sybase ...
  • MySQL PostgreSQL Oracle/SQL Server/Informix/Sybase ... MEMCACHED
  • Rails App Database
  • Rails App Database
  • MEMCACHED Rails App Database
  • MEMCACHED Rails App Database Slave
  • class Post < ActiveRecord::Base end
  • class Post < ActiveRecord::Base acts_as_cached after_destroy :expire_cache end
  • http://errtheblog.com/posts/57-kickin-ass-w-cachefu
  • HTTP Servers
  • Maduro Apache 2.x Mais “pesado”
  • Maduro Apache 2.x Mais “pesado” Nginx 0.5 Rápido
  • Maduro Apache 2.x Mais “pesado” Nginx 0.5 Rápido Rápido Litespeed 3.x Comercial
  • FastCGI Instável
  • FastCGI Instável SAPI Rápido
  • FastCGI Instável SAPI Rápido HTTP Estável Proxy Reverso
  • FastCGI Instável SAPI Rápido HTTP Estável Proxy Reverso mod_rails recém-chegado
  • HTTP “Rails Stack” Server
  • FCGI HTTP “Rails Stack” Server
  • FCGI HTTP SAPI “Rails Stack” Server
  • FCGI HTTP SAPI “Rails Stack” Server HTTP
  • “Rails Stack” FCGI HTTP SAPI “Rails Stack” Server HTTP “Rails Stack”
  • Rails Stack
  • “Rails Stack”
  • “Rails Stack” Ruby VM (MRI)
  • “Rails Stack” RubyGems Ruby VM (MRI)
  • Ruby on Rails “Rails Stack” RubyGems Ruby VM (MRI)
  • Ruby on Rails Mongrel “Rails Stack” RubyGems Ruby VM (MRI)
  • Rails, ActiveSupport, ActiveRecord, ActionPack
  • Rails, ActiveSupport, ActiveRecord, ActionPack ActionMailer, ActiveResource, ActionWS
  • Rails, ActiveSupport, ActiveRecord, ActionPack ActionMailer, ActiveResource, ActionWS Capistrano, Net-SSH, Net-SFTP
  • Rails, ActiveSupport, ActiveRecord, ActionPack ActionMailer, ActiveResource, ActionWS Capistrano, Net-SSH, Net-SFTP Mongrel, Mongrel Cluster
  • Rails, ActiveSupport, ActiveRecord, ActionPack ActionMailer, ActiveResource, ActionWS Capistrano, Net-SSH, Net-SFTP Mongrel, Mongrel Cluster Rmagick, Mini Magick, Image Science
  • Rails, ActiveSupport, ActiveRecord, ActionPack ActionMailer, ActiveResource, ActionWS Capistrano, Net-SSH, Net-SFTP Mongrel, Mongrel Cluster Rmagick, Mini Magick, Image Science Rspec, ZenTest
  • Mongrel Multi-threaded
  • Mongrel Multi-threaded Rails Non-concurrent
  • Mongrel
  • Ruby on Rails Mongrel
  • Outras Gems Ruby on Rails Mongrel
  • Sua Applicação Outras Gems Ruby on Rails Mongrel
  • “Rails Stack”
  • Mongrel Cluster
  • Mongrel Cluster Load Balancer
  • Monit God
  • objetos Ruby VM
  • objetos objetos Ruby VM
  • GC objetos objetos Ruby VM
  • objetos objetos Ruby VM
  • Memória Livre não desalocada objetos objetos Ruby VM
  • Monit Rails App
  • Rails App Monit
  • Monit Rails App
  • Load Balancer
  • Rails + Mongrel Rails + Mongrel Rails + Mongrel Load Balancer Rails + Mongrel Rails + Mongrel Rails + Mongrel
  • Capistrano
  • capify . cap setup cap deploy cap rollback
  • capify . set :application, quot;mey_aplicativoquot; set :repository, quot;git://server.com/projeto.gitquot; set :deploy_to, quot;/var/www/#{application}quot; cap setup default_run_options[:pty] = true set :repository, quot;git@github.com:user/rails-app.gitquot; set :scm, quot;gitquot; set :scm_passphrase, quot;p00pquot; set :user, quot;deployerquot; cap deploy set :branch, quot;origin/masterquot; set :deploy_via, :remote_cache set :git_shallow_clone, 1 set :git_enable_submodules, 1 cap rollback
  • capify . cap setup cap deploy cap rollback
  • capify . cap setup cap deploy cap rollback
  • capify . cap setup cap deploy cap rollback
  • Desktop
  • SCM (Git) Desktop
  • SCM (Git) Desktop
  • SCM (Git) Desktop
  • SCM Staging (Git) Cap Desktop
  • SCM Staging (Git) Cap Desktop
  • SCM Staging (Git) Cap Desktop
  • SCM Staging (Git) Cap Desktop Production Cap
  • SCM Staging (Git) Cap Desktop Production Cap
  • SCM Staging (Git) Cap Desktop Production Cap
  • SCM Desktop (Git)
  • SCM Desktop (Git) Production Production Production Production Cap Cap Cap Cap Production Production Production Production Cap Cap Cap Cap
  • http://capify.org/
  • Quantos Mongrels?
  • Apache Bench • Blog Demo • Post resource • (1 query, 20 rows)
  • Apache Bench
  • Apache Bench ab -n 1000 http://127.0.0.1:3000/posts
  • Apache Bench ab -n 1000 http://127.0.0.1:3000/posts 1 conexão 1000 requisições
  • Apache Bench ab -n 5000 -c 10 http://127.0.0.1:3000/posts
  • Apache Bench ab -n 5000 -c 10 http://127.0.0.1:3000/posts 10 conexões 5000 requisições
  • Nginx - 3 Mongrels
  • Nginx - 3 Mongrels req/s (mean) 1000 requests 1 conexão 5000 requests 10 conexões
  • Nginx - 3 Mongrels req/s (mean) Hello World 1000 requests 414.56 1 conexão 5000 requests 701.88 10 conexões
  • Nginx - 3 Mongrels Posts req/s (mean) Hello World (puro) 1000 requests 414.56 24.44 1 conexão 5000 requests 701.88 39.31 10 conexões
  • Nginx - 3 Mongrels Posts Posts req/s (mean) Hello World (page (puro) cache) 1000 requests 414.56 24.44 1587.31 1 conexão 5000 requests 701.88 39.31 2220.24 10 conexões
  • Nginx - 3 Mongrels Posts Posts Posts req/s (mean) Hello World (page (action (puro) cache) cache) 1000 requests 414.56 24.44 1587.31 106.29 1 conexão 5000 requests 701.88 39.31 2220.24 96.81 10 conexões
  • Memória
  • Memória 1 Mongrel, ~30 Mb 1 Rails vazio
  • Memória 1 Mongrel, ~30 Mb 1 Rails vazio 1 Mongrel, ~70Mb 1 Mephisto
  • http://www.scribd.com/doc/97641/ JHoffmanRailsConfMay2007
  • Estratégias
  • Rails Cache (Page/Action/Fragment)
  • Rails Cache (Page/Action/Fragment) MEMCACHED
  • Rails Cache (Page/Action/Fragment) MEMCACHED Asynchronous Processes (BackgrounDRb, cronjobs, etc)
  • class PostsController < Application def action # código lento end end # http://www.site.com/posts
  • class PostsController < Application def action PERIGO! # código lento end end # http://www.site.com/posts
  • class PostsController < Application def action MiddleMan.new_worker( :class => :heavy) end end class Heavy < BackgrounDRb::Worker::RailsBase def do_work(options) # código lento end end
  • Tempo de Execução Rails Request
  • Tempo de Execução Rails Request CACHE
  • Tempo de Execução Rails Request
  • Tempo de Execução Rails Request Async
  • Tempo de Execução Rails Request Outros
  • 920 pageviews/dia ~30 req/s pico USD 370/mês
  • Deployment comum
  • Cap
  • Nginx Cap
  • MySQL Nginx Cap
  • MySQL Nginx Memcached Cap
  • MySQL Nginx Memcached Cap Git
  • Desafios
  • Performance Green Threads x Native Thread + GIL Memory Management C Extensions Interoperability
  • Performance Green Threads x Native Thread + GIL Memory Management C Extensions Interoperability
  • Performance Green Threads x Native Thread + GIL Memory Management C Extensions Interoperability
  • Performance Green Threads x Native Thread + GIL Memory Management C Extensions Interoperability
  • Performance Green Threads x Native Thread + GIL Memory Management C Extensions Interoperability
  • Instalação
  • Instalação aptitude install apache2 apache2­mpm­prefork  ruby1.8 dev apache2­prefork­dev gem install passenger ./passenger­install­apache2­module cd /var/www ; rails .
  • Instalação aptitude install apache2 apache2­mpm­prefork  ruby1.8 dev apache2­prefork­dev gem install passenger ./passenger­install­apache2­module cd /var/www ; rails .
  • Instalação aptitude install apache2 apache2­mpm­prefork  ruby1.8 dev apache2­prefork­dev gem install passenger ./passenger­install­apache2­module cd /var/www ; rails .
  • Instalação aptitude install apache2 apache2­mpm­prefork  ruby1.8 dev apache2­prefork­dev gem install passenger ./passenger­install­apache2­module cd /var/www ; rails .
  • LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/ passenger-1.0.1/ext/apache2/mod_passenger.so RailsSpawnServer /opt/local/lib/ruby/gems/1.8/gems/passenger-1.0.1/bin/ passenger-spawn-server RailsRuby /opt/local/bin/ruby <Directory quot;/Users/akitaonrails/rails/blog/publicquot;> Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName localhost DocumentRoot /Users/akitaonrails/rails/blog/public </VirtualHost>
  • Benchmarks Mongrel Thin Passenger
  • Benchmarks Mongrel Thin Passenger
  • Obrigado! www.akitaonrails.com