• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Evented I/O based web servers, explained using bunnies
 

Evented I/O based web servers, explained using bunnies

on

  • 35,366 views

Part of a talk about Node.js given at Full Frontal 2009 in Brighton. I've added some additional explanatory notes.

Part of a talk about Node.js given at Full Frontal 2009 in Brighton. I've added some additional explanatory notes.

Statistics

Views

Total Views
35,366
Views on SlideShare
33,781
Embed Views
1,585

Actions

Likes
61
Downloads
293
Comments
1

46 Embeds 1,585

http://stendev.com 621
http://51elliot.blogspot.com 300
http://www.slideshare.net 156
http://lanyrd.com 120
http://phcostabh.wordpress.com 66
http://moot.ly 55
http://sens3.com 53
http://51elliot.blogspot.com.es 41
http://51elliot.blogspot.in 28
https://twitter.com 22
http://51elliot.blogspot.ca 17
http://rxvl.in 16
http://www.techgig.com 12
http://51elliot.blogspot.co.uk 8
http://mj89sp3sau2k7lj1eg3k40hkeppguj6j-a-sites-opensocial.googleusercontent.com 7
http://51elliot.blogspot.co.nz 6
http://www.sens3.com 5
http://51elliot.blogspot.com.au 5
http://51elliot.blogspot.fr 4
http://rudyschockaert.wordpress.com 4
http://51elliot.blogspot.com.br 4
https://si0.twimg.com 3
http://51elliot.blogspot.de 3
http://51elliot.blogspot.sg 2
http://51elliot.blogspot.cz 2
http://51elliot.blogspot.ie 2
http://akshaye.posterous.com 2
http://rjsvaljean.com 2
http://posterous.com 2
http://51elliot.blogspot.jp 1
https://home.jolicloud.com 1
http://51elliot.blogspot.tw 1
http://51elliot.blogspot.ru 1
http://51elliot.blogspot.ae 1
http://51elliot.blogspot.it 1
http://51elliot.blogspot.co.il 1
http://www.lmodules.com 1
http://translate.googleusercontent.com 1
http://a0.twimg.com 1
https://lanyrd.com 1
http://webcache.googleusercontent.com 1
http://51elliot.blogspot.com.ar 1
http://rxvl.lan 1
http://www.mefeedia.com 1
http://localhost 1
http://51elliot.blogspot.be 1
More...

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

11 of 1 previous next

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

    Evented I/O based web servers, explained using bunnies Evented I/O based web servers, explained using bunnies Presentation Transcript

    • Evented I/O based web servers, explained using bunnies Simon Willison Part of a talk given at Full Frontal 2009
    • Your Web Server (using a bunny)
    • Your Web Server (using a bunny) Single threaded (one bunny), so can only handle one request at a time Happy hamster
    • Your Web Server (using a bunny) (The hamsters are using web browsers to visit your site) Impatient hamsters
    • Your Web Server 5 bunnies = can handle 5 requests at the same time (using threads, aka bunnies) Happy hamsters
    • fetching a web API (2 seconds) Long running operations cause a thread to block, causing requests to build up in a queue Your Web Server (using threads, aka bunnies)
    • fetching a web API (2 seconds) uploading an image (3 seconds) fetching a web API (2 seconds) fetching a web API (2 seconds) comet long polling (10 seconds) Impatient hamsters
    • Replace the bunnies with a single hyperactive squid. The squid runs up and down as fast as it can dealing with each hamster in turn. It fires off any Your Web Server long running I/O operations and then moves on to the next hamster. When (event loop, aka the I/O operation reports progress, it hyperactive squid) does a little more work on behalf of the corresponding hamster.
    • Bad code • rows = database.fetch(category = 'news') • template = read_file('homepage.html') • json = fetch_url('http://.../') These functions block and wait for results - blocking the squid and causing the entire event loop (and hence server) to pause until they complete
    • Good code • database.fetch(category = 'news', callback) • read_file('homepage.html', callback) • fetch_url('http://.../', callback) These functions specify a callback to be executed as soon as the I/O operation completes