Real time server
Upcoming SlideShare
Loading in...5
×
 

Real time server

on

  • 2,953 views

Real time web serving with Tornado

Real time web serving with Tornado

Statistics

Views

Total Views
2,953
Views on SlideShare
2,951
Embed Views
2

Actions

Likes
6
Downloads
65
Comments
0

2 Embeds 2

http://www.coffav.com 1
http://www.techgig.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

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
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Real time server Real time server Presentation Transcript

  • 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 View slide
  • 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() View slide
  • 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