Fisl - Deployment

2,068 views

Published on

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

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

No Downloads
Views
Total views
2,068
On SlideShare
0
From Embeds
0
Number of Embeds
39
Actions
Shares
0
Downloads
30
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Fisl - Deployment

  1. 1. Deployment de Rails Fabio Akita www.akitaonrails.com
  2. 2. Deployment de Rails
  3. 3. +7000 pessoas no WWR
  4. 4. +7000 pessoas no WWR +3 anos
  5. 5. +7000 pessoas no WWR +3 anos +8M hits no Google
  6. 6. “Rails Escala?”
  7. 7. “Sim, Rails Escala!”
  8. 8. Rails 1.0 em 2005
  9. 9. Rails 1.0 em 2005 MySQL
  10. 10. Rails 1.0 em 2005 MySQL LightTPD + Fast CGI
  11. 11. Database/Storage
  12. 12. Database/Storage “Rails Stack”
  13. 13. Database/Storage “Rails Stack” HTTP Server/Load Balancer
  14. 14. Database
  15. 15. MySQL PostgreSQL Oracle/SQL Server/Informix/Sybase ...
  16. 16. MySQL PostgreSQL Oracle/SQL Server/Informix/Sybase ... MEMCACHED
  17. 17. Rails App Database
  18. 18. Rails App Database
  19. 19. MEMCACHED Rails App Database
  20. 20. MEMCACHED Rails App Database Slave
  21. 21. class Post < ActiveRecord::Base end
  22. 22. class Post < ActiveRecord::Base acts_as_cached after_destroy :expire_cache end
  23. 23. http://errtheblog.com/posts/57-kickin-ass-w-cachefu
  24. 24. HTTP Servers
  25. 25. Maduro Apache 2.x Mais “pesado”
  26. 26. Maduro Apache 2.x Mais “pesado” Nginx 0.5 Rápido
  27. 27. Maduro Apache 2.x Mais “pesado” Nginx 0.5 Rápido Rápido Litespeed 3.x Comercial
  28. 28. FastCGI Instável
  29. 29. FastCGI Instável SAPI Rápido
  30. 30. FastCGI Instável SAPI Rápido HTTP Estável Proxy Reverso
  31. 31. FastCGI Instável SAPI Rápido HTTP Estável Proxy Reverso mod_rails recém-chegado
  32. 32. HTTP “Rails Stack” Server
  33. 33. FCGI HTTP “Rails Stack” Server
  34. 34. FCGI HTTP SAPI “Rails Stack” Server
  35. 35. FCGI HTTP SAPI “Rails Stack” Server HTTP
  36. 36. “Rails Stack” FCGI HTTP SAPI “Rails Stack” Server HTTP “Rails Stack”
  37. 37. Rails Stack
  38. 38. “Rails Stack”
  39. 39. “Rails Stack” Ruby VM (MRI)
  40. 40. “Rails Stack” RubyGems Ruby VM (MRI)
  41. 41. Ruby on Rails “Rails Stack” RubyGems Ruby VM (MRI)
  42. 42. Ruby on Rails Mongrel “Rails Stack” RubyGems Ruby VM (MRI)
  43. 43. Rails, ActiveSupport, ActiveRecord, ActionPack
  44. 44. Rails, ActiveSupport, ActiveRecord, ActionPack ActionMailer, ActiveResource, ActionWS
  45. 45. Rails, ActiveSupport, ActiveRecord, ActionPack ActionMailer, ActiveResource, ActionWS Capistrano, Net-SSH, Net-SFTP
  46. 46. Rails, ActiveSupport, ActiveRecord, ActionPack ActionMailer, ActiveResource, ActionWS Capistrano, Net-SSH, Net-SFTP Mongrel, Mongrel Cluster
  47. 47. Rails, ActiveSupport, ActiveRecord, ActionPack ActionMailer, ActiveResource, ActionWS Capistrano, Net-SSH, Net-SFTP Mongrel, Mongrel Cluster Rmagick, Mini Magick, Image Science
  48. 48. Rails, ActiveSupport, ActiveRecord, ActionPack ActionMailer, ActiveResource, ActionWS Capistrano, Net-SSH, Net-SFTP Mongrel, Mongrel Cluster Rmagick, Mini Magick, Image Science Rspec, ZenTest
  49. 49. Mongrel Multi-threaded
  50. 50. Mongrel Multi-threaded Rails Non-concurrent
  51. 51. Mongrel
  52. 52. Ruby on Rails Mongrel
  53. 53. Outras Gems Ruby on Rails Mongrel
  54. 54. Sua Applicação Outras Gems Ruby on Rails Mongrel
  55. 55. “Rails Stack”
  56. 56. Mongrel Cluster
  57. 57. Mongrel Cluster Load Balancer
  58. 58. Monit God
  59. 59. objetos Ruby VM
  60. 60. objetos objetos Ruby VM
  61. 61. GC objetos objetos Ruby VM
  62. 62. objetos objetos Ruby VM
  63. 63. Memória Livre não desalocada objetos objetos Ruby VM
  64. 64. Monit Rails App
  65. 65. Rails App Monit
  66. 66. Monit Rails App
  67. 67. Load Balancer
  68. 68. Rails + Mongrel Rails + Mongrel Rails + Mongrel Load Balancer Rails + Mongrel Rails + Mongrel Rails + Mongrel
  69. 69. Capistrano
  70. 70. capify . cap setup cap deploy cap rollback
  71. 71. 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
  72. 72. capify . cap setup cap deploy cap rollback
  73. 73. capify . cap setup cap deploy cap rollback
  74. 74. capify . cap setup cap deploy cap rollback
  75. 75. Desktop
  76. 76. SCM (Git) Desktop
  77. 77. SCM (Git) Desktop
  78. 78. SCM (Git) Desktop
  79. 79. SCM Staging (Git) Cap Desktop
  80. 80. SCM Staging (Git) Cap Desktop
  81. 81. SCM Staging (Git) Cap Desktop
  82. 82. SCM Staging (Git) Cap Desktop Production Cap
  83. 83. SCM Staging (Git) Cap Desktop Production Cap
  84. 84. SCM Staging (Git) Cap Desktop Production Cap
  85. 85. SCM Desktop (Git)
  86. 86. SCM Desktop (Git) Production Production Production Production Cap Cap Cap Cap Production Production Production Production Cap Cap Cap Cap
  87. 87. http://capify.org/
  88. 88. Quantos Mongrels?
  89. 89. Apache Bench • Blog Demo • Post resource • (1 query, 20 rows)
  90. 90. Apache Bench
  91. 91. Apache Bench ab -n 1000 http://127.0.0.1:3000/posts
  92. 92. Apache Bench ab -n 1000 http://127.0.0.1:3000/posts 1 conexão 1000 requisições
  93. 93. Apache Bench ab -n 5000 -c 10 http://127.0.0.1:3000/posts
  94. 94. Apache Bench ab -n 5000 -c 10 http://127.0.0.1:3000/posts 10 conexões 5000 requisições
  95. 95. Nginx - 3 Mongrels
  96. 96. Nginx - 3 Mongrels req/s (mean) 1000 requests 1 conexão 5000 requests 10 conexões
  97. 97. Nginx - 3 Mongrels req/s (mean) Hello World 1000 requests 414.56 1 conexão 5000 requests 701.88 10 conexões
  98. 98. 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
  99. 99. 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
  100. 100. 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
  101. 101. Memória
  102. 102. Memória 1 Mongrel, ~30 Mb 1 Rails vazio
  103. 103. Memória 1 Mongrel, ~30 Mb 1 Rails vazio 1 Mongrel, ~70Mb 1 Mephisto
  104. 104. http://www.scribd.com/doc/97641/ JHoffmanRailsConfMay2007
  105. 105. Estratégias
  106. 106. Rails Cache (Page/Action/Fragment)
  107. 107. Rails Cache (Page/Action/Fragment) MEMCACHED
  108. 108. Rails Cache (Page/Action/Fragment) MEMCACHED Asynchronous Processes (BackgrounDRb, cronjobs, etc)
  109. 109. class PostsController < Application def action # código lento end end # http://www.site.com/posts
  110. 110. class PostsController < Application def action PERIGO! # código lento end end # http://www.site.com/posts
  111. 111. 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
  112. 112. Tempo de Execução Rails Request
  113. 113. Tempo de Execução Rails Request CACHE
  114. 114. Tempo de Execução Rails Request
  115. 115. Tempo de Execução Rails Request Async
  116. 116. Tempo de Execução Rails Request Outros
  117. 117. 920 pageviews/dia ~30 req/s pico USD 370/mês
  118. 118. Deployment comum
  119. 119. Cap
  120. 120. Nginx Cap
  121. 121. MySQL Nginx Cap
  122. 122. MySQL Nginx Memcached Cap
  123. 123. MySQL Nginx Memcached Cap Git
  124. 124. Desafios
  125. 125. Performance Green Threads x Native Thread + GIL Memory Management C Extensions Interoperability
  126. 126. Performance Green Threads x Native Thread + GIL Memory Management C Extensions Interoperability
  127. 127. Performance Green Threads x Native Thread + GIL Memory Management C Extensions Interoperability
  128. 128. Performance Green Threads x Native Thread + GIL Memory Management C Extensions Interoperability
  129. 129. Performance Green Threads x Native Thread + GIL Memory Management C Extensions Interoperability
  130. 130. Instalação
  131. 131. 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 .
  132. 132. 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 .
  133. 133. 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 .
  134. 134. 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 .
  135. 135. 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>
  136. 136. Benchmarks Mongrel Thin Passenger
  137. 137. Benchmarks Mongrel Thin Passenger
  138. 138. Obrigado! www.akitaonrails.com

×