SlideShare ist ein Scribd-Unternehmen logo
1 von 13
globo   Tornado + Nginx = 17k req/s
.com
two servers, one goal
‣   huge potential userbase
            ‣   live sports events

1.000.000   ‣

            ‣
                changing business model
                unknown user behavior
            ‣   “beta” - small investment
            ‣   gotta keep it simple!
“It's time for web servers to handle ten thousand clients simultaneously,
don't you think? After all, the web is a big place now.”
as simple as you need - as robust as you want


    nginx          nginx         tornado        mongo
  frontend        backend




                     filer
                 filesystem
‣   “there’s a lot of caching”
    ‣   scores, current transmissions etc. are updated quickly
    ‣   out of bounds to the general public - closed beta
‣   authentication and authorization from separate systems
    ‣   just checking if cookies exist on the frontend
import tornado.ioloop
                            import tornado.web

‣   plain Python            class MainHandler(tornado.web.RequestHandler):
                                def get(self):
‣   good looking Python             self.write("Hello, world")

‣   sweet!                  application = tornado.web.Application([
                                (r"/", MainHandler),
                            ])
‣   fast!
                            if __name__ == "__main__":
    ‣   ab req/s: 2987.96       application.listen(8888)
                                tornado.ioloop.IOLoop.instance().start()
import   json
                                     import   tornado.ioloop
                                     import   tornado.web
                                     import   tornado.httpclient

                                     search = 'http://search.twitter.com/search.json?
‣   non-blocking web server          q=pythonbrasil&result_type=mixed&count=1'

                                     class MainHandler(tornado.web.RequestHandler):
‣   so please don’t block it!            def get(self):
                                             self.write("Hello blocking Twitter!n")
                                             http_client = tornado.httpclient.HTTPClient()
‣   the blocking way...                      response = http_client.fetch(search)
                                             last_tweet = json.loads(response.body)['results'][0]['text']
                                             self.write(last_tweet)
    ‣   ab req/s: 0.81               application = tornado.web.Application([
                                         (r"/", MainHandler),
        (over our poor local wi-fi)   ])

                                     if __name__ == "__main__":
                                         application.listen(8888)
                                         tornado.ioloop.IOLoop.instance().start()
import json
                                     import tornado.ioloop
                                     import tornado.web
                                     import tornado.httpclient
                                     from tornado.web import asynchronous

                                     search = 'http://search.twitter.com/search.json?
                                     q=pythonbrasil&result_type=mixed&count=1'
‣   the non-blocking way...          class MainHandler(tornado.web.RequestHandler):

    ‣   ab req/s: 7.25                   @asynchronous
                                         def get(self):
                                             self.write("Hello blocking Twitter!n")
        (over our poor local wi-fi)           http_client = tornado.httpclient.AsyncHTTPClient()
                                             response = http_client.fetch(search, self.handle_response)

                                         def handle_response(self, response):
                                             last_tweet = json.loads(response.body)['results'][0]['text']
                                             self.finish(last_tweet)

                                     application = tornado.web.Application([
                                         (r"/", MainHandler),
                                     ])

                                     if __name__ == "__main__":
                                         application.listen(8888)
                                         tornado.ioloop.IOLoop.instance().start()
import tornado.ioloop
                          import tornado.web
                          from db import users

                          class HomeHandler(tornado.web.RequestHandler):
                              def get(self):
                                  if 'signed_in' == self.get_secure_cookie('access'):
                                      self.write('Hello to your world!')
                                  else:
                                      self. write('Hello, world!')

‣   secure cookies        class SigninHandler(tornado.web.RequestHandler):
                              def post(self):
                                  if self.get_attribute('login') in users:
    ‣   not persisted                 self.set_secure_cookie('access', 'signed_in',
                                                             expires_days=None)
                                  self.redirect('/')
    ‣   served from any   class SignoutHandler(tornado.web.RequestHandler):
                              def get(self):
        instance                  self.clear_cookie('access')
                                  self.redirect('/')

                          application = tornado.web.Application([
                              (r"/", HomeHandler), (r"/signin", SigninHandler),
                              (r"/signout", SignoutHandler),
                          ], **{
                              'cookie_secret': 'i_should_be_reading_that_from_env'
                          })

                          if __name__ == "__main__":
                              application.listen(8888)
                              tornado.ioloop.IOLoop.instance().start()
‣   what else?
    ‣   templates extensions
    ‣   semi-standardized project structure
    ‣   pre-rendered data for frequently updated data - scores
‣   most URLs are served as fast
             as nginx can
         ‣   on a single 24 processors

17.000       server our load tests got us
             to 17k req/s served by
             Tornado
         ‣   few pages with heavy DB
             access served less than 4k
             req/s
Valeu!
Danilo Moret - Globo.com / Webmedia / Vídeos 3
moret@corp.globo.com - http://moret.pro.br/ - @moret1979

Weitere ähnliche Inhalte

Was ist angesagt?

Real time server
Real time serverReal time server
Real time serverthepian
 
Even faster django
Even faster djangoEven faster django
Even faster djangoGage Tseng
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node jsfakedarren
 
PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2Graham Dumpleton
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejsAmit Thakkar
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseChristian Melchior
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJSSylvain Zimmer
 
用Tornado开发RESTful API运用
用Tornado开发RESTful API运用用Tornado开发RESTful API运用
用Tornado开发RESTful API运用Felinx Lee
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkAarti Parikh
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express Jeetendra singh
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...Tom Croucher
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsjacekbecela
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with ExamplesGabriele Lana
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011hangxin1940
 

Was ist angesagt? (20)

Real time server
Real time serverReal time server
Real time server
 
Even faster django
Even faster djangoEven faster django
Even faster django
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node js
 
PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejs
 
What is nodejs
What is nodejsWhat is nodejs
What is nodejs
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in Practise
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJS
 
用Tornado开发RESTful API运用
用Tornado开发RESTful API运用用Tornado开发RESTful API运用
用Tornado开发RESTful API运用
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Node.js - A Quick Tour
Node.js - A Quick TourNode.js - A Quick Tour
Node.js - A Quick Tour
 
Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011
 

Ähnlich wie Nginx + Tornado = 17k req/s

服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScriptQiangning Hong
 
An opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathonAn opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathonLuciano Mammino
 
Flask patterns
Flask patternsFlask patterns
Flask patternsit-people
 
Implementing new WebAPIs
Implementing new WebAPIsImplementing new WebAPIs
Implementing new WebAPIsJulian Viereck
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiJérémy Derussé
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Hugo Hamon
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...Tom Croucher
 
Async task, threads, pools, and executors oh my!
Async task, threads, pools, and executors oh my!Async task, threads, pools, and executors oh my!
Async task, threads, pools, and executors oh my!Stacy Devino
 
Serverless archtiectures
Serverless archtiecturesServerless archtiectures
Serverless archtiecturesIegor Fadieiev
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJSWei Ru
 
Ato2019 weave-services-istio
Ato2019 weave-services-istioAto2019 weave-services-istio
Ato2019 weave-services-istioLin Sun
 
Weave Your Microservices with Istio
Weave Your Microservices with IstioWeave Your Microservices with Istio
Weave Your Microservices with IstioAll Things Open
 
All Things Open 2019 weave-services-istio
All Things Open 2019 weave-services-istioAll Things Open 2019 weave-services-istio
All Things Open 2019 weave-services-istioLin Sun
 
Tasks: you gotta know how to run them
Tasks: you gotta know how to run themTasks: you gotta know how to run them
Tasks: you gotta know how to run themFilipe Ximenes
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it meansRobert Nyman
 
IstSec'14 - İbrahim BALİÇ - Automated Malware Analysis
IstSec'14 - İbrahim BALİÇ -  Automated Malware AnalysisIstSec'14 - İbrahim BALİÇ -  Automated Malware Analysis
IstSec'14 - İbrahim BALİÇ - Automated Malware AnalysisBGA Cyber Security
 
Using google appengine
Using google appengineUsing google appengine
Using google appengineWei Sun
 
Spring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenSpring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenJoshua Long
 

Ähnlich wie Nginx + Tornado = 17k req/s (20)

服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript
 
An opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathonAn opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathon
 
Flask patterns
Flask patternsFlask patterns
Flask patterns
 
Implementing New Web
Implementing New WebImplementing New Web
Implementing New Web
 
Implementing new WebAPIs
Implementing new WebAPIsImplementing new WebAPIs
Implementing new WebAPIs
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
 
Async task, threads, pools, and executors oh my!
Async task, threads, pools, and executors oh my!Async task, threads, pools, and executors oh my!
Async task, threads, pools, and executors oh my!
 
Serverless archtiectures
Serverless archtiecturesServerless archtiectures
Serverless archtiectures
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
 
Ato2019 weave-services-istio
Ato2019 weave-services-istioAto2019 weave-services-istio
Ato2019 weave-services-istio
 
Weave Your Microservices with Istio
Weave Your Microservices with IstioWeave Your Microservices with Istio
Weave Your Microservices with Istio
 
All Things Open 2019 weave-services-istio
All Things Open 2019 weave-services-istioAll Things Open 2019 weave-services-istio
All Things Open 2019 weave-services-istio
 
Tasks: you gotta know how to run them
Tasks: you gotta know how to run themTasks: you gotta know how to run them
Tasks: you gotta know how to run them
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it means
 
IstSec'14 - İbrahim BALİÇ - Automated Malware Analysis
IstSec'14 - İbrahim BALİÇ -  Automated Malware AnalysisIstSec'14 - İbrahim BALİÇ -  Automated Malware Analysis
IstSec'14 - İbrahim BALİÇ - Automated Malware Analysis
 
Using google appengine
Using google appengineUsing google appengine
Using google appengine
 
Spring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenSpring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in Heaven
 

Kürzlich hochgeladen

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.pdfsudhanshuwaghmare1
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Kürzlich hochgeladen (20)

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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Nginx + Tornado = 17k req/s

  • 1. globo Tornado + Nginx = 17k req/s .com
  • 3. huge potential userbase ‣ live sports events 1.000.000 ‣ ‣ changing business model unknown user behavior ‣ “beta” - small investment ‣ gotta keep it simple!
  • 4. “It's time for web servers to handle ten thousand clients simultaneously, don't you think? After all, the web is a big place now.”
  • 5. as simple as you need - as robust as you want nginx nginx tornado mongo frontend backend filer filesystem
  • 6. “there’s a lot of caching” ‣ scores, current transmissions etc. are updated quickly ‣ out of bounds to the general public - closed beta ‣ authentication and authorization from separate systems ‣ just checking if cookies exist on the frontend
  • 7. import tornado.ioloop import tornado.web ‣ plain Python class MainHandler(tornado.web.RequestHandler):     def get(self): ‣ good looking Python         self.write("Hello, world") ‣ sweet! application = tornado.web.Application([     (r"/", MainHandler), ]) ‣ fast! if __name__ == "__main__": ‣ ab req/s: 2987.96     application.listen(8888)     tornado.ioloop.IOLoop.instance().start()
  • 8. import json import tornado.ioloop import tornado.web import tornado.httpclient search = 'http://search.twitter.com/search.json? ‣ non-blocking web server q=pythonbrasil&result_type=mixed&count=1' class MainHandler(tornado.web.RequestHandler): ‣ so please don’t block it!     def get(self):         self.write("Hello blocking Twitter!n")         http_client = tornado.httpclient.HTTPClient() ‣ the blocking way...         response = http_client.fetch(search)         last_tweet = json.loads(response.body)['results'][0]['text']         self.write(last_tweet) ‣ ab req/s: 0.81 application = tornado.web.Application([     (r"/", MainHandler), (over our poor local wi-fi) ]) if __name__ == "__main__":     application.listen(8888)     tornado.ioloop.IOLoop.instance().start()
  • 9. import json import tornado.ioloop import tornado.web import tornado.httpclient from tornado.web import asynchronous search = 'http://search.twitter.com/search.json? q=pythonbrasil&result_type=mixed&count=1' ‣ the non-blocking way... class MainHandler(tornado.web.RequestHandler): ‣ ab req/s: 7.25     @asynchronous     def get(self):         self.write("Hello blocking Twitter!n") (over our poor local wi-fi)         http_client = tornado.httpclient.AsyncHTTPClient()         response = http_client.fetch(search, self.handle_response)     def handle_response(self, response):         last_tweet = json.loads(response.body)['results'][0]['text']         self.finish(last_tweet) application = tornado.web.Application([     (r"/", MainHandler), ]) if __name__ == "__main__":     application.listen(8888)     tornado.ioloop.IOLoop.instance().start()
  • 10. import tornado.ioloop import tornado.web from db import users class HomeHandler(tornado.web.RequestHandler):     def get(self):         if 'signed_in' == self.get_secure_cookie('access'):             self.write('Hello to your world!')         else:             self. write('Hello, world!') ‣ secure cookies class SigninHandler(tornado.web.RequestHandler):     def post(self):         if self.get_attribute('login') in users: ‣ not persisted             self.set_secure_cookie('access', 'signed_in', expires_days=None)         self.redirect('/') ‣ served from any class SignoutHandler(tornado.web.RequestHandler):     def get(self): instance         self.clear_cookie('access')         self.redirect('/') application = tornado.web.Application([     (r"/", HomeHandler), (r"/signin", SigninHandler),     (r"/signout", SignoutHandler), ], **{     'cookie_secret': 'i_should_be_reading_that_from_env' }) if __name__ == "__main__":     application.listen(8888)     tornado.ioloop.IOLoop.instance().start()
  • 11. what else? ‣ templates extensions ‣ semi-standardized project structure ‣ pre-rendered data for frequently updated data - scores
  • 12. most URLs are served as fast as nginx can ‣ on a single 24 processors 17.000 server our load tests got us to 17k req/s served by Tornado ‣ few pages with heavy DB access served less than 4k req/s
  • 13. Valeu! Danilo Moret - Globo.com / Webmedia / Vídeos 3 moret@corp.globo.com - http://moret.pro.br/ - @moret1979

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n