SlideShare a Scribd company logo
WSGI, Django &
                           Gunicorn
                              Benoît Chesneau
                          25/04/2010 - djangocong
Sunday, April 25, 2010
benoît chesneau

              benoitc@apache.org
              Artisan web
              Minimal web & Opensource
              Enki Multimedia
              http://www.e-engura.com



Sunday, April 25, 2010
• WSGI ?
                         • Django & WSGI
                         • Gunicorn




Sunday, April 25, 2010
WSGI ?

                     • Web Server Gateway Interface
                     • PEP 333
                     • Interface entre le web et une application
                         Python




Sunday, April 25, 2010
Serveur web




                               WSGI




                         Application Python




Sunday, April 25, 2010
simple application
                   def app(environ, start_response):
                       """Simplest possible application object"""
                       data = 'Hello, World!n'
                       status = '200 OK'
                       response_headers = [
                           ('Content-type','text/plain'),
                           ('Content-Length', str(len(data)))
                       ]
                       start_response(status, response_headers)
                       return iter([data])




Sunday, April 25, 2010
WSGI ?

                     • Réutilisation d’applications
                     • Middleware
                     • Paster
                     • Frameworks: webob, werkzeug, bottle,
                         repoze, ...



Sunday, April 25, 2010
Middleware WSGI

                         class CustomHeader(object):

                             def __init__(self, app):
                                 self.app = app

                             def __call__(self, environ, start_response):
                                 environ["HTTP_X_MY_HEADER"] = "1"
                                 return self.app(environ, start_response)




Sunday, April 25, 2010
Serveur web




                                 WSGI




                          Application Python


                         App      App        App


Sunday, April 25, 2010
Django & WSGI



Sunday, April 25, 2010
Intégrer

                     • Pourquoi réinventer la roue ?
                     • Principes communs: middlewares,
                         request, ...
                     • Réutiliser les applications.
                     • intégrer != compatible wsgi

Sunday, April 25, 2010
• django-wsgi
                     • twod.wsgi



Sunday, April 25, 2010
django-wsgi

                     • pas de dependance
                     • permet d’embarquer des apps wsgi,
                         `django_view`
                     • permet de creer une app wsgi à partir
                         d’une vue ou des urls, `wsgi_application`



Sunday, April 25, 2010
django_view
                 def test_app(environ, start_response):
                     start_response("200 OK", [("Content-type", "text/
                 html")])
                     yield "i suck"

                 def test_app1(request):
                     return HttpResponse("wowa, meta")

                 urls = patterns("",
                     ..
                     (r"^test/$", django_view(test_app)),
                     (r"^(?P<name>.*?)/$", test_app1),
                     ..
                 )

                 application = wsgi_application(urls)


Sunday, April 25, 2010
twod.wsgi
                     • vise à créer une "paserelle coopérative"
                         entre Django et WSGI
                     • basé sur webob (wrap HttpRequest et
                         HttpResponse)
                     • Paste deploy factory
                     • Middleware pour le routage

Sunday, April 25, 2010
twod.wsgi - embed

          import os
          from twod.wsgi import DjangoApplication

          os.environ['DJANGO_SETTINGS_MODULE'] = "yourpackage.settings"
          django_app = DjangoApplication()




Sunday, April 25, 2010
twod.wsgi routing args
                         (r'^/blog/posts/(?<post_slug>w+)/comments/(?
                         <post_comment_id>d+)$'




                         >>> request.urlvars
                         {'post_slug': "hello-world", 'post_comment_id': "3"}




Sunday, April 25, 2010
twod.wsgi - embed

                     • intégrer une application WSGI au sein de
                         votre projet django
                     • modifier les requêtes/réponses
                     • Integrer votre app django dans une app
                         WSGI



Sunday, April 25, 2010
embarque les apps
                              WSGI
           from twod.wsgi import call_wsgi_app
           from somewhere import wsgi_app

           def run_app(request, path_info):
               response = call_wsgi_app(wsgi_app, request, path_info)
               response['Server'] = "twod.wsgi 1.0"
               return response




Sunday, April 25, 2010
Déployer

                     • l’utilisation courante de Django avec WSGI
                     • 2 types de deploiements :
                      • via serveur
                      • via proxy

Sunday, April 25, 2010
Serveur


                     • uWSGI
                     • mod_proxy


Sunday, April 25, 2010
proxy

                     • spawning, paster, ...
                     • cherrypy, ..
                     • gunicorn


Sunday, April 25, 2010
Sunday, April 25, 2010
Sunday, April 25, 2010
gunicorn
                     • Green unicorn
                     • WSGI 1.0, clients lents et rapides
                     • supporte WSGI, Paster compatible app & ...
                         Django
                     • Load balancing via pre-fork and un socket
                         partagé
                     • Upgrade à chaud “à la nginx”
Sunday, April 25, 2010
mais encore...
                     • HTTP Stream. Décode le HTTP à la volée
                     • Gestion des connexions asynchrones
                         (longpolling, comet, websockets, appels
                         d’api, ...).
                     • Eventlet, Gevent, Tornado
                     • DSL Config

Sunday, April 25, 2010
Philosophie

                     • Simple
                     • Minimal
                     • Performant
                     • Unix

Sunday, April 25, 2010
Simple

                     • gunicorn_django -w 3 /myproject/
                         settings.py
                     • ./manage.py run_django -w 3
                     • gunicorn_django -w 3 -k
                         “egg:gunicorn#eventlet” /myproject/
                         settings.py



Sunday, April 25, 2010
Simple

                     • Taille memoire controllée
                     • Derrière NGINX
                     • Full Python
                     • Graceful Reload

Sunday, April 25, 2010
http://www.peterbe.com/plog/fcgi-vs-gunicorn-vs-uwsgi


      gunicorn is the winner in my eyes. It's easy to configure
      and get up and running and certainly fast enough [..] .
Sunday, April 25, 2010
DEMO



Sunday, April 25, 2010
0.9

                     • Parseur HTTP en C (fallback en python sur
                         les plateformes non supportées)
                     • Increase unitests
                     • Reload hook
                     • status ?

Sunday, April 25, 2010
Liens

                     • http://gunicorn.org
                     • http://e-engura.org
                     • http://www.python.org/dev/peps/pep-0333/
                     • http://bitbucket.org/2degrees/twod.wsgi/
                     • http://github.com/alex/django-wsgi

Sunday, April 25, 2010
Questions




Sunday, April 25, 2010
@benoitc




Sunday, April 25, 2010
Cette création est mise à disposition selon le Contrat
                         Paternité 2.0 France disponible en ligne http://
                    creativecommons.org/licenses/by/2.0/fr/ ou par courrier
                     postal à Creative Commons, 171 Second Street, Suite
                           300, San Francisco, California 94105, USA.




Sunday, April 25, 2010

More Related Content

Viewers also liked

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
Graham Dumpleton
 
A look at FastCgi & Mod_PHP architecture
A look at FastCgi & Mod_PHP architectureA look at FastCgi & Mod_PHP architecture
A look at FastCgi & Mod_PHP architecture
Aimee Maree Forsstrom
 
Large platform architecture in (mostly) perl - an illustrated tour
Large platform architecture in (mostly) perl - an illustrated tourLarge platform architecture in (mostly) perl - an illustrated tour
Large platform architecture in (mostly) perl - an illustrated tour
Tomas Doran
 
A Brief Introduce to WSGI
A Brief Introduce to WSGIA Brief Introduce to WSGI
A Brief Introduce to WSGI
Mingli Yuan
 
Intro to PSGI and Plack
Intro to PSGI and PlackIntro to PSGI and Plack
Intro to PSGI and Plack
Tatsuhiko Miyagawa
 
Scaling Django with gevent
Scaling Django with geventScaling Django with gevent
Scaling Django with gevent
Mahendra M
 
Djangoのエントリポイントとアプリケーションの仕組み
Djangoのエントリポイントとアプリケーションの仕組みDjangoのエントリポイントとアプリケーションの仕組み
Djangoのエントリポイントとアプリケーションの仕組み
Shinya Okano
 
Common gateway interface
Common gateway interfaceCommon gateway interface
Common gateway interface
Anandita
 
Common Gateway Interface
Common Gateway InterfaceCommon Gateway Interface
Common Gateway Interface
Piero Fraternali
 
FCGI, C++로 Restful 서버 개발
FCGI, C++로 Restful 서버 개발FCGI, C++로 Restful 서버 개발
FCGI, C++로 Restful 서버 개발
현승 배
 
Articulo Malditas Tarjetas Eq3
Articulo Malditas Tarjetas Eq3Articulo Malditas Tarjetas Eq3
Articulo Malditas Tarjetas Eq3Beatriz Adriana
 
插图伊斯兰教简明指南 _ Chinese
插图伊斯兰教简明指南 _  Chinese插图伊斯兰教简明指南 _  Chinese
插图伊斯兰教简明指南 _ Chinese
Abdullah Baspren
 
Vrouwen Binnen De Islaam
Vrouwen Binnen De IslaamVrouwen Binnen De Islaam
Vrouwen Binnen De Islaam
Abdullah Baspren
 
Monthly seasonal outlook
Monthly seasonal outlookMonthly seasonal outlook
Monthly seasonal outlook
climate central
 
Budgeting and Savings
Budgeting and SavingsBudgeting and Savings
Budgeting and Savings
fpcksc
 
Writing winning proposals
Writing winning proposals Writing winning proposals
Writing winning proposals
Candace Benson
 
Let’S Go To The Beach
Let’S Go To The BeachLet’S Go To The Beach
Let’S Go To The Beach
guest4ef6c7e
 
Couchdbkit & Dango
Couchdbkit & DangoCouchdbkit & Dango
Couchdbkit & Dango
Benoit Chesneau
 
Merle Norman By Epic
Merle Norman By EpicMerle Norman By Epic
Merle Norman By Epic
JeffMoore
 
Presentació assignatura informà 1er eso
Presentació assignatura informà 1er esoPresentació assignatura informà 1er eso
Presentació assignatura informà 1er esovicenhdez
 

Viewers also liked (20)

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
 
A look at FastCgi & Mod_PHP architecture
A look at FastCgi & Mod_PHP architectureA look at FastCgi & Mod_PHP architecture
A look at FastCgi & Mod_PHP architecture
 
Large platform architecture in (mostly) perl - an illustrated tour
Large platform architecture in (mostly) perl - an illustrated tourLarge platform architecture in (mostly) perl - an illustrated tour
Large platform architecture in (mostly) perl - an illustrated tour
 
A Brief Introduce to WSGI
A Brief Introduce to WSGIA Brief Introduce to WSGI
A Brief Introduce to WSGI
 
Intro to PSGI and Plack
Intro to PSGI and PlackIntro to PSGI and Plack
Intro to PSGI and Plack
 
Scaling Django with gevent
Scaling Django with geventScaling Django with gevent
Scaling Django with gevent
 
Djangoのエントリポイントとアプリケーションの仕組み
Djangoのエントリポイントとアプリケーションの仕組みDjangoのエントリポイントとアプリケーションの仕組み
Djangoのエントリポイントとアプリケーションの仕組み
 
Common gateway interface
Common gateway interfaceCommon gateway interface
Common gateway interface
 
Common Gateway Interface
Common Gateway InterfaceCommon Gateway Interface
Common Gateway Interface
 
FCGI, C++로 Restful 서버 개발
FCGI, C++로 Restful 서버 개발FCGI, C++로 Restful 서버 개발
FCGI, C++로 Restful 서버 개발
 
Articulo Malditas Tarjetas Eq3
Articulo Malditas Tarjetas Eq3Articulo Malditas Tarjetas Eq3
Articulo Malditas Tarjetas Eq3
 
插图伊斯兰教简明指南 _ Chinese
插图伊斯兰教简明指南 _  Chinese插图伊斯兰教简明指南 _  Chinese
插图伊斯兰教简明指南 _ Chinese
 
Vrouwen Binnen De Islaam
Vrouwen Binnen De IslaamVrouwen Binnen De Islaam
Vrouwen Binnen De Islaam
 
Monthly seasonal outlook
Monthly seasonal outlookMonthly seasonal outlook
Monthly seasonal outlook
 
Budgeting and Savings
Budgeting and SavingsBudgeting and Savings
Budgeting and Savings
 
Writing winning proposals
Writing winning proposals Writing winning proposals
Writing winning proposals
 
Let’S Go To The Beach
Let’S Go To The BeachLet’S Go To The Beach
Let’S Go To The Beach
 
Couchdbkit & Dango
Couchdbkit & DangoCouchdbkit & Dango
Couchdbkit & Dango
 
Merle Norman By Epic
Merle Norman By EpicMerle Norman By Epic
Merle Norman By Epic
 
Presentació assignatura informà 1er eso
Presentació assignatura informà 1er esoPresentació assignatura informà 1er eso
Presentació assignatura informà 1er eso
 

Similar to WSGI, Django, Gunicorn

Oscon 2010
Oscon 2010Oscon 2010
Oscon 2010
John Woodell
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010
John Woodell
 
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
Google Developer Relations Team
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby Conference
John Woodell
 
Slideshare presentation
Slideshare presentationSlideshare presentation
Slideshare presentation
PaniPuri Soft Limited
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
jeresig
 
Advanced Data Widgets and Server Integration
Advanced Data Widgets and Server IntegrationAdvanced Data Widgets and Server Integration
Advanced Data Widgets and Server Integration
Sencha
 
Best Practices in Widget Development - Examples and Counterexamples
Best Practices in Widget Development  - Examples and CounterexamplesBest Practices in Widget Development  - Examples and Counterexamples
Best Practices in Widget Development - Examples and Counterexamples
ROLE Project
 
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
WO Community
 
Feature Bits at LSSC10
Feature  Bits at LSSC10Feature  Bits at LSSC10
Feature Bits at LSSC10
Erik Sowa
 
Building Dojo in the Cloud
Building Dojo in the CloudBuilding Dojo in the Cloud
Building Dojo in the Cloud
James Thomas
 
Html5 Apps
Html5 AppsHtml5 Apps
Html5 Apps
Nikolai Onken
 
So what's a web app? introduction to the chrome web store
So what's a web app? introduction to the chrome web storeSo what's a web app? introduction to the chrome web store
So what's a web app? introduction to the chrome web store
Eric Bidelman
 
Learn How to Unit Test Your Android Application (with Robolectric)
Learn How to Unit Test Your Android Application (with Robolectric)Learn How to Unit Test Your Android Application (with Robolectric)
Learn How to Unit Test Your Android Application (with Robolectric)
Marakana Inc.
 
Javascript essential-pattern
Javascript essential-patternJavascript essential-pattern
Javascript essential-pattern
偉格 高
 
Testing iOS Apps
Testing iOS AppsTesting iOS Apps
Testing iOS Apps
C4Media
 
Protractor survival guide
Protractor survival guideProtractor survival guide
Protractor survival guide
László Andrási
 
jQuery: The World's Most Popular JavaScript Library Comes to XPages
jQuery: The World's Most Popular JavaScript Library Comes to XPagesjQuery: The World's Most Popular JavaScript Library Comes to XPages
jQuery: The World's Most Popular JavaScript Library Comes to XPages
Teamstudio
 
App Engine Meetup
App Engine MeetupApp Engine Meetup
App Engine Meetup
John Woodell
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
NexThoughts Technologies
 

Similar to WSGI, Django, Gunicorn (20)

Oscon 2010
Oscon 2010Oscon 2010
Oscon 2010
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010
 
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby Conference
 
Slideshare presentation
Slideshare presentationSlideshare presentation
Slideshare presentation
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
 
Advanced Data Widgets and Server Integration
Advanced Data Widgets and Server IntegrationAdvanced Data Widgets and Server Integration
Advanced Data Widgets and Server Integration
 
Best Practices in Widget Development - Examples and Counterexamples
Best Practices in Widget Development  - Examples and CounterexamplesBest Practices in Widget Development  - Examples and Counterexamples
Best Practices in Widget Development - Examples and Counterexamples
 
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
 
Feature Bits at LSSC10
Feature  Bits at LSSC10Feature  Bits at LSSC10
Feature Bits at LSSC10
 
Building Dojo in the Cloud
Building Dojo in the CloudBuilding Dojo in the Cloud
Building Dojo in the Cloud
 
Html5 Apps
Html5 AppsHtml5 Apps
Html5 Apps
 
So what's a web app? introduction to the chrome web store
So what's a web app? introduction to the chrome web storeSo what's a web app? introduction to the chrome web store
So what's a web app? introduction to the chrome web store
 
Learn How to Unit Test Your Android Application (with Robolectric)
Learn How to Unit Test Your Android Application (with Robolectric)Learn How to Unit Test Your Android Application (with Robolectric)
Learn How to Unit Test Your Android Application (with Robolectric)
 
Javascript essential-pattern
Javascript essential-patternJavascript essential-pattern
Javascript essential-pattern
 
Testing iOS Apps
Testing iOS AppsTesting iOS Apps
Testing iOS Apps
 
Protractor survival guide
Protractor survival guideProtractor survival guide
Protractor survival guide
 
jQuery: The World's Most Popular JavaScript Library Comes to XPages
jQuery: The World's Most Popular JavaScript Library Comes to XPagesjQuery: The World's Most Popular JavaScript Library Comes to XPages
jQuery: The World's Most Popular JavaScript Library Comes to XPages
 
App Engine Meetup
App Engine MeetupApp Engine Meetup
App Engine Meetup
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 

Recently uploaded

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 

Recently uploaded (20)

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 

WSGI, Django, Gunicorn

  • 1. WSGI, Django & Gunicorn Benoît Chesneau 25/04/2010 - djangocong Sunday, April 25, 2010
  • 2. benoît chesneau benoitc@apache.org Artisan web Minimal web & Opensource Enki Multimedia http://www.e-engura.com Sunday, April 25, 2010
  • 3. • WSGI ? • Django & WSGI • Gunicorn Sunday, April 25, 2010
  • 4. WSGI ? • Web Server Gateway Interface • PEP 333 • Interface entre le web et une application Python Sunday, April 25, 2010
  • 5. Serveur web WSGI Application Python Sunday, April 25, 2010
  • 6. simple application def app(environ, start_response): """Simplest possible application object""" data = 'Hello, World!n' status = '200 OK' response_headers = [ ('Content-type','text/plain'), ('Content-Length', str(len(data))) ] start_response(status, response_headers) return iter([data]) Sunday, April 25, 2010
  • 7. WSGI ? • Réutilisation d’applications • Middleware • Paster • Frameworks: webob, werkzeug, bottle, repoze, ... Sunday, April 25, 2010
  • 8. Middleware WSGI class CustomHeader(object): def __init__(self, app): self.app = app def __call__(self, environ, start_response): environ["HTTP_X_MY_HEADER"] = "1" return self.app(environ, start_response) Sunday, April 25, 2010
  • 9. Serveur web WSGI Application Python App App App Sunday, April 25, 2010
  • 10. Django & WSGI Sunday, April 25, 2010
  • 11. Intégrer • Pourquoi réinventer la roue ? • Principes communs: middlewares, request, ... • Réutiliser les applications. • intégrer != compatible wsgi Sunday, April 25, 2010
  • 12. • django-wsgi • twod.wsgi Sunday, April 25, 2010
  • 13. django-wsgi • pas de dependance • permet d’embarquer des apps wsgi, `django_view` • permet de creer une app wsgi à partir d’une vue ou des urls, `wsgi_application` Sunday, April 25, 2010
  • 14. django_view def test_app(environ, start_response): start_response("200 OK", [("Content-type", "text/ html")]) yield "i suck" def test_app1(request): return HttpResponse("wowa, meta") urls = patterns("", .. (r"^test/$", django_view(test_app)), (r"^(?P<name>.*?)/$", test_app1), .. ) application = wsgi_application(urls) Sunday, April 25, 2010
  • 15. twod.wsgi • vise à créer une "paserelle coopérative" entre Django et WSGI • basé sur webob (wrap HttpRequest et HttpResponse) • Paste deploy factory • Middleware pour le routage Sunday, April 25, 2010
  • 16. twod.wsgi - embed import os from twod.wsgi import DjangoApplication os.environ['DJANGO_SETTINGS_MODULE'] = "yourpackage.settings" django_app = DjangoApplication() Sunday, April 25, 2010
  • 17. twod.wsgi routing args (r'^/blog/posts/(?<post_slug>w+)/comments/(? <post_comment_id>d+)$' >>> request.urlvars {'post_slug': "hello-world", 'post_comment_id': "3"} Sunday, April 25, 2010
  • 18. twod.wsgi - embed • intégrer une application WSGI au sein de votre projet django • modifier les requêtes/réponses • Integrer votre app django dans une app WSGI Sunday, April 25, 2010
  • 19. embarque les apps WSGI from twod.wsgi import call_wsgi_app from somewhere import wsgi_app def run_app(request, path_info): response = call_wsgi_app(wsgi_app, request, path_info) response['Server'] = "twod.wsgi 1.0" return response Sunday, April 25, 2010
  • 20. Déployer • l’utilisation courante de Django avec WSGI • 2 types de deploiements : • via serveur • via proxy Sunday, April 25, 2010
  • 21. Serveur • uWSGI • mod_proxy Sunday, April 25, 2010
  • 22. proxy • spawning, paster, ... • cherrypy, .. • gunicorn Sunday, April 25, 2010
  • 25. gunicorn • Green unicorn • WSGI 1.0, clients lents et rapides • supporte WSGI, Paster compatible app & ... Django • Load balancing via pre-fork and un socket partagé • Upgrade à chaud “à la nginx” Sunday, April 25, 2010
  • 26. mais encore... • HTTP Stream. Décode le HTTP à la volée • Gestion des connexions asynchrones (longpolling, comet, websockets, appels d’api, ...). • Eventlet, Gevent, Tornado • DSL Config Sunday, April 25, 2010
  • 27. Philosophie • Simple • Minimal • Performant • Unix Sunday, April 25, 2010
  • 28. Simple • gunicorn_django -w 3 /myproject/ settings.py • ./manage.py run_django -w 3 • gunicorn_django -w 3 -k “egg:gunicorn#eventlet” /myproject/ settings.py Sunday, April 25, 2010
  • 29. Simple • Taille memoire controllée • Derrière NGINX • Full Python • Graceful Reload Sunday, April 25, 2010
  • 30. http://www.peterbe.com/plog/fcgi-vs-gunicorn-vs-uwsgi gunicorn is the winner in my eyes. It's easy to configure and get up and running and certainly fast enough [..] . Sunday, April 25, 2010
  • 32. 0.9 • Parseur HTTP en C (fallback en python sur les plateformes non supportées) • Increase unitests • Reload hook • status ? Sunday, April 25, 2010
  • 33. Liens • http://gunicorn.org • http://e-engura.org • http://www.python.org/dev/peps/pep-0333/ • http://bitbucket.org/2degrees/twod.wsgi/ • http://github.com/alex/django-wsgi Sunday, April 25, 2010
  • 36. Cette création est mise à disposition selon le Contrat Paternité 2.0 France disponible en ligne http:// creativecommons.org/licenses/by/2.0/fr/ ou par courrier postal à Creative Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA. Sunday, April 25, 2010