SlideShare une entreprise Scribd logo
1  sur  13
quick’n’dirty
TORNADO intro

                   Teemu Kurppa
           www.dirtyaura.org/blog
                   Twitter: teemu

                Huikea Experience
       Social mobile gaming startup
                  www.huikea.com
TORNADO


 scalable, non-blocking web server
TORNADO
  asynchronous requests
  simple clean DB API, no ORM
  programmer-friendly templates
  readable codebase
  proven in production: FriendFeed
TORNADO
Probably good for
real-time web services (hanging GETs to poll)
super-popular dynamic sites
non-web REST services
non-CMS sites
for devs like me
Our Tornado instance
               app



cheap, async call


                    Twitter
Our Tornado instance
db.slow_synchronous_query()

 cheap, async call
                               ?
                     Twitter
Our Tornado instance



               cheap, async calls

  Another Tornado instance
                                    Twitter
db.slow_synchronous_query()
Programmer-friendly templates


    {% for index,value in entries.iteritems() %}
      {{ index }} : {{ value }
    {% end %}


    {% for value in entries %}
      {{ forloop.counter0 }} : {{ value }}
    {% endfor %}
CODE DEMO
class TwitterBadgeHandler(tornado.web.RequestHandler):
   @tornado.web.asynchronous
   def get(self, username):
      http = tornado.httpclient.AsyncHTTPClient()
      url = "http://api.twitter.com/1/users/show/%s.json" % username
      http.fetch(url, callback=self.on_response)

  def on_response(self, response):
    if response.error:
        self.render("badge_error.html")
    else:
        user = tornado.escape.json_decode(response.body)
        self.render("twitter_badge.html", **user)
....
    <style type="text/css">
      .badge {
         background: #{{profile_background_color}} url({{profile_background_image_url}});

... rest of wrapping and css left-out ...

  <div class="badge">
   <img class="badge-photo” src="{{ profile_image_url }}">
   <div class="badge-title">{{ screen_name }}</div>
   <div class="badge-description">{{ description }}</div>
   <div class="clear"></div>
   <div class="badge-status">{{ status['text'] }}</div>
  </div>
Quick'n'Dirty Tornado Intro

Contenu connexe

Similaire à Quick'n'Dirty Tornado Intro

Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngine
ikailan
 

Similaire à Quick'n'Dirty Tornado Intro (20)

Rails missing features
Rails missing featuresRails missing features
Rails missing features
 
Real time server
Real time serverReal time server
Real time server
 
Motion Django Meetup
Motion Django MeetupMotion Django Meetup
Motion Django Meetup
 
Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)
 
Integrating WordPress With Web APIs
Integrating WordPress With Web APIsIntegrating WordPress With Web APIs
Integrating WordPress With Web APIs
 
Develop iOS and Android apps with SharePoint/Office 365
Develop iOS and Android apps with SharePoint/Office 365Develop iOS and Android apps with SharePoint/Office 365
Develop iOS and Android apps with SharePoint/Office 365
 
Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngine
 
Reactive Application Using METEOR
Reactive Application Using METEORReactive Application Using METEOR
Reactive Application Using METEOR
 
Api
ApiApi
Api
 
Web performance optimization
Web performance optimizationWeb performance optimization
Web performance optimization
 
Monitoring distributed (micro-)services
Monitoring distributed (micro-)servicesMonitoring distributed (micro-)services
Monitoring distributed (micro-)services
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
Monitoring as Code: Getting to Monitoring-Driven Development - DEV314 - re:In...
Monitoring as Code: Getting to Monitoring-Driven Development - DEV314 - re:In...Monitoring as Code: Getting to Monitoring-Driven Development - DEV314 - re:In...
Monitoring as Code: Getting to Monitoring-Driven Development - DEV314 - re:In...
 
Rhodes Overview
Rhodes OverviewRhodes Overview
Rhodes Overview
 
Rust: Systems Programming for Everyone
Rust: Systems Programming for EveryoneRust: Systems Programming for Everyone
Rust: Systems Programming for Everyone
 
Using Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in RubyUsing Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in Ruby
 
Think Async: Understanding the Complexity of Multithreading - Avi Kabizon & A...
Think Async: Understanding the Complexity of Multithreading - Avi Kabizon & A...Think Async: Understanding the Complexity of Multithreading - Avi Kabizon & A...
Think Async: Understanding the Complexity of Multithreading - Avi Kabizon & A...
 
Introduction to CloudStack API
Introduction to CloudStack APIIntroduction to CloudStack API
Introduction to CloudStack API
 
Service Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and KubernetesService Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and Kubernetes
 
Serverless for Developers
Serverless for DevelopersServerless for Developers
Serverless for Developers
 

Plus de Teemu Kurppa

Plus de Teemu Kurppa (7)

React + Redux + d3.js
React + Redux + d3.jsReact + Redux + d3.js
React + Redux + d3.js
 
fast.ai - Learning Deep Learning
fast.ai - Learning Deep Learningfast.ai - Learning Deep Learning
fast.ai - Learning Deep Learning
 
Managing data workflows with Luigi
Managing data workflows with LuigiManaging data workflows with Luigi
Managing data workflows with Luigi
 
Early stage startups
Early stage startupsEarly stage startups
Early stage startups
 
Mobile Startups - Why to focus on mobile?
Mobile Startups - Why to focus on mobile?Mobile Startups - Why to focus on mobile?
Mobile Startups - Why to focus on mobile?
 
Platform = Stage. How to choose a mobile development platform?
Platform = Stage. How to choose a mobile development platform?Platform = Stage. How to choose a mobile development platform?
Platform = Stage. How to choose a mobile development platform?
 
Leaks & Zombies
Leaks & ZombiesLeaks & Zombies
Leaks & Zombies
 

Dernier

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
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
 

Dernier (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

Quick'n'Dirty Tornado Intro

  • 1. quick’n’dirty TORNADO intro Teemu Kurppa www.dirtyaura.org/blog Twitter: teemu Huikea Experience Social mobile gaming startup www.huikea.com
  • 2.
  • 4. TORNADO asynchronous requests simple clean DB API, no ORM programmer-friendly templates readable codebase proven in production: FriendFeed
  • 5. TORNADO Probably good for real-time web services (hanging GETs to poll) super-popular dynamic sites non-web REST services non-CMS sites for devs like me
  • 6. Our Tornado instance app cheap, async call Twitter
  • 8. Our Tornado instance cheap, async calls Another Tornado instance Twitter db.slow_synchronous_query()
  • 9. Programmer-friendly templates {% for index,value in entries.iteritems() %} {{ index }} : {{ value } {% end %} {% for value in entries %} {{ forloop.counter0 }} : {{ value }} {% endfor %}
  • 11. class TwitterBadgeHandler(tornado.web.RequestHandler): @tornado.web.asynchronous def get(self, username): http = tornado.httpclient.AsyncHTTPClient() url = "http://api.twitter.com/1/users/show/%s.json" % username http.fetch(url, callback=self.on_response) def on_response(self, response): if response.error: self.render("badge_error.html") else: user = tornado.escape.json_decode(response.body) self.render("twitter_badge.html", **user)
  • 12. .... <style type="text/css"> .badge { background: #{{profile_background_color}} url({{profile_background_image_url}}); ... rest of wrapping and css left-out ... <div class="badge"> <img class="badge-photo” src="{{ profile_image_url }}"> <div class="badge-title">{{ screen_name }}</div> <div class="badge-description">{{ description }}</div> <div class="clear"></div> <div class="badge-status">{{ status['text'] }}</div> </div>

Notes de l'éditeur