Evented I/O based web servers, explained using bunnies

Simon Willison
Simon WillisonCEO and Co-Founder at Lanyrd
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
1 of 10

Recommended

Cómo conectarse a una red con windows con un teléfono o tablet con android by
Cómo conectarse a una red con windows con un teléfono o tablet con androidCómo conectarse a una red con windows con un teléfono o tablet con android
Cómo conectarse a una red con windows con un teléfono o tablet con androidAleksander Grajeda
6.1K views6 slides
virtual machine.ppt by
virtual machine.pptvirtual machine.ppt
virtual machine.pptSushantShinde74
74 views45 slides
Introduction of AMD Virtual Interrupt Controller by
Introduction of AMD Virtual Interrupt ControllerIntroduction of AMD Virtual Interrupt Controller
Introduction of AMD Virtual Interrupt ControllerThe Linux Foundation
7.9K views26 slides
Virtualization basics by
Virtualization basics Virtualization basics
Virtualization basics Chandrani Ray Chowdhury
27.8K views20 slides
Web engineering cse ru by
Web engineering cse ruWeb engineering cse ru
Web engineering cse ruHossain Md Shakhawat
1.8K views19 slides
[NDC17] Kubernetes로 개발서버 간단히 찍어내기 by
[NDC17] Kubernetes로 개발서버 간단히 찍어내기[NDC17] Kubernetes로 개발서버 간단히 찍어내기
[NDC17] Kubernetes로 개발서버 간단히 찍어내기SeungYong Oh
17.5K views59 slides

More Related Content

What's hot

Application server vs Web Server by
Application server vs Web ServerApplication server vs Web Server
Application server vs Web ServerGagandeep Singh
29.4K views21 slides
Whats New in Integration What's New in IBM Integration Bus and IIB on Cloud by
Whats New in Integration What's New in IBM Integration Bus and IIB on Cloud Whats New in Integration What's New in IBM Integration Bus and IIB on Cloud
Whats New in Integration What's New in IBM Integration Bus and IIB on Cloud Rob Convery
2.7K views35 slides
Basic Introduction to Web Development by
Basic Introduction to Web DevelopmentBasic Introduction to Web Development
Basic Introduction to Web DevelopmentBurhan Khalid
11.1K views53 slides
Static dynamic and active web pages by
Static dynamic and active web pagesStatic dynamic and active web pages
Static dynamic and active web pagesMohammad Kamrul Hasan
34K views37 slides
WebLogic for DBAs by
WebLogic for DBAsWebLogic for DBAs
WebLogic for DBAsSimon Haslam
4.8K views43 slides
Different SoftwareAG webMethods components by
Different SoftwareAG webMethods componentsDifferent SoftwareAG webMethods components
Different SoftwareAG webMethods componentsArul ChristhuRaj Alphonse
468 views17 slides

What's hot(20)

Application server vs Web Server by Gagandeep Singh
Application server vs Web ServerApplication server vs Web Server
Application server vs Web Server
Gagandeep Singh29.4K views
Whats New in Integration What's New in IBM Integration Bus and IIB on Cloud by Rob Convery
Whats New in Integration What's New in IBM Integration Bus and IIB on Cloud Whats New in Integration What's New in IBM Integration Bus and IIB on Cloud
Whats New in Integration What's New in IBM Integration Bus and IIB on Cloud
Rob Convery2.7K views
Basic Introduction to Web Development by Burhan Khalid
Basic Introduction to Web DevelopmentBasic Introduction to Web Development
Basic Introduction to Web Development
Burhan Khalid11.1K views
WebLogic for DBAs by Simon Haslam
WebLogic for DBAsWebLogic for DBAs
WebLogic for DBAs
Simon Haslam4.8K views
Web crawlingchapter by Borseshweta
Web crawlingchapterWeb crawlingchapter
Web crawlingchapter
Borseshweta463 views
نظم التشغيل by Rayaor
نظم التشغيلنظم التشغيل
نظم التشغيل
Rayaor12K views
Virtualization, A Concept Implementation of Cloud by Nishant Munjal
Virtualization, A Concept Implementation of CloudVirtualization, A Concept Implementation of Cloud
Virtualization, A Concept Implementation of Cloud
Nishant Munjal1.4K views
X Window System by Ron Bandes
X Window SystemX Window System
X Window System
Ron Bandes5.6K views
Wowza설치및사용법 by dasom im
Wowza설치및사용법Wowza설치및사용법
Wowza설치및사용법
dasom im8.7K views
Introduction to Hyper-V by Mark Wilson
Introduction to Hyper-VIntroduction to Hyper-V
Introduction to Hyper-V
Mark Wilson12.8K views
Deep Dive into Amazon ElastiCache Architecture and Design Patterns (DAT307) |... by Amazon Web Services
Deep Dive into Amazon ElastiCache Architecture and Design Patterns (DAT307) |...Deep Dive into Amazon ElastiCache Architecture and Design Patterns (DAT307) |...
Deep Dive into Amazon ElastiCache Architecture and Design Patterns (DAT307) |...
Amazon Web Services12.6K views
WEB DEVELOPMENT by khushi74
WEB DEVELOPMENTWEB DEVELOPMENT
WEB DEVELOPMENT
khushi74352 views
linux software architecture by Sneha Ramesh
linux software architecture linux software architecture
linux software architecture
Sneha Ramesh4.4K views

Viewers also liked

Crowdsourcing with Django by
Crowdsourcing with DjangoCrowdsourcing with Django
Crowdsourcing with DjangoSimon Willison
12.4K views83 slides
Talking circles by
Talking circlesTalking circles
Talking circlesDan Belford
1.3K views6 slides
NoSql presentation by
NoSql presentationNoSql presentation
NoSql presentationMat Wall
25.4K views59 slides
What Should I Blog About? by
What Should I Blog About?What Should I Blog About?
What Should I Blog About?Andrea La-Rosa
5.5K views30 slides
The Role of Enterprise Integration in Digital Transformation by
The Role of Enterprise Integration in Digital TransformationThe Role of Enterprise Integration in Digital Transformation
The Role of Enterprise Integration in Digital TransformationKasun Indrasiri
5.4K views50 slides
How to Create an Editorial Calendar for Your Blog by
How to Create an Editorial Calendar for Your BlogHow to Create an Editorial Calendar for Your Blog
How to Create an Editorial Calendar for Your BlogAmanda Nagy
17.7K views19 slides

Viewers also liked(18)

Crowdsourcing with Django by Simon Willison
Crowdsourcing with DjangoCrowdsourcing with Django
Crowdsourcing with Django
Simon Willison12.4K views
Talking circles by Dan Belford
Talking circlesTalking circles
Talking circles
Dan Belford1.3K views
NoSql presentation by Mat Wall
NoSql presentationNoSql presentation
NoSql presentation
Mat Wall25.4K views
What Should I Blog About? by Andrea La-Rosa
What Should I Blog About?What Should I Blog About?
What Should I Blog About?
Andrea La-Rosa5.5K views
The Role of Enterprise Integration in Digital Transformation by Kasun Indrasiri
The Role of Enterprise Integration in Digital TransformationThe Role of Enterprise Integration in Digital Transformation
The Role of Enterprise Integration in Digital Transformation
Kasun Indrasiri5.4K views
How to Create an Editorial Calendar for Your Blog by Amanda Nagy
How to Create an Editorial Calendar for Your BlogHow to Create an Editorial Calendar for Your Blog
How to Create an Editorial Calendar for Your Blog
Amanda Nagy17.7K views
Dear NSA, let me take care of your slides. by Emiland
Dear NSA, let me take care of your slides.Dear NSA, let me take care of your slides.
Dear NSA, let me take care of your slides.
Emiland 1.5M views
What Makes Great Infographics by SlideShare
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great Infographics
SlideShare1.1M views
TEDx Manchester: AI & The Future of Work by Volker Hirsch
TEDx Manchester: AI & The Future of WorkTEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of Work
Volker Hirsch902.8K views
Masters of SlideShare by Kapost
Masters of SlideShareMasters of SlideShare
Masters of SlideShare
Kapost979.8K views
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare by Empowered Presentations
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareSTOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
10 Ways to Win at SlideShare SEO & Presentation Optimization by Oneupweb
10 Ways to Win at SlideShare SEO & Presentation Optimization10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization
Oneupweb926.7K views
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ... by SlideShare
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
SlideShare1.1M views
How to Make Awesome SlideShares: Tips & Tricks by SlideShare
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & Tricks
SlideShare3M views
Getting Started With SlideShare by SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShare
SlideShare4M views

More from Simon Willison

How Lanyrd does Geo by
How Lanyrd does GeoHow Lanyrd does Geo
How Lanyrd does GeoSimon Willison
5.7K views25 slides
Cheap tricks for startups by
Cheap tricks for startupsCheap tricks for startups
Cheap tricks for startupsSimon Willison
8.5K views26 slides
The Django Web Framework (EuroPython 2006) by
The Django Web Framework (EuroPython 2006)The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)Simon Willison
2.9K views56 slides
Building Lanyrd by
Building LanyrdBuilding Lanyrd
Building LanyrdSimon Willison
5.4K views65 slides
How we bootstrapped Lanyrd using Twitter's social graph by
How we bootstrapped Lanyrd using Twitter's social graphHow we bootstrapped Lanyrd using Twitter's social graph
How we bootstrapped Lanyrd using Twitter's social graphSimon Willison
2.2K views23 slides
Web Services for Fun and Profit by
Web Services for Fun and ProfitWeb Services for Fun and Profit
Web Services for Fun and ProfitSimon Willison
2.6K views95 slides

More from Simon Willison(20)

Cheap tricks for startups by Simon Willison
Cheap tricks for startupsCheap tricks for startups
Cheap tricks for startups
Simon Willison8.5K views
The Django Web Framework (EuroPython 2006) by Simon Willison
The Django Web Framework (EuroPython 2006)The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)
Simon Willison2.9K views
How we bootstrapped Lanyrd using Twitter's social graph by Simon Willison
How we bootstrapped Lanyrd using Twitter's social graphHow we bootstrapped Lanyrd using Twitter's social graph
How we bootstrapped Lanyrd using Twitter's social graph
Simon Willison2.2K views
Web Services for Fun and Profit by Simon Willison
Web Services for Fun and ProfitWeb Services for Fun and Profit
Web Services for Fun and Profit
Simon Willison2.6K views
Tricks & challenges developing a large Django application by Simon Willison
Tricks & challenges developing a large Django applicationTricks & challenges developing a large Django application
Tricks & challenges developing a large Django application
Simon Willison13.9K views
Advanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric by Simon Willison
Advanced Aspects of the Django Ecosystem: Haystack, Celery & FabricAdvanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
Advanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
Simon Willison26.2K views
Building Things Fast - and getting approval by Simon Willison
Building Things Fast - and getting approvalBuilding Things Fast - and getting approval
Building Things Fast - and getting approval
Simon Willison1.7K views
Rediscovering JavaScript: The Language Behind The Libraries by Simon Willison
Rediscovering JavaScript: The Language Behind The LibrariesRediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The Libraries
Simon Willison20.1K views
Building crowdsourcing applications by Simon Willison
Building crowdsourcing applicationsBuilding crowdsourcing applications
Building crowdsourcing applications
Simon Willison10.1K views
Cowboy development with Django by Simon Willison
Cowboy development with DjangoCowboy development with Django
Cowboy development with Django
Simon Willison16.9K views
Class-based views with Django by Simon Willison
Class-based views with DjangoClass-based views with Django
Class-based views with Django
Simon Willison2.7K views
Web App Security Horror Stories by Simon Willison
Web App Security Horror StoriesWeb App Security Horror Stories
Web App Security Horror Stories
Simon Willison13.1K views
Web Security Horror Stories by Simon Willison
Web Security Horror StoriesWeb Security Horror Stories
Web Security Horror Stories
Simon Willison32.1K views
When Ajax Attacks! Web application security fundamentals by Simon Willison
When Ajax Attacks! Web application security fundamentalsWhen Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentals
Simon Willison5.6K views

Recently uploaded

iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...Bernd Ruecker
50 views69 slides
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ by
Confidence in CloudStack - Aron Wagner, Nathan Gleason - AmericConfidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
Confidence in CloudStack - Aron Wagner, Nathan Gleason - AmericShapeBlue
41 views9 slides
20231123_Camunda Meetup Vienna.pdf by
20231123_Camunda Meetup Vienna.pdf20231123_Camunda Meetup Vienna.pdf
20231123_Camunda Meetup Vienna.pdfPhactum Softwareentwicklung GmbH
46 views73 slides
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...The Digital Insurer
31 views52 slides
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...ShapeBlue
65 views28 slides
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... by
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...ShapeBlue
42 views13 slides

Recently uploaded(20)

iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker50 views
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ by ShapeBlue
Confidence in CloudStack - Aron Wagner, Nathan Gleason - AmericConfidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
ShapeBlue41 views
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue65 views
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... by ShapeBlue
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
ShapeBlue42 views
DRBD Deep Dive - Philipp Reisner - LINBIT by ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue62 views
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue by ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue85 views
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by ShapeBlue
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
ShapeBlue34 views
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue82 views
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... by ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue83 views
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... by ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue63 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPool by ShapeBlue
Extending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPoolExtending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPool
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPool
ShapeBlue40 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray1080 views
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue by ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
ShapeBlue131 views
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT by ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue91 views
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue46 views

Evented I/O based web servers, explained using bunnies

  • 1. Evented I/O based web servers, explained using bunnies Simon Willison Part of a talk given at Full Frontal 2009
  • 2. Your Web Server (using a bunny)
  • 3. Your Web Server (using a bunny) Single threaded (one bunny), so can only handle one request at a time Happy hamster
  • 4. Your Web Server (using a bunny) (The hamsters are using web browsers to visit your site) Impatient hamsters
  • 5. Your Web Server 5 bunnies = can handle 5 requests at the same time (using threads, aka bunnies) Happy hamsters
  • 6. 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)
  • 7. 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
  • 8. 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.
  • 9. 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
  • 10. 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