Rs on Rails 2011

1,023 views

Published on

Discutindo Rails e Arquiteturas. Palestra para a RS on Rails 2011

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

No Downloads
Views
Total views
1,023
On SlideShare
0
From Embeds
0
Number of Embeds
28
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Rs on Rails 2011

  1. 1. Discutindo Rails e Arquiteturas a apresentação já vai começar ...
  2. 2. Discutindo Rails e Arquiteturas
  3. 3. Fabio Akitawww.akitaonrails.com @akitaonrails
  4. 4. 1 ano atrás 4 pessoas 20 pessoas Hoje + USD 1 Milhão/ano
  5. 5. 1 ano atrás 4 pessoas 20 pessoas Hoje + USD 1 Milhão/ano
  6. 6. 1 ano atrás 4 pessoas 20 pessoas Hoje + USD 1 Milhão/ano
  7. 7. ~1990
  8. 8. Anos 80 Fim Anos 90 Século XXI
  9. 9. Anos 80 Fim Anos 90 Século XXI PerlBasic Pascal Java C PHP dBase Delphi Python ABAP III Ruby Clipper ASP .NET ObjC VB6
  10. 10. 1.8.7 1.9.21.9.3-dev 2.3.12 3.0.93.1-RC4
  11. 11. 1.8.7 1.9.21.9.3-dev 2.3.12 3.0.93.1-RC4
  12. 12. 1.8.7 1.9.21.9.3-dev 2.3.12 3.0.93.1-RC4
  13. 13. Request Web Server Rack Middlewares Routes ControllerView Model
  14. 14. Request Web Server Rack Middlewares Routes ControllerView Model
  15. 15. Request Web Server Rack Middlewares Routes ControllerView Model
  16. 16. Request Web Server Rack Middlewares Routes ControllerView Model
  17. 17. Request Web Server Rack Middlewares Routes ControllerView Model
  18. 18. Request Web Server Rack Middlewares Routes ControllerView Model
  19. 19. Request Web Server Rack Middlewares Routes ControllerView Model
  20. 20. Request Web Server Rack Middlewares Routes ControllerView Model
  21. 21. Request Web Server Rack Middlewares Routes ControllerView Model
  22. 22. Request Web Server Rack Middlewares Routes ControllerView Model
  23. 23. Request Web Server Rack Middlewares Routes ControllerView Model
  24. 24. Response Request Web Server Rack Middlewares Routes Controller View Model
  25. 25. Response Request Web Server Rack Middlewares Application Server Rack: Routes Unicorn, Controller Passenger View Model
  26. 26. Web Server:Response Request NginX Apache Web Server Rack Middlewares Application Server Rack: Routes Unicorn, Controller Passenger View Model
  27. 27. NginX, Apache Reverse Proxy Unicorn, PassengerActiveRecord/DataMapper RDBMS/NoSQL
  28. 28. HAProxy NginX, Apache Reverse Proxy Unicorn, PassengerActiveRecord/DataMapper RestClient/Savon RDBMS/NoSQLWeb Services (REST, SOAP)
  29. 29. HAProxy NginX, Apache Varnish Reverse Proxy Unicorn, PassengerActiveRecord/DataMapper RestClient/Savon RDBMS/NoSQLWeb Services (REST, SOAP)
  30. 30. HAProxy NginX, Apache Varnish Reverse Proxy Unicorn, PassengerActiveRecord/DataMapper RestClient/Savon Memcached RDBMS/NoSQLWeb Services (REST, SOAP)
  31. 31. Request Request Request Request Request RequestHTTPD HTTPD HTTPD HTTPD HTTPD HTTPD Rails Rails Rails Rails Rails Rails App App App App App App RDBMS
  32. 32. Request Request Request Request Request RequestHTTPD HTTPD HTTPD HTTPD HTTPD HTTPD Rails Rails Rails Rails Rails Rails App App App App App App RDBMS
  33. 33. Request Request Request Request Request RequestHTTPD HTTPD HTTPD HTTPD HTTPD HTTPD Rails Rails Rails Rails Rails Rails App App App App App App Mais curto RDBMS possível!
  34. 34. Thread Context Switch
  35. 35. Thread Context Switch
  36. 36. RailsRequest App
  37. 37. Eventos AssíncronosEnvio de mensagens
  38. 38. Request Request Request Request Request RequestHTTPD HTTPD HTTPD HTTPD HTTPD HTTPD Rails Rails Rails Rails Rails Rails App App App App App App RDBMS
  39. 39. Request Request Request Request Request Request NginX Async App RDBMS
  40. 40. Request Request Request Request Request Request NginX Async App “Look Ma! No Threads!” RDBMS
  41. 41. Request Request Request Request Request Request NginX 5k ~ 10k conexões Async App “Look Ma! No Threads!” RDBMS
  42. 42. Request Request Request Request Request Request NginX 5k ~ 10k conexões Conexões Longas Async App “Look Ma! No Threads!” RDBMS
  43. 43. EventMachine.run do conn = { :host => "0.0.0.0", :port => 8080 } EventMachine::WebSocket.start(conn) do |ws| ws.onopen do puts "WebSocket connection open" # publish message to the client ws.send "Hello Client" end ws.onclose { puts "Connection closed" } ws.onmessage do |msg| puts "Recieved message: #{msg}" ws.send "Pong: #{msg}" end endend
  44. 44. EventMachine.run do conn = { :host => "0.0.0.0", :port => 8080 } EventMachine::WebSocket.start(conn) do |ws| ws.onopen do puts "WebSocket connection open" # publish message to the client ws.send "Hello Client" end ws.onclose { puts "Connection closed" } ws.onmessage do |msg| puts "Recieved message: #{msg}" ws.send "Pong: #{msg}" end endend
  45. 45. EventMachine.run do conn = { :host => "0.0.0.0", :port => 8080 } EventMachine::WebSocket.start(conn) do |ws| ws.onopen do puts "WebSocket connection open" # publish message to the client ws.send "Hello Client" end ws.onclose { puts "Connection closed" } ws.onmessage do |msg| puts "Recieved message: #{msg}" ws.send "Pong: #{msg}" end endend
  46. 46. EventMachine.run do conn = { :host => "0.0.0.0", :port => 8080 } EventMachine::WebSocket.start(conn) do |ws| ws.onopen do puts "WebSocket connection open" # publish message to the client ws.send "Hello Client" end ws.onclose { puts "Connection closed" } ws.onmessage do |msg| puts "Recieved message: #{msg}" ws.send "Pong: #{msg}" end endend
  47. 47. EventMachine.run do conn = { :host => "0.0.0.0", :port => 8080 } EventMachine::WebSocket.start(conn) do |ws| ws.onopen do puts "WebSocket connection open" # publish message to the client ws.send "Hello Client" end ws.onclose { puts "Connection closed" } ws.onmessage do |msg| puts "Recieved message: #{msg}" ws.send "Pong: #{msg}" end endend
  48. 48. EventMachine.run do conn = { :host => "0.0.0.0", :port => 8080 } EventMachine::WebSocket.start(conn) do |ws| ws.onopen do puts "WebSocket connection open" # publish message to the client ws.send "Hello Client" end ws.onclose { puts "Connection closed" } ws.onmessage do |msg| puts "Recieved message: #{msg}" ws.send "Pong: #{msg}" end endend
  49. 49. EventMachine.run do conn = { :host => "0.0.0.0", :port => 8080 } EventMachine::WebSocket.start(conn) do |ws| ws.onopen do puts "WebSocket connection open" # publish message to the client ws.send "Hello Client" end ws.onclose { puts "Connection closed" } ws.onmessage do |msg| puts "Recieved message: #{msg}" ws.send "Pong: #{msg}" end endend
  50. 50. EventMachine.run do conn = { :host => "0.0.0.0", :port => 8080 } EventMachine::WebSocket.start(conn) do |ws| ws.onopen do puts "WebSocket connection open" # publish message to the client ws.send "Hello Client" end ws.onclose { puts "Connection closed" } ws.onmessage do |msg| puts "Recieved message: #{msg}" ws.send "Pong: #{msg}" end endend
  51. 51. EventMachine.run do conn = { :host => "0.0.0.0", :port => 8080 } EventMachine::WebSocket.start(conn) do |ws| ws.onopen do puts "WebSocket connection open" # publish message to the client ws.send "Hello Client" end ws.onclose { puts "Connection closed" } ws.onmessage do |msg| puts "Recieved message: #{msg}" ws.send "Pong: #{msg}" end endend
  52. 52. <script src="http://js.pusherapp.com/1.8/pusher.min.js"></script><script>var pusher = new Pusher(API_KEY);var myChannel = pusher.subscribe(MEU_CANAL);</script>
  53. 53. <script src="http://js.pusherapp.com/1.8/pusher.min.js"></script><script>var pusher = new Pusher(API_KEY);var myChannel = pusher.subscribe(MEU_CANAL);</script>
  54. 54. <script src="http://js.pusherapp.com/1.8/pusher.min.js"></script><script>var pusher = new Pusher(API_KEY);var myChannel = pusher.subscribe(MEU_CANAL);</script>
  55. 55. myChannel.bind(coisa-criada, function(thing) { alert(Uma coisa foi criada: + thing.name);});
  56. 56. myChannel.bind(coisa-criada, function(thing) { alert(Uma coisa foi criada: + thing.name);});
  57. 57. myChannel.bind(coisa-criada, function(thing) { alert(Uma coisa foi criada: + thing.name);});
  58. 58. require pusherPusher.app_id = APP_IDPusher.key = API_KEYPusher.secret = SECRET_KEYclass ThingsController < ApplicationController def create @thing = Thing.new(params[:thing]) if @thing.save Pusher[MEU_CANAL].trigger(coisa-criada, @thing.attributes) end endend
  59. 59. require pusherPusher.app_id = APP_IDPusher.key = API_KEYPusher.secret = SECRET_KEYclass ThingsController < ApplicationController def create @thing = Thing.new(params[:thing]) if @thing.save Pusher[MEU_CANAL].trigger(coisa-criada, @thing.attributes) end endend
  60. 60. require pusherPusher.app_id = APP_IDPusher.key = API_KEYPusher.secret = SECRET_KEYclass ThingsController < ApplicationController def create @thing = Thing.new(params[:thing]) if @thing.save Pusher[MEU_CANAL].trigger(coisa-criada, @thing.attributes) end endend
  61. 61. require pusherPusher.app_id = APP_IDPusher.key = API_KEYPusher.secret = SECRET_KEYclass ThingsController < ApplicationController def create @thing = Thing.new(params[:thing]) if @thing.save Pusher[MEU_CANAL].trigger(coisa-criada, @thing.attributes) end endend
  62. 62. Arquitetura deAltíssima Concorrência
  63. 63. (
  64. 64. W. Edward Deming
  65. 65. IN GOD WE TRUSTTodos os outros devem trazer dados
  66. 66. EXPERIENCE BY ITSELF BRINGS NOTHING
  67. 67. Ciclo “Plan-Do-Check-Act” (melhoria contínua) P A D C
  68. 68. Ciclo “Plan-Do-Check-Act” (melhoria contínua) P A D C STANDARD
  69. 69. Ciclo “Plan-Do-Check-Act” (melhoria contínua) P A D C
  70. 70. Ciclo “Plan-Do-Check-Act” (melhoria contínua) P A D C
  71. 71. Ciclo “Plan-Do-Check-Act” (melhoria contínua) P A D C
  72. 72. Ciclo “Plan-Do-Check-Act” (melhoria contínua) P A D C
  73. 73. )
  74. 74. Perl
  75. 75. Python
  76. 76. PHP
  77. 77. Ruby
  78. 78. OMG!
  79. 79. 20112010200920082007 Ruby on Rails
  80. 80. 3.0.92011 2.3.12 102010 3.0.0 2.2.3 122009 2.3.0 2.1.2 4 2.2.0 2.0.5 3 2.1.02008 62007 Ruby on Rails 2.0.0
  81. 81. 3.0.92011 2.3.122010 3.0.0 2.2.32009 2.1.2 2.3.0 34 2.2.0 Versões! 2.0.5 2.1.020082007 Ruby on Rails 2.0.0
  82. 82. Request Web Server Rails App/public/stylesheets
  83. 83. Request Web ServerArquivosEstáticos Rails App /public/stylesheets
  84. 84. Variáveis$blue: #3bbfce;$margin: 16px; /* CSS */.content-navigation { .content-navigation { border-color: $blue; border-color: #3bbfce; color: color: #2b9eab; darken($blue, 9%); }} .border {.border { padding: 8px; padding: $margin / 2; margin: 8px; margin: $margin / 2; border-color: #3bbfce; border-color: $blue; }}
  85. 85. Nestingtable.hl { /* CSS */ margin: 2em 0; td.ln { table.hl { text-align: right; margin: 2em 0; } }} table.hl td.ln { text-align: right;li { } font: { family: serif; li { weight: bold; font-family: serif; size: 1.2em; font-weight: bold; } font-size: 1.2em;} }
  86. 86. Mixins@mixin table-base { th { /* CSS */ text-align: center; font-weight: bold; #data { } td, th {padding: 2px} float: left;} margin-left: 10px; }@mixin left($dist) { #data th { float: left; text-align: center; margin-left: $dist; font-weight: bold;} } #data td, #data th {#data { @include left(10px); padding: 2px; @include table-base; }}
  87. 87. Selector Inheritance /* CSS */.error { .error, .badError { border: 1px #f00; border: 1px #f00; background: #fdd; background: #fdd;} }.error.intrusion { font-size: 1.3em; .error.intrusion, font-weight: bold; .badError.intrusion {} font-size: 1.3em; font-weight: bold;.badError { } @extend .error; border-width: 3px; .badError {} border-width: 3px; }
  88. 88. class Animal constructor: (@name) -> move: (meters) -> alert @name + " moved " + meters + "m."class Snake extends Animal move: -> alert "Slithering..." super 5class Horse extends Animal move: -> alert "Galloping..." super 45sam = new Snake "Sammy the Python"tom = new Horse "Tommy the Palomino"sam.move()tom.move()
  89. 89. var Animal, Horse, Snake, sam, tom; var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor;class Animal child.__super__ = parent.prototype; constructor: (@name) -> return child; }; Animal = (function() { move: (meters) -> function Animal(name) { this.name = name; alert @name + " moved " + meters + "m." } Animal.prototype.move = function(meters) { return alert(this.name + " moved " + meters + "m.");class Snake extends Animal }; return Animal; move: -> })(); alert "Slithering..." Snake = (function() { __extends(Snake, Animal); super 5 function Snake() { Snake.__super__.constructor.apply(this, arguments); }class Horse extends Animal Snake.prototype.move = function() { alert("Slithering..."); move: -> return Snake.__super__.move.call(this, 5); alert "Galloping..." }; return Snake; super 45 })(); Horse = (function() { __extends(Horse, Animal);sam = new Snake "Sammy the Python" function Horse() {tom = new Horse "Tommy the Palomino" Horse.__super__.constructor.apply(this, arguments); } Horse.prototype.move = function() { alert("Galloping...");sam.move() return Horse.__super__.move.call(this, 45);tom.move() }; return Horse; })(); sam = new Snake("Sammy the Python"); tom = new Horse("Tommy the Palomino"); sam.move(); tom.move(); loadrun
  90. 90. 102
  91. 91. Request Request Web Server Web Server(Desenvolvimento) (Produção) Rails App /app/assets /public
  92. 92. Request Request Web Server Web Server(Desenvolvimento) (Produção) Rails Sprockets App /app/assets /public
  93. 93. Request Request Web Server Web Server(Desenvolvimento) (Produção) Rails Sprockets App Tilt /app/assets /public
  94. 94. Request Request Web Server Web Server(Desenvolvimento) (Produção) Rails Sprockets App Tilt Ugli er /app/assets /public
  95. 95. ENGINE FILE EXTENSIONS REQUIRED LIBRARIESERB .erb, .rhtml noneInterpolated String .strErubis .erb, .rhtml, .erubis erubisHaml .haml hamlSass .sass sassScss .scssLess CSS .less lessBuilder .builder builderLiquid .liquid liquidRDiscount rdiscountRedcarpet redcarpetBlueCloth .markdown, .mkd, .md blueclothKramdown kramdownMaruku marukuRedCloth .textile redclothRDoc .rdoc rdocRadius .radius radiusMarkaby .mab markabyNokogiri .nokogiri nokogiriCoffeeScript .coffee coffee-scriptCreole (Wiki markup) .creole creole
  96. 96. jQuery Tamanho Tempo Original Size 621kbGoogle Closure 234kb 6.5sYUI Compressor 240kb 2.7s UglifyJS 235kb 1.3s
  97. 97. jQuery Tamanho Tempo Original Size 621kbGoogle Closure 234kb 6.5sYUI Compressor 240kb 2.7s UglifyJS 235kb 1.3s
  98. 98. jQuery Tamanho Tempo Original Size 621kbGoogle Closure 234kb 6.5sYUI Compressor 240kb 2.7s UglifyJS 235kb 1.3s
  99. 99. jQuery Tamanho Tempo Original Size 621kbGoogle Closure 234kb 6.5sYUI Compressor 240kb 2.7s UglifyJS 235kb 1.3s
  100. 100. jQuery Tamanho Tempo Original Size 621kbGoogle Closure 234kb 6.5sYUI Compressor 240kb 2.7s UglifyJS 235kb 1.3s
  101. 101. Rails 3.1:Release Candidate (may 2011)
  102. 102. RubyConf Brasil3 e 4 de Novembro www.rubyconf.com.br
  103. 103. <epílogo>
  104. 104. Como o cliente Como o Líder de Como o Analista Como o Programador Como o Consultor de explicou Projeto entendeu desenhou escreveu Negócios descreveuComo o projeto foi Como Operações Como o cliente foi O que o cliente Como foi o suporte documentado instalou cobrado realmente queria
  105. 105. Requerimentos: ENTENDIDO!
  106. 106. LOL
  107. 107. DESIGN
  108. 108. DESIGN
  109. 109. Pattern PADRÃO
  110. 110. STANDARD Pattern PADRÃO Default
  111. 111. “Pattern”
  112. 112. NÃO é “Standard”!
  113. 113. Christopher Alexander
  114. 114. cada padrão (“pattern”)representa nosso melhor chute agora ... os padrões ainda são hipóteses, ... e portanto todos sãotentativas, todos livres para evoluir sob o impacto de novas experiências e observações." Christopher Alexander
  115. 115. 2 + 2 = 5!
  116. 116. 2 + 2 = 5!
  117. 117. 2 + 2 = 4!
  118. 118. Bertrand Russel
  119. 119. Bertrand Russel
  120. 120. Aqui estão os fatos. Que Aqui está a conclusão. conclusões podemos Que fatos podemos chegar com eles? suportar com eles?
  121. 121. 80
  122. 122. 20 80
  123. 123. 20 80
  124. 124. 20 80 “Long Tail”
  125. 125. Pedro Franceschi @pedroh96
  126. 126. 15 anosPedro Franceschi @pedroh96
  127. 127. 9 anosPedro Franceschi @pedroh96
  128. 128. 6 anosPedro Franceschi @pedroh96
  129. 129. Pedro Franceschi @pedroh96
  130. 130. <epílogo>
  131. 131. Obrigado! www.akitaonrails.com u.akita.ws/rsonrails11 .com.br
  132. 132. Obrigado! www.akitaonrails.com u.akita.ws/rsonrails11 .com.br

×