Tornado
- 2. Real Time, so what?Tornado – The baby that comes with it1000s simultaneously active connections
- 3. Open-source (Apache 2.0 License)NginxNon-blocking web serverEpoll (callbacks on the kernel file structure)Push vs Pull (long polling)Real-time web services
- 5. - Code SnippetsURL Mapping (get + post)class MainHandler(tornado.web.RequestHandler): def get(self): self.write("You requested the main page") class StoryHandler(tornado.web.RequestHandler): def get(self, story_id): self.write("You requested the story " + story_id) application = tornado.web.Application([ (r"/", MainHandler), (r"/story/([0-9]+)", StoryHandler), ])Post arguments class MainHandler(tornado.web.RequestHandler): def get(self): self.write('<html><body><form action="/" method="post">' '<input type="text" name="message">' '<input type="submit" value="Submit">' '</form></body></html>') def post(self): self.set_header("Content-Type", "text/plain") self.write("You wrote " + self.get_argument("message"))HTTPRequest
- 6. - Code SnippetsHTML Templates<html> <head> <title>{{ title }}</title> </head> <body> <ul> {% for item in items %} <li>{{ escape(item) }}</li> {% end %} </ul> </body> </html>Template Handlerclass MainHandler(tornado.web.RequestHandler): def get(self): Items = ["Item 1", "Item 2", "Item 3"] self.render("template.html", title="My title", items=items)
- 9. MySQLBlog Post 1WidgetmyModule.pyBlog Post 2WidgetWeb Page<short python code here…>
- 10. - Asynchronous Requests1. Fetch datawww.website.comPicasa/Flickr2. Response (callback)Synchronous Requests immediate server response
- 11. cannot later-update the clientAsynchronous Requests immediate server response
- 12. allows for 3rd party services
- 13. push technologies- ReferencesNon-blockingLong-pollingWeb ServerCSRF ProtectionAsynchronousSigned CookiesmodularTornado - http://www.tornadoweb.org/Epoll man page - http://linux.die.net/man/4/epollLong Pooling - http://en.wikipedia.org/wiki/Push_technologyCSRF - http://en.wikipedia.org/wiki/Cross-site_request_forgeryHack it now…Q/A minute
Editor's Notes
- - Facebook Tornado (ce este tornado, structura de ansamblu a modulelor, care sunt beneficiile, cum se utilizeaza)- Rata de adoptie pe web a tehnologiilor (weekend sized-problem)
- Cati au cont pe faceboook?Stie cineva ce e friendfeed?La ce foloseste?Acquisition price, value baby (Tornado)
- - Ce e tornado in esenta?blocking vs non-blocking- Select O(n) , epoll O(1)- Real time web services: search, news, contacts