SlideShare ist ein Scribd-Unternehmen logo
1 von 47
Downloaden Sie, um offline zu lesen
No Callbacks, No Threads & Ruby 1.9,[object Object],async & co-operative web-servers,[object Object],Ilya Grigorik,[object Object],@igrigorik,[object Object]
Reactor Pattern,[object Object],Review: ,[object Object],State of the art,[object Object],Async Primitives,[object Object],Callbacks & Fibers,[object Object],Async Rails?,[object Object]
require"active_record”,[object Object],ActiveRecord::Base.establish_connection(,[object Object],  :adapter => "mysql",,[object Object],  :username => "root",,[object Object],  :database => "database",,[object Object],  :pool => 5,[object Object],),[object Object],threads = [],[object Object],10.times do |n| ,[object Object],  threads <<Thread.new {,[object Object],ActiveRecord::Base.connection_pool.with_connectiondo |conn|,[object Object],      res =conn.execute("select sleep(1)"),[object Object],end,[object Object],  },[object Object],end,[object Object],threads.each { |t| t.join },[object Object],The “Experiment”,[object Object],vanilla everything…,[object Object]
require"active_record”,[object Object],ActiveRecord::Base.establish_connection(,[object Object],  :adapter => "mysql",,[object Object],  :username => "root",,[object Object],  :database => "database",,[object Object],  :pool => 5,[object Object],),[object Object],threads = [],[object Object],10.times do |n| ,[object Object],  threads <<Thread.new {,[object Object],ActiveRecord::Base.connection_pool.with_connectiondo |conn|,[object Object],      res =conn.execute("select sleep(1)"),[object Object],end,[object Object],  },[object Object],end,[object Object],threads.each { |t| t.join },[object Object],5 shared connections,[object Object],# time ruby activerecord-pool.rb,[object Object],#,[object Object],# real    0m10.663s,[object Object],# user    0m0.405s,[object Object],# sys     0m0.201s,[object Object]
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
BHP,[object Object],% power ,[object Object],    loss,[object Object],WHP,[object Object]
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
Mongo,[object Object],Couch,[object Object],MySQL,[object Object],PSQL,[object Object],…,[object Object],Drivers,[object Object],Threads,[object Object],Ruby VM,[object Object],GIL,[object Object],Fibers,[object Object],…,[object Object],Network,[object Object],Mongrel,[object Object],Unicorn,[object Object],Passenger,[object Object],…,[object Object]
Global Interpreter Lock is a mutual exclusion lock held by a programming language interpreter thread to avoid sharing code that is not thread-safe with other threads. ,[object Object],There is always one GIL for one interpreter process.,[object Object],Concurrency is a myth in Ruby,[object Object],(with a few caveats, of course),[object Object],http://bit.ly/ruby-gil,[object Object]
N-M thread pool in Ruby 1.9…,[object Object],Better but still the same problem!,[object Object],Concurrency is a myth in Ruby,[object Object],still no concurrency in Ruby 1.9,[object Object],http://bit.ly/ruby-gil,[object Object]
Concurrency is a myth in Ruby,[object Object],still no parallelism in Ruby 1.9,[object Object],http://bit.ly/ruby-gil,[object Object]
Blocks entire,[object Object],Ruby VM,[object Object],Not as bad, but,[object Object],avoid it still..,[object Object],Avoid locking interpreter threads at all costs,[object Object],let’s say you’re writing an extension…,[object Object]
Drivers,[object Object],Ruby VM,[object Object],Network,[object Object],WEBRick,[object Object],Mongrel made Rails viable,[object Object],still powers a lot of Rails apps today,[object Object]
Rails rediscovers Apache,[object Object],the worker/forker model… ,[object Object]
*nix IPC is fast! ,[object Object],…,[object Object],Full Ruby VM,[object Object],An exclusive Ruby VM for EACH request,[object Object],am I the only one who thinks this is terrible? ,[object Object]
“Does not care if your application is thread-safe or not, workers all run within their own isolated address space and only serve one client at a time for maximum robustness.”,[object Object],Robustness? That sounds like a bug.,[object Object],An exclusive Ruby VM for EACH request,[object Object],am I the only one who thinks this is terrible? ,[object Object]
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
…?,[object Object]
Node imposes the full-stack requirements,[object Object],Node imposes async drivers,[object Object],Node imposes async frameworks,[object Object],*Surprise*: Node is “fast”,[object Object]
=,[object Object],I’ll take Ruby over JS,[object Object],gem install eventmachine,[object Object]
p "Starting"EM.rundop"Running in EM reactor"endp”won’t get here",[object Object],whiletruedo,[object Object],       timersnetwork_ioother_io,[object Object],end,[object Object],EventMachine Reactor,[object Object],concurrency without thread,[object Object]
gem install em-mysqlplus,[object Object],EventMachine.rundo,[object Object],conn=EventMachine::MySQL.new(:host => 'localhost'),[object Object],  query =conn.query("select sleep(1)"),[object Object],query.callback { |res| pres.all_hashes },[object Object],query.errback  { |res| pres.all_hashes },[object Object],  puts ”executing…”,[object Object],end,[object Object],callback fired 1s after “executing”,[object Object],# > ruby em-mysql-test.rb,[object Object],#,[object Object],# executing…,[object Object],# [{"sleep(1)"=>"0"}],[object Object],em-mysqlplus: example,[object Object],asyncMySQL driver,[object Object]
Non-blocking IO requires non-blocking drivers:,[object Object],AMQP                      http://github.com/tmm1/amqp,[object Object],MySQLPlushttp://github.com/igrigorik/em-mysqlplus,[object Object],Memcachedhttp://github.com/astro/remcached,[object Object],DNS                            http://github.com/astro/em-dns,[object Object],Redishttp://github.com/madsimian/em-redis,[object Object],MongoDBhttp://github.com/tmm1/rmongo,[object Object],HTTPRequesthttp://github.com/igrigorik/em-http-request,[object Object],WebSockethttp://github.com/igrigorik/em-websocket,[object Object],Amazon S3               http://github.com/peritor/happening,[object Object],And many others: ,[object Object],http://wiki.github.com/eventmachine/eventmachine/protocol-implementations,[object Object]
httpA=EventMachine::HttpRequest.new(URL).get,[object Object],httpA.errback {,[object Object],# retry logic?,[object Object],},[object Object],httpA.callback {,[object Object],Memcached.set(:key => URL, :value => httpA.response) { |response|,[object Object],caseresponse[:status],[object Object],whenMemcached::Errors::NO_ERROR,[object Object],# That's good,[object Object],whenMemcached::Errors::DISCONNECTED,[object Object],# Maybe stop filling the cache for now?,[object Object],else,[object Object],# What could've gone wrong?,[object Object],end,[object Object],  },[object Object],},[object Object],http =get(url),[object Object],memc=save(url, http.response),[object Object],ifmemc.error?,[object Object],# That's good,[object Object],else,[object Object],# Err?,[object Object],end,[object Object],accidental complexity,[object Object],async is harder to manage,[object Object]
and this callback goes to…,[object Object]
We can do better than node.js,[object Object],all the benefits of evented code without the drawbacks,[object Object]
Ruby 1.9 Fibers are a means of creating code blocks which can be paused and resumed by our application (think lightweight threads, minus the thread scheduler and less overhead). ,[object Object],f=Fiber.new {,[object Object],whiletruedo,[object Object],Fiber.yield"Hi”,[object Object],end,[object Object],},[object Object],pf.resume# => Hi,[object Object],pf.resume# => Hi,[object Object],pf.resume# => Hi,[object Object],Manual / cooperative scheduling!,[object Object],Ruby 1.9 Fibers,[object Object],and cooperative scheduling,[object Object],http://bit.ly/d2hYw0,[object Object]
Fibers vs Threads: creation time much lower,[object Object],Fibers vs Threads: memory usage is much lower,[object Object],Ruby 1.9 Fibers,[object Object],and cooperative scheduling,[object Object],http://bit.ly/aesXy5,[object Object]
defquery(sql),[object Object],f = Fiber.current,[object Object],conn=EventMachine::MySQL.new(:host => 'localhost'),[object Object],q = conn.query(sql),[object Object],c.callback { f.resume(conn) },[object Object],c.errback  { f.resume(conn) },[object Object],return Fiber.yield,[object Object],end,[object Object],EventMachine.rundo,[object Object],Fiber.new {,[object Object],    res =query('select sleep(1)'),[object Object],    puts "Results: #{res.fetch_row.first}",[object Object],}.resume,[object Object],end,[object Object],Exception, async!,[object Object],Untangling Evented Code with Fibers,[object Object],http://bit.ly/d2hYw0,[object Object]
defquery(sql),[object Object],f = Fiber.current,[object Object],conn=EventMachine::MySQL.new(:host => 'localhost'),[object Object],q = conn.query(sql),[object Object],c.callback { f.resume(conn) },[object Object],c.errback  { f.resume(conn) },[object Object],  return Fiber.yield,[object Object],end,[object Object],EventMachine.rundo,[object Object],Fiber.new{,[object Object],    res =query('select sleep(1)'),[object Object],    puts "Results: #{res.fetch_row.first}",[object Object],  }.resume,[object Object],end,[object Object],1. Wrap into a continuation,[object Object],Untangling Evented Code with Fibers,[object Object],http://bit.ly/d2hYw0,[object Object]
defquery(sql),[object Object],f=Fiber.current,[object Object],conn=EventMachine::MySQL.new(:host => 'localhost'),[object Object],q = conn.query(sql),[object Object],c.callback { f.resume(conn) },[object Object],c.errback  { f.resume(conn) },[object Object],returnFiber.yield,[object Object],end,[object Object],EventMachine.rundo,[object Object],Fiber.new{,[object Object],    res =query('select sleep(1)'),[object Object],    puts "Results: #{res.fetch_row.first}",[object Object],  }.resume,[object Object],end,[object Object],2. Pause the continuation,[object Object],Untangling Evented Code with Fibers,[object Object],http://bit.ly/d2hYw0,[object Object]
defquery(sql),[object Object],f=Fiber.current,[object Object],conn=EventMachine::MySQL.new(:host => 'localhost'),[object Object],q = conn.query(sql),[object Object],c.callback { f.resume(conn) },[object Object],c.errback  { f.resume(conn) },[object Object],returnFiber.yield,[object Object],end,[object Object],EventMachine.rundo,[object Object],Fiber.new{,[object Object],    res =query('select sleep(1)'),[object Object],    puts "Results: #{res.fetch_row.first}",[object Object],  }.resume,[object Object],end,[object Object],3. Resume the continuation,[object Object],Untangling Evented Code with Fibers,[object Object],http://bit.ly/d2hYw0,[object Object]
Good news, you don’t even have to muck around with Fibers!,[object Object],gem install em-synchrony,[object Object],http://github.com/igrigorik/em-synchrony,[object Object],[object Object]
 Multi request interface which accepts any callback enabled client
 Fibered iterator to allow concurrency control & mixing of sync / async
em-http-request: .get, etc are synchronous, while .aget, etc are async
em-mysqlplus: .query is synchronous, while .aquery is async
remcached: .get, etc, and .multi_* methods are synchronousem-synchrony: simple evented programming,[object Object],best of both worlds…,[object Object]
EventMachine.synchronydo,[object Object],    multi =EventMachine::Synchrony::Multi.new,[object Object],multi.add:a, EventMachine::HttpRequest.new(url1).aget,[object Object],multi.add:b, EventMachine::HttpRequest.new(url2).apost,[object Object],    res =multi.perform,[object Object],p“No callbacks, and parallel HTTP requests!",[object Object],p res,[object Object],EventMachine.stop,[object Object],end,[object Object],Parallel IO with Fibers,[object Object],multi interface example,[object Object]
Persistent connections,[object Object],EventMachine.synchronydo,[object Object],    db =EventMachine::Synchrony::ConnectionPool.new(size:2) do,[object Object],EventMachine::MySQL.new(host:"localhost"),[object Object],end,[object Object],    multi =EventMachine::Synchrony::Multi.new,[object Object],multi.add:a, db.aquery("select sleep(1)"),[object Object],multi.add:b, db.aquery("select sleep(1)"),[object Object],    res =multi.perform,[object Object],EventMachine.stop,[object Object],end,[object Object],Fiber Pools,[object Object],accessing shared services,[object Object]
EM.synchronydo,[object Object],    concurrency =2,[object Object],urls= ['http://url.1.com', 'http://url2.com'],[object Object],    results =EM::Synchrony::Iterator.new(urls, concurrency).mapdo |url, iter|,[object Object],        http =EventMachine::HttpRequest.new(url).aget,[object Object],http.callback { iter.return(http) },[object Object],end,[object Object],p results # all completed requests,[object Object],EventMachine.stop,[object Object],end,[object Object],Explicit iterators,[object Object],.each, .map, .inject, …,[object Object],asynchronous iterators,[object Object]
EM.synchronydo,[object Object],  result =EM::Synchrony.syncEventMachine::HttpRequest.new(URL).get,[object Object],presult,[object Object],EM.stop,[object Object],end,[object Object],Inline synchronization,[object Object],Inline synchronization,[object Object],ad-hoc synchronization,[object Object]
require"em-synchrony/em-mysqlplus",[object Object],EventMachine.synchronydo,[object Object],    db =EventMachine::MySQL.new(host:"localhost"),[object Object],    res =db.query("select sleep(1)"),[object Object],    puts res,[object Object],EventMachine.stop,[object Object],end,[object Object],Async under the hood,[object Object],Untangling Evented Code with Fibers,[object Object],http://bit.ly/d2hYw0,[object Object]
require "em-synchrony/em-mysqlplus",[object Object],EventMachine.synchrony do,[object Object],    db = EventMachine::MySQL.new(host: "localhost"),[object Object],    res =db.query("select sleep(1)"),[object Object],    puts res,[object Object],EventMachine.stop,[object Object],end,[object Object],Untangling Evented Code with Fibers,[object Object],http://bit.ly/d2hYw0,[object Object]
Async web-stack in Ruby?,[object Object]

Weitere ähnliche Inhalte

Was ist angesagt?

0-60 with Goliath: High performance web services
0-60 with Goliath: High performance web services0-60 with Goliath: High performance web services
0-60 with Goliath: High performance web servicesIlya Grigorik
 
Plack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversPlack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversTatsuhiko Miyagawa
 
Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011Tatsuhiko Miyagawa
 
Plack basics for Perl websites - YAPC::EU 2011
Plack basics for Perl websites - YAPC::EU 2011Plack basics for Perl websites - YAPC::EU 2011
Plack basics for Perl websites - YAPC::EU 2011leo lapworth
 
Web frameworks don't matter
Web frameworks don't matterWeb frameworks don't matter
Web frameworks don't matterTomas Doran
 
Event Driven Architecture - MeshU - Ilya Grigorik
Event Driven Architecture - MeshU - Ilya GrigorikEvent Driven Architecture - MeshU - Ilya Grigorik
Event Driven Architecture - MeshU - Ilya GrigorikIlya Grigorik
 
Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)True-Vision
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
A complete guide to Node.js
A complete guide to Node.jsA complete guide to Node.js
A complete guide to Node.jsPrabin Silwal
 
Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ilya Grigorik
 
Real Time Event Dispatcher
Real Time Event DispatcherReal Time Event Dispatcher
Real Time Event DispatcherPeter Dietrich
 
Building real time applications with Symfony2
Building real time applications with Symfony2Building real time applications with Symfony2
Building real time applications with Symfony2Antonio Peric-Mazar
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Alexander Lisachenko
 
Asterisk, HTML5 and NodeJS; a world of endless possibilities
Asterisk, HTML5 and NodeJS; a world of endless possibilitiesAsterisk, HTML5 and NodeJS; a world of endless possibilities
Asterisk, HTML5 and NodeJS; a world of endless possibilitiesDan Jenkins
 

Was ist angesagt? (20)

0-60 with Goliath: High performance web services
0-60 with Goliath: High performance web services0-60 with Goliath: High performance web services
0-60 with Goliath: High performance web services
 
Intro to PSGI and Plack
Intro to PSGI and PlackIntro to PSGI and Plack
Intro to PSGI and Plack
 
Plack at OSCON 2010
Plack at OSCON 2010Plack at OSCON 2010
Plack at OSCON 2010
 
Plack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversPlack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and servers
 
Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011
 
Plack - LPW 2009
Plack - LPW 2009Plack - LPW 2009
Plack - LPW 2009
 
Plack basics for Perl websites - YAPC::EU 2011
Plack basics for Perl websites - YAPC::EU 2011Plack basics for Perl websites - YAPC::EU 2011
Plack basics for Perl websites - YAPC::EU 2011
 
Web frameworks don't matter
Web frameworks don't matterWeb frameworks don't matter
Web frameworks don't matter
 
PSGI/Plack OSDC.TW
PSGI/Plack OSDC.TWPSGI/Plack OSDC.TW
PSGI/Plack OSDC.TW
 
Event Driven Architecture - MeshU - Ilya Grigorik
Event Driven Architecture - MeshU - Ilya GrigorikEvent Driven Architecture - MeshU - Ilya Grigorik
Event Driven Architecture - MeshU - Ilya Grigorik
 
Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)
 
Tatsumaki
TatsumakiTatsumaki
Tatsumaki
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
A complete guide to Node.js
A complete guide to Node.jsA complete guide to Node.js
A complete guide to Node.js
 
Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011
 
Real Time Event Dispatcher
Real Time Event DispatcherReal Time Event Dispatcher
Real Time Event Dispatcher
 
Building real time applications with Symfony2
Building real time applications with Symfony2Building real time applications with Symfony2
Building real time applications with Symfony2
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
 
Asterisk, HTML5 and NodeJS; a world of endless possibilities
Asterisk, HTML5 and NodeJS; a world of endless possibilitiesAsterisk, HTML5 and NodeJS; a world of endless possibilities
Asterisk, HTML5 and NodeJS; a world of endless possibilities
 
Sinatra for REST services
Sinatra for REST servicesSinatra for REST services
Sinatra for REST services
 

Ähnlich wie No callbacks, No Threads - Cooperative web servers in Ruby 1.9

Ruby vs Node ShiningRay Shanghai
Ruby vs Node ShiningRay ShanghaiRuby vs Node ShiningRay Shanghai
Ruby vs Node ShiningRay ShanghaiJackson Tian
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the wayOleg Podsechin
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA PresentationRob Tweed
 
Evented Ruby VS Node.js
Evented Ruby VS Node.jsEvented Ruby VS Node.js
Evented Ruby VS Node.jsNitin Gupta
 
mri ruby gil
mri ruby gilmri ruby gil
mri ruby gilachempion
 
Node js presentation
Node js presentationNode js presentation
Node js presentationmartincabrera
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkAarti Parikh
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDDSudar Muthu
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsJack Franklin
 
Async programming and python
Async programming and pythonAsync programming and python
Async programming and pythonChetan Giridhar
 
Asynchronous I/O in NodeJS - new standard or challenges?
Asynchronous I/O in NodeJS - new standard or challenges?Asynchronous I/O in NodeJS - new standard or challenges?
Asynchronous I/O in NodeJS - new standard or challenges?Dinh Pham
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011Lance Ball
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tourcacois
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Visual Engineering
 

Ähnlich wie No callbacks, No Threads - Cooperative web servers in Ruby 1.9 (20)

Ruby vs Node ShiningRay Shanghai
Ruby vs Node ShiningRay ShanghaiRuby vs Node ShiningRay Shanghai
Ruby vs Node ShiningRay Shanghai
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
Concurrency in ruby
Concurrency in rubyConcurrency in ruby
Concurrency in ruby
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA Presentation
 
Node.js
Node.jsNode.js
Node.js
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Evented Ruby VS Node.js
Evented Ruby VS Node.jsEvented Ruby VS Node.js
Evented Ruby VS Node.js
 
mri ruby gil
mri ruby gilmri ruby gil
mri ruby gil
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Introduction to Node.JS
Introduction to Node.JSIntroduction to Node.JS
Introduction to Node.JS
 
Async programming and python
Async programming and pythonAsync programming and python
Async programming and python
 
Asynchronous I/O in NodeJS - new standard or challenges?
Asynchronous I/O in NodeJS - new standard or challenges?Asynchronous I/O in NodeJS - new standard or challenges?
Asynchronous I/O in NodeJS - new standard or challenges?
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.
 

Mehr von Ilya Grigorik

Pagespeed what, why, and how it works
Pagespeed   what, why, and how it worksPagespeed   what, why, and how it works
Pagespeed what, why, and how it worksIlya Grigorik
 
Making the web fast(er) - RailsConf 2012
Making the web fast(er) - RailsConf 2012Making the web fast(er) - RailsConf 2012
Making the web fast(er) - RailsConf 2012Ilya Grigorik
 
Intelligent Ruby + Machine Learning
Intelligent Ruby + Machine LearningIntelligent Ruby + Machine Learning
Intelligent Ruby + Machine LearningIlya Grigorik
 
Real-time Ruby for the Real-time Web
Real-time Ruby for the Real-time WebReal-time Ruby for the Real-time Web
Real-time Ruby for the Real-time WebIlya Grigorik
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Ilya Grigorik
 
Leveraging Social Media - Strategies & Tactics - PostRank
Leveraging Social Media - Strategies & Tactics - PostRankLeveraging Social Media - Strategies & Tactics - PostRank
Leveraging Social Media - Strategies & Tactics - PostRankIlya Grigorik
 
Ruby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and MonitoringRuby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and MonitoringIlya Grigorik
 
Building Mini Google in Ruby
Building Mini Google in RubyBuilding Mini Google in Ruby
Building Mini Google in RubyIlya Grigorik
 
Taming The RSS Beast
Taming The  RSS  BeastTaming The  RSS  Beast
Taming The RSS BeastIlya Grigorik
 

Mehr von Ilya Grigorik (9)

Pagespeed what, why, and how it works
Pagespeed   what, why, and how it worksPagespeed   what, why, and how it works
Pagespeed what, why, and how it works
 
Making the web fast(er) - RailsConf 2012
Making the web fast(er) - RailsConf 2012Making the web fast(er) - RailsConf 2012
Making the web fast(er) - RailsConf 2012
 
Intelligent Ruby + Machine Learning
Intelligent Ruby + Machine LearningIntelligent Ruby + Machine Learning
Intelligent Ruby + Machine Learning
 
Real-time Ruby for the Real-time Web
Real-time Ruby for the Real-time WebReal-time Ruby for the Real-time Web
Real-time Ruby for the Real-time Web
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
 
Leveraging Social Media - Strategies & Tactics - PostRank
Leveraging Social Media - Strategies & Tactics - PostRankLeveraging Social Media - Strategies & Tactics - PostRank
Leveraging Social Media - Strategies & Tactics - PostRank
 
Ruby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and MonitoringRuby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and Monitoring
 
Building Mini Google in Ruby
Building Mini Google in RubyBuilding Mini Google in Ruby
Building Mini Google in Ruby
 
Taming The RSS Beast
Taming The  RSS  BeastTaming The  RSS  Beast
Taming The RSS Beast
 

Kürzlich hochgeladen

ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 

Kürzlich hochgeladen (20)

ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 

No callbacks, No Threads - Cooperative web servers in Ruby 1.9

  • 1.
  • 2.
  • 3.
  • 4.
  • 6.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36. Multi request interface which accepts any callback enabled client
  • 37. Fibered iterator to allow concurrency control & mixing of sync / async
  • 38. em-http-request: .get, etc are synchronous, while .aget, etc are async
  • 39. em-mysqlplus: .query is synchronous, while .aquery is async
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.