Mais conteúdo relacionado
Semelhante a RubyMasters 2011 - Beyond Ruby with NodeJS (20)
Mais de Emerson Macedo (13)
RubyMasters 2011 - Beyond Ruby with NodeJS
- 6. Model
class Product < ActiveRecord::Base
after_create :set_initial_inventory
has_many :variants, :dependent => :destroy
has_many :images, :as => :viewable, :order => :position,
:dependent => :destroy
has_many :properties, :through => :product_properties
belongs_to :tax_category
validates_presence_of :name
validates_presence_of :master_price
validates_presence_of :description
make_permalink :with => :name, :field => :permalink
end
Friday, August 7, 2009
- 10. Código Bonito
Don’t Repeat Yourself
Convention Over Configuration
- 11. class Booking < ActiveRecord::Base
belongs_to :hotel
belongs_to :user
validates_presence_of :hotel
validates_presence_of :user
validates_presence_of :credit_card
validates_presence_of :credit_card_name
validates_length_of :credit_card, :within => 16..16
validates_format_of :credit_card, :with => /^d*$/
validates_length_of :credit_card_name, :within => 3..70
def total
hotel.price * nights
end
def nights
((checkout_date - checkin_date) / 1.day).round
end
def to_s
"Booking(#{user},#{hotel})"
end
end
- 20. Usuários de Internet no Mundo (em milhões)
2.000 milhões
2000
1500
1000
500 360 milhões
0
2000 2010
- 22. % de usuários ativos nas Redes Sociais
90 86 %
78 % 77 %
75 % 74 % 74 % 73 % 72 %
67,5 63 %
59 %
45
22,5
0
Brasil Italia Espanha Japão EUA Inglaterra França Austrália Alemanha Suiça
Fonte: The Nielsen Company
- 25. ~ 70% dos adultos
serão usuários
regulares de
redes sociais
- 39. Escalando DB na horizontal
Shard Shard Shard Shard Shard Shard
Database Database Database Database Database Database
- 61. Qual é o problema
das tecnologias atuais ?
- 64. Nosso código costuma
ser escrito assim
O que o software está fazendo
enquanto a querie executa ?
- 71. Ruby on Rails
RUBY
BLOCK
PROCESS
RUBY
BLOCK
PROCESS
HTTPD Database
RUBY
BLOCK
PROCESS
EUBY
PROCESS BLOCK
- 76. Java
Servlet Container
HTTPD Servlet Database
- 77. Java
Servlet Container
HTTPD Servlet Database
- 78. Java
Servlet Container
HTTPD Servlet Database
- 79. Java
Servlet Container
Thread
HTTPD Servlet Database
- 80. Java
Servlet Container
Thread BLOCK
HTTPD Servlet Database
- 81. Java
Servlet Container
Thread BLOCK
Thread BLOCK
Thread BLOCK
HTTPD Servlet Database
Thread BLOCK
Thread BLOCK
Thread BLOCK
Thread BLOCK
- 90. concurrency × reqs/sec
Apache vs NGINX
concurrency × reqs/sec
http://blog.webfaction.com/a-little-holiday-present
http://blog.webfaction.com/a-little-holiday-present
- 91. concurrency × reqs/sec
Apache vs NGINX
concurrency × memory
http://blog.webfaction.com/a-little-holiday-present
http://blog.webfaction.com/a-little-holiday-present
- 95. Pense bem antes de
usar uma thread por
request quando
precisar suportar alta
concorrência
- 111. Latência de I/O
L1 3 ciclos
L2 14 ciclos
RAM 250 ciclos
Disco 41.000.000 ciclos
- 112. Latência de I/O
L1 3 ciclos
L2 14 ciclos
RAM 250 ciclos
Disco 41.000.000 ciclos
Rede 240.000.000 ciclos
- 113. Latência de I/O
L1 3 ciclos
L2 14 ciclos
RAM 250 ciclos
Disco 41.000.000 ciclos
Rede 240.000.000 ciclos
- 117. I/O não bloqueante
L1 3 ciclos
L2 14 ciclos
RAM 250 ciclos
I/O bloqueante
Disco 41.000.000 ciclos
Rede 240.000.000 ciclos
- 119. Servidor TCP simples
em NodeJS
O código acima faz com que a execução
retorne imediatamente ao event loop
- 123. POSIX Assync I/O não
suportado por todos
os S.Os
libmysql_client não
permite query async
- 131. Pilha de execução
http_parse(1)
socket_readdable(1)
ev_loop()
I/O em disco (bloqueante)
- 132. Pilha de execução
load(“index.html”)
http_parse(1)
socket_readdable(1)
ev_loop()
I/O em disco (bloqueante)
- 133. Pilha de execução
http_parse(1)
socket_readdable(1)
ev_loop()
I/O em disco (bloqueante)
- 138. Pilha de execução
http_parse(2)
socket_readdable(2)
ev_loop()
I/O em RAM (não bloqueante)
- 139. Pilha de execução
http_respond(2)
http_parse(2)
socket_readdable(2)
ev_loop()
I/O em RAM (não bloqueante)
- 140. Pilha de execução
http_parse(2)
socket_readdable(2)
ev_loop()
I/O em RAM (não bloqueante)
- 145. Pilha de execução
http_respond(1)
file_loaded()
ev_loop()
Arquivo carregou do disco
- 150. Arquitetura Web
Nginx
Ruby Ruby Ruby Ruby Ruby
on on on on on
Rails Rails Rails Rails Rails
- 151. Arquitetura Web
Nginx
Ruby Ruby Ruby Ruby Ruby
on on on on on NodeJS
Rails Rails Rails Rails Rails
- 166. em-proxy em-dns
em-syslog
em-ruby-irc
em-spec
em-memcache-client
- 167. em-mysql
em-proxy em-dns
em-mongo
em-syncrony em-syslog
em-ruby-irc
em-spec
em-memcache-client em-simplechat
- 168. em-mysql em-resolv-replace
em-http-request em-websocket
em-proxy em-dns
em-s3 em-mongo
em-syncrony em-syslog
em-dir-watcher
em-ftpd
em-jabberbot
em-redis em-ruby-irc
em-spec em-net-http
em-memcache-client em-simplechat
- 238. Obrigado !!!
Emerson Macedo
@emerleite
http://nodecasts.org
http://codificando.com