SlideShare una empresa de Scribd logo
1 de 15
Tornado Rocking the Non-Blocking Web Contact: Twitter:	 Kurtiss Hare, CTO & Co-Founder of playhaven.com @kurtiss
What is Tornado? Scalable, Non-blocking Web Server Powered www.friendfeed.com Now open-sourced by Facebook after FF acquisition
Why Tornado?
Why Tornado? Paul Buchheit
Why Tornado? Don’t Be Paul Buchheit
Why Tornado? Processor/Thread Model CherryPy, Mod_WSGI, uWSGI, … Lightweight Threads Gevent, Eventlet, … IOLoop/Callback Model Tornado, Cogen, … What are you trying to do?
Why Tornado? Trying to address the c10k problem? 10,000 concurrent connections Processor/thread is known to fall over Trying to enable real-time/long-polling, WebSockets? Different problem than handling many short-lived, pipelined requests. Want to extend your arsenal with a tool that addresses these problems? Tornado might be for you.
Tornado’s Architecture ~2000 clients tornado.ioloop._poll tornado.web.RequestHandler tornado.httpserver.HTTPServer socket.socket tornado.ioloop.IOStream tornado.httpserver.HTTPConnection tornado.web.Application Routing/MVC tornado.ioloop
Tornado’s Architecture tornado.ioloop._poll Edge-triggered when possible (epoll/kqueue) Falls back on level triggered (select) Handles: Callback registration New connections Connections with new data Heart of Tornado’s approach to c10k
Hello, world import tornado.httpserver import tornado.ioloop import tornado.web class MainHandler(tornado.web.RequestHandler):     def get(self):         self.write("Hello, world") application = tornado.web.Application([     (r"/", MainHandler), ]) if __name__ == "__main__”:     http_server = tornado.httpserver.HTTPServer(application)     http_server.listen(8888)     tornado.ioloop.IOLoop.instance().start()
Rocking the Non-Block class MainHandler(tornado.web.RequestHandler):     @tornado.web.asynchronous     def get(self):         http = tornado.httpclient.AsyncHTTPClient()         http.fetch("http://friendfeed-api.com/v2/feed/kurtiss",                    callback=self.async_callback(self.on_response))     def on_response(self, response):         if response.error: raise tornado.web.HTTPError(500)         json = tornado.escape.json_decode(response.body)         self.write("Fetched " + str(len(json["entries"])) + " entries ”)         self.finish()
Performance Notes Source: http://developers.facebook.com/blog/post/301
Performance Notes Better Comparisons Node.js – Tornado by 110% throughput [0] Twisted.Web – Tornado by 84% shorter average response time [1] Caveat Emptor, OK? http://nichol.as/benchmark-of-python-web-servers Of note, “Server Latency,” vs. gEvent, uWSGI Likely due to CPU availability Nothing beats a load test on your own environment PlayHaven’s use is modest, but growing: <500 concurrent web requests No long polling … yet. [0] http://news.ycombinator.com/item?id=1089340 [1] http://www.apparatusproject.org/blog/2009/09/twisted-web-vs-tornado-part-deux/
Let’s Code
Questions? Beer?

Más contenido relacionado

La actualidad más candente

用Tornado开发RESTful API运用
用Tornado开发RESTful API运用用Tornado开发RESTful API运用
用Tornado开发RESTful API运用
Felinx Lee
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
Hiroshi Nakamura
 

La actualidad más candente (20)

Real time server
Real time serverReal time server
Real time server
 
Even faster django
Even faster djangoEven faster django
Even faster django
 
Pycon - Python for ethical hackers
Pycon - Python for ethical hackers Pycon - Python for ethical hackers
Pycon - Python for ethical hackers
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node js
 
用Tornado开发RESTful API运用
用Tornado开发RESTful API运用用Tornado开发RESTful API运用
用Tornado开发RESTful API运用
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in Practise
 
Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
 
WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! Framework
 
Implementing Comet using PHP
Implementing Comet using PHPImplementing Comet using PHP
Implementing Comet using PHP
 
Vert.x clustering on Docker, CoreOS and ETCD
Vert.x clustering on Docker, CoreOS and ETCDVert.x clustering on Docker, CoreOS and ETCD
Vert.x clustering on Docker, CoreOS and ETCD
 
About Node.js
About Node.jsAbout Node.js
About Node.js
 
AJAX Transport Layer
AJAX Transport LayerAJAX Transport Layer
AJAX Transport Layer
 
Using Websockets with Play!
Using Websockets with Play!Using Websockets with Play!
Using Websockets with Play!
 
A complete guide to Node.js
A complete guide to Node.jsA complete guide to Node.js
A complete guide to Node.js
 
Node worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioNode worshop Realtime - Socket.io
Node worshop Realtime - Socket.io
 
Groovy Powered Clean Code
Groovy Powered Clean CodeGroovy Powered Clean Code
Groovy Powered Clean Code
 
Java Play RESTful ebean
Java Play RESTful ebeanJava Play RESTful ebean
Java Play RESTful ebean
 
Real Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.ioReal Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.io
 

Destacado

GEOG101 Tornado Presentation
GEOG101 Tornado PresentationGEOG101 Tornado Presentation
GEOG101 Tornado Presentation
Tracy Mascorro
 
La morfologia il caso
La morfologia il casoLa morfologia il caso
La morfologia il caso
efeso78
 
Presentation visual aide tornado burdick qcc101
Presentation visual aide tornado burdick qcc101Presentation visual aide tornado burdick qcc101
Presentation visual aide tornado burdick qcc101
Chad Burdick
 
tornado powerpoint
 tornado powerpoint tornado powerpoint
tornado powerpoint
clh121
 
Holly's Tornado Presentation
Holly's Tornado PresentationHolly's Tornado Presentation
Holly's Tornado Presentation
jennyv1
 
Introduction to Tornado - TienNA
Introduction to Tornado - TienNAIntroduction to Tornado - TienNA
Introduction to Tornado - TienNA
Framgia Vietnam
 

Destacado (18)

Tornado
TornadoTornado
Tornado
 
Tornado presentation
Tornado presentationTornado presentation
Tornado presentation
 
GEOG101 Tornado Presentation
GEOG101 Tornado PresentationGEOG101 Tornado Presentation
GEOG101 Tornado Presentation
 
Thinking Tornadoes
Thinking TornadoesThinking Tornadoes
Thinking Tornadoes
 
Hurricanes
HurricanesHurricanes
Hurricanes
 
La morfologia il caso
La morfologia il casoLa morfologia il caso
La morfologia il caso
 
Presentation 2
Presentation 2Presentation 2
Presentation 2
 
HCS Tornado Safety
HCS Tornado SafetyHCS Tornado Safety
HCS Tornado Safety
 
Vasu
VasuVasu
Vasu
 
Presentation visual aide tornado burdick qcc101
Presentation visual aide tornado burdick qcc101Presentation visual aide tornado burdick qcc101
Presentation visual aide tornado burdick qcc101
 
tornado powerpoint
 tornado powerpoint tornado powerpoint
tornado powerpoint
 
Holly's Tornado Presentation
Holly's Tornado PresentationHolly's Tornado Presentation
Holly's Tornado Presentation
 
Tornadoes
TornadoesTornadoes
Tornadoes
 
Introduction to Tornado - TienNA
Introduction to Tornado - TienNAIntroduction to Tornado - TienNA
Introduction to Tornado - TienNA
 
Handling Disaster and Overcoming Adversity - Mayflower Mayor Randy Holland
Handling Disaster and Overcoming Adversity - Mayflower Mayor Randy HollandHandling Disaster and Overcoming Adversity - Mayflower Mayor Randy Holland
Handling Disaster and Overcoming Adversity - Mayflower Mayor Randy Holland
 
Tornadoes
TornadoesTornadoes
Tornadoes
 
Mapping a Tornado Tragedy: Library Technology Conference 2017
Mapping a Tornado Tragedy: Library Technology Conference 2017Mapping a Tornado Tragedy: Library Technology Conference 2017
Mapping a Tornado Tragedy: Library Technology Conference 2017
 
Tornadoes
TornadoesTornadoes
Tornadoes
 

Similar a Tornado web

Why Node.js
Why Node.jsWhy Node.js
Why Node.js
guileen
 
Bar Camp Ubiquity Presentation
Bar Camp Ubiquity PresentationBar Camp Ubiquity Presentation
Bar Camp Ubiquity Presentation
Andy Edmonds
 
Bar Camp Talk on Ubiquity
Bar Camp Talk on UbiquityBar Camp Talk on Ubiquity
Bar Camp Talk on Ubiquity
guest5014a
 
12 core technologies you should learn, love, and hate to be a 'real' technocrat
12 core technologies you should learn, love, and hate to be a 'real' technocrat12 core technologies you should learn, love, and hate to be a 'real' technocrat
12 core technologies you should learn, love, and hate to be a 'real' technocrat
Jonathan Linowes
 

Similar a Tornado web (20)

Devoxx Maroc 2015 HTTP 1, HTTP 2 and folks
Devoxx Maroc  2015 HTTP 1, HTTP 2 and folksDevoxx Maroc  2015 HTTP 1, HTTP 2 and folks
Devoxx Maroc 2015 HTTP 1, HTTP 2 and folks
 
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
Android Performance #4: Network
Android Performance #4: NetworkAndroid Performance #4: Network
Android Performance #4: Network
 
Tornado
TornadoTornado
Tornado
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
Bar Camp Ubiquity Presentation
Bar Camp Ubiquity PresentationBar Camp Ubiquity Presentation
Bar Camp Ubiquity Presentation
 
Bar Camp Talk on Ubiquity
Bar Camp Talk on UbiquityBar Camp Talk on Ubiquity
Bar Camp Talk on Ubiquity
 
Ajax to the Moon
Ajax to the MoonAjax to the Moon
Ajax to the Moon
 
Performance #4 network
Performance #4  networkPerformance #4  network
Performance #4 network
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of users
 
Life on the Edge with ESI
Life on the Edge with ESILife on the Edge with ESI
Life on the Edge with ESI
 
Ruby Conf Preso
Ruby Conf PresoRuby Conf Preso
Ruby Conf Preso
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
 
Building an inflight entertainment system controller in twisted
Building an inflight entertainment system controller in twistedBuilding an inflight entertainment system controller in twisted
Building an inflight entertainment system controller in twisted
 
Dave Orchard - Offline Web Apps with HTML5
Dave Orchard - Offline Web Apps with HTML5Dave Orchard - Offline Web Apps with HTML5
Dave Orchard - Offline Web Apps with HTML5
 
12 core technologies you should learn, love, and hate to be a 'real' technocrat
12 core technologies you should learn, love, and hate to be a 'real' technocrat12 core technologies you should learn, love, and hate to be a 'real' technocrat
12 core technologies you should learn, love, and hate to be a 'real' technocrat
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Tornado web

  • 1. Tornado Rocking the Non-Blocking Web Contact: Twitter: Kurtiss Hare, CTO & Co-Founder of playhaven.com @kurtiss
  • 2. What is Tornado? Scalable, Non-blocking Web Server Powered www.friendfeed.com Now open-sourced by Facebook after FF acquisition
  • 4. Why Tornado? Paul Buchheit
  • 5. Why Tornado? Don’t Be Paul Buchheit
  • 6. Why Tornado? Processor/Thread Model CherryPy, Mod_WSGI, uWSGI, … Lightweight Threads Gevent, Eventlet, … IOLoop/Callback Model Tornado, Cogen, … What are you trying to do?
  • 7. Why Tornado? Trying to address the c10k problem? 10,000 concurrent connections Processor/thread is known to fall over Trying to enable real-time/long-polling, WebSockets? Different problem than handling many short-lived, pipelined requests. Want to extend your arsenal with a tool that addresses these problems? Tornado might be for you.
  • 8. Tornado’s Architecture ~2000 clients tornado.ioloop._poll tornado.web.RequestHandler tornado.httpserver.HTTPServer socket.socket tornado.ioloop.IOStream tornado.httpserver.HTTPConnection tornado.web.Application Routing/MVC tornado.ioloop
  • 9. Tornado’s Architecture tornado.ioloop._poll Edge-triggered when possible (epoll/kqueue) Falls back on level triggered (select) Handles: Callback registration New connections Connections with new data Heart of Tornado’s approach to c10k
  • 10. Hello, world import tornado.httpserver import tornado.ioloop import tornado.web class MainHandler(tornado.web.RequestHandler): def get(self): self.write("Hello, world") application = tornado.web.Application([ (r"/", MainHandler), ]) if __name__ == "__main__”: http_server = tornado.httpserver.HTTPServer(application) http_server.listen(8888) tornado.ioloop.IOLoop.instance().start()
  • 11. Rocking the Non-Block class MainHandler(tornado.web.RequestHandler): @tornado.web.asynchronous def get(self): http = tornado.httpclient.AsyncHTTPClient() http.fetch("http://friendfeed-api.com/v2/feed/kurtiss", callback=self.async_callback(self.on_response)) def on_response(self, response): if response.error: raise tornado.web.HTTPError(500) json = tornado.escape.json_decode(response.body) self.write("Fetched " + str(len(json["entries"])) + " entries ”) self.finish()
  • 12. Performance Notes Source: http://developers.facebook.com/blog/post/301
  • 13. Performance Notes Better Comparisons Node.js – Tornado by 110% throughput [0] Twisted.Web – Tornado by 84% shorter average response time [1] Caveat Emptor, OK? http://nichol.as/benchmark-of-python-web-servers Of note, “Server Latency,” vs. gEvent, uWSGI Likely due to CPU availability Nothing beats a load test on your own environment PlayHaven’s use is modest, but growing: <500 concurrent web requests No long polling … yet. [0] http://news.ycombinator.com/item?id=1089340 [1] http://www.apparatusproject.org/blog/2009/09/twisted-web-vs-tornado-part-deux/