SlideShare a Scribd company logo
Real-time Webserving Playing around with Tornado Web Server
Lean Basics While Tornado is similar to existing Web-frameworks in Python (Django, Google's webapp,  web.py ), it focuses on speed and handling large amounts of simultaneous traffic.
RSS reader flagged/read/favourite/selected Show  current  status/price for a number of products Ask the server to process an image Routing chat between webapps Web User Scenarios
Server Startup Multi sub-domain, auto-reloading process Multi sub-domain, auto-reloading process ioloop = tornado.ioloop.IOLoop.instance()  for n in structure.SITES:  site = structure.SITES[n]  if site["package"] in ("tornado", "mediaserver"):  server = HTTPServer( Application (urls,site,ioloop=ioloop))  server.listen(site["port"])  tornado.autoreload.start(io_loop=ioloop)  ioloop.start()
Handle Request urls = [ (r"/static/(.*)", StaticFileHandler),] class MyHandler(tornado. web.RequestHandler ):  def get(self,subpath): info = { “ abc_list”: [“a”, ”b”, ”c”], “ path”: self.request.path, “ subpath”: subpath }  self.render("home.html",**info)  def post(self,subpath):  post_names = self.request.arguments.keys() headers_dict = self.request.headers headers_dict = self.request.headers
Serve Response class MyHandler(tornado. web.RequestHandler ):  def get(self,subpath): site_title = self.application.site["title"]  info = { “ abc_list”: [“a”, ”b”, ”c”], “ site_title”: site_title }  self.render("home.html",**info) def post(self):  post_names = self.request.arguments.keys():  self.set_header("Content-Type","text/plain")  self.write('done.')
Delayed Response class MainHandler(tornado. web.RequestHandler ):  @ tornado. web.asynchronous     def get(self):   http = tornado.httpclient.AsyncHTTPClient()  http.fetch(" http://friendfeed-api.com/v2/feed/ bret ",                   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.bod y)        sel f.write("Fetched " + str(len(json["entries"])) + " entries "  "from the FriendFeed API")  self.finish ()
Baseline Performance Using Apache Bench
Henrik Vendelbo [email_address] http://github.com/thepian
Baseline Performance Using Apache Bench

More Related Content

PDF
用Tornado开发RESTful API运用
Felinx Lee
 
PPTX
Tornado web
kurtiss
 
ZIP
Nginx + Tornado = 17k req/s
moret1979
 
PPTX
Python, async web frameworks, and MongoDB
emptysquare
 
PDF
Tornado Web Server Internals
Praveen Gollakota
 
PDF
An Introduction to Tornado
Gavin Roy
 
PDF
Tornado in Depth
Òscar Vilaplana
 
PPTX
Tornado - different Web programming
Dima Malenko
 
用Tornado开发RESTful API运用
Felinx Lee
 
Tornado web
kurtiss
 
Nginx + Tornado = 17k req/s
moret1979
 
Python, async web frameworks, and MongoDB
emptysquare
 
Tornado Web Server Internals
Praveen Gollakota
 
An Introduction to Tornado
Gavin Roy
 
Tornado in Depth
Òscar Vilaplana
 
Tornado - different Web programming
Dima Malenko
 

What's hot (20)

PDF
Tornadoweb
Osman Yuksel
 
PDF
Rack Middleware
LittleBIGRuby
 
PDF
8 Minutes On Rack
danwrong
 
PDF
Introduction to Flask Micro Framework
Mohammad Reza Kamalifard
 
PDF
Rapid web development using tornado web and mongodb
ikailan
 
PPTX
Phl mongo-philly-tornado-2011
hangxin1940
 
PDF
Introduction to Nodejs
Gabriele Lana
 
PPT
Dance for the puppet master: G6 Tech Talk
Michael Peacock
 
PPT
Powerful and flexible templates with Twig
Michael Peacock
 
PPTX
New in php 7
Vic Metcalfe
 
PDF
Even faster django
Gage Tseng
 
PDF
Web Crawling with NodeJS
Sylvain Zimmer
 
PDF
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
Fernando Hamasaki de Amorim
 
KEY
Building a real life application in node js
fakedarren
 
PPTX
Webrtc mojo
bpmedley
 
PPTX
Building Web Apps with Express
Aaron Stannard
 
PDF
HTTP Caching and PHP
David de Boer
 
PDF
Advanced symfony Techniques
Kris Wallsmith
 
KEY
Perl: Hate it for the Right Reasons
Matt Follett
 
PDF
Rest api with Python
Santosh Ghimire
 
Tornadoweb
Osman Yuksel
 
Rack Middleware
LittleBIGRuby
 
8 Minutes On Rack
danwrong
 
Introduction to Flask Micro Framework
Mohammad Reza Kamalifard
 
Rapid web development using tornado web and mongodb
ikailan
 
Phl mongo-philly-tornado-2011
hangxin1940
 
Introduction to Nodejs
Gabriele Lana
 
Dance for the puppet master: G6 Tech Talk
Michael Peacock
 
Powerful and flexible templates with Twig
Michael Peacock
 
New in php 7
Vic Metcalfe
 
Even faster django
Gage Tseng
 
Web Crawling with NodeJS
Sylvain Zimmer
 
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
Fernando Hamasaki de Amorim
 
Building a real life application in node js
fakedarren
 
Webrtc mojo
bpmedley
 
Building Web Apps with Express
Aaron Stannard
 
HTTP Caching and PHP
David de Boer
 
Advanced symfony Techniques
Kris Wallsmith
 
Perl: Hate it for the Right Reasons
Matt Follett
 
Rest api with Python
Santosh Ghimire
 
Ad

Similar to Real time server (17)

PPTX
Tornado
Cristian Andreica
 
PPTX
Tornado my
Constantine Priemski
 
PDF
Webscraping with asyncio
Jose Manuel Ortega Candel
 
PDF
PyCon lightning talk on my Toro module for Tornado
emptysquare
 
PPTX
Async programming and python
Chetan Giridhar
 
PDF
Denys Serhiienko "ASGI in depth"
Fwdays
 
PDF
Python, fill in code are marked with #FillInStart and #FillInEndim.pdf
agmobiles
 
KEY
Twisted: a quick introduction
Robert Coup
 
ODP
Introduction to Tornado - TienNA
Framgia Vietnam
 
PDF
Asynchronous Python and You
AddShoppers
 
PPT
Introduccion app engine con python
sserrano44
 
PDF
Python Coroutines, Present and Future
emptysquare
 
PPTX
Torando demo
CRidenour
 
PPT
Real-Time Python Web: Gevent and Socket.io
Rick Copeland
 
PDF
Django at Scale
bretthoerner
 
PPTX
Python queue solution with asyncio and kafka
Ondřej Veselý
 
PDF
Behind the curtain - How Django handles a request
Daniel Hepper
 
Webscraping with asyncio
Jose Manuel Ortega Candel
 
PyCon lightning talk on my Toro module for Tornado
emptysquare
 
Async programming and python
Chetan Giridhar
 
Denys Serhiienko "ASGI in depth"
Fwdays
 
Python, fill in code are marked with #FillInStart and #FillInEndim.pdf
agmobiles
 
Twisted: a quick introduction
Robert Coup
 
Introduction to Tornado - TienNA
Framgia Vietnam
 
Asynchronous Python and You
AddShoppers
 
Introduccion app engine con python
sserrano44
 
Python Coroutines, Present and Future
emptysquare
 
Torando demo
CRidenour
 
Real-Time Python Web: Gevent and Socket.io
Rick Copeland
 
Django at Scale
bretthoerner
 
Python queue solution with asyncio and kafka
Ondřej Veselý
 
Behind the curtain - How Django handles a request
Daniel Hepper
 
Ad

Recently uploaded (20)

PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Doc9.....................................
SofiaCollazos
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 

Real time server

  • 1. Real-time Webserving Playing around with Tornado Web Server
  • 2. Lean Basics While Tornado is similar to existing Web-frameworks in Python (Django, Google's webapp, web.py ), it focuses on speed and handling large amounts of simultaneous traffic.
  • 3. RSS reader flagged/read/favourite/selected Show current status/price for a number of products Ask the server to process an image Routing chat between webapps Web User Scenarios
  • 4. Server Startup Multi sub-domain, auto-reloading process Multi sub-domain, auto-reloading process ioloop = tornado.ioloop.IOLoop.instance() for n in structure.SITES: site = structure.SITES[n] if site["package"] in ("tornado", "mediaserver"): server = HTTPServer( Application (urls,site,ioloop=ioloop)) server.listen(site["port"]) tornado.autoreload.start(io_loop=ioloop) ioloop.start()
  • 5. Handle Request urls = [ (r"/static/(.*)", StaticFileHandler),] class MyHandler(tornado. web.RequestHandler ): def get(self,subpath): info = { “ abc_list”: [“a”, ”b”, ”c”], “ path”: self.request.path, “ subpath”: subpath } self.render("home.html",**info) def post(self,subpath): post_names = self.request.arguments.keys() headers_dict = self.request.headers headers_dict = self.request.headers
  • 6. Serve Response class MyHandler(tornado. web.RequestHandler ): def get(self,subpath): site_title = self.application.site["title"] info = { “ abc_list”: [“a”, ”b”, ”c”], “ site_title”: site_title } self.render("home.html",**info) def post(self): post_names = self.request.arguments.keys(): self.set_header("Content-Type","text/plain") self.write('done.')
  • 7. Delayed Response class MainHandler(tornado. web.RequestHandler ): @ tornado. web.asynchronous def get(self): http = tornado.httpclient.AsyncHTTPClient() http.fetch(" http://friendfeed-api.com/v2/feed/ bret ", 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.bod y) sel f.write("Fetched " + str(len(json["entries"])) + " entries " "from the FriendFeed API") self.finish ()
  • 9. Henrik Vendelbo [email_address] http://github.com/thepian