SlideShare ist ein Scribd-Unternehmen logo
1 von 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: #{{proïŹle_background_color}} url({{proïŹle_background_image_url}});

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

  <div class="badge">
   <img class="badge-photo” src="{{ proïŹle_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

Weitere Àhnliche Inhalte

Ähnlich wie Quick'n'Dirty Tornado Intro

Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngine
ikailan
 

Ähnlich wie 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
 

Mehr von Teemu Kurppa

Mehr von 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
 

KĂŒrzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
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
 
+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@
 

KĂŒrzlich hochgeladen (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
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
 
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
 
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
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
+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...
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

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: #{{proïŹle_background_color}} url({{proïŹle_background_image_url}}); ... rest of wrapping and css left-out ... <div class="badge"> <img class="badge-photo” src="{{ proïŹle_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>

Hinweis der Redaktion