Your SlideShare is downloading. ×
0
gunicorn introduction
gunicorn introduction
gunicorn introduction
gunicorn introduction
gunicorn introduction
gunicorn introduction
gunicorn introduction
gunicorn introduction
gunicorn introduction
gunicorn introduction
gunicorn introduction
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

gunicorn introduction

5,988

Published on

A lightning-talk length introduction to the gunicorn web server for Python applications.

A lightning-talk length introduction to the gunicorn web server for Python applications.

Published in: Technology
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,988
On Slideshare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
45
Comments
0
Likes
9
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • A bit of a stretch -- an app, not a module/package
    But works with nearly any python web application, and is easy_installable/pip installable gunicorn is a simple Python web server.


  • 4 workers, all listening on shared socket
    python path colon callable name (defaults to ‘application’)
    Pronounced gee-unicorn, günicorn, but I always call it gunicorn
  • I’m not the only one
  • Want something stable and simple, easy to reason about





  • Setting the process name is useful for multi-process environments
    Hard to do cross-platform
    This uses code from PostgreSQL, which is always awesome
  • Transcript

    • 1. Adam Lowry PDX Python, 2010-07-13
    • 2. So you have a WSGI app def app(environ, start_response): data = "Hello, World!n" start_response("200 OK", [ ("Content-Type", "text/plain"), ("Content-Length", str(len(data))) ]) return iter([data])
    • 3. Now you have a server $ gunicorn -w 4 myapp:app 2010-06-05 23:27:07 [16800] [INFO] Arbiter booted 2010-06-05 23:27:07 [16800] [INFO] Listening at: http://127.0.0.1:8000 2010-06-05 23:27:07 [16801] [INFO] Worker spawned (pid: 16801) 2010-06-05 23:27:07 [16802] [INFO] Worker spawned (pid: 16802) 2010-06-05 23:27:07 [16803] [INFO] Worker spawned (pid: 16803) 2010-06-05 23:27:07 [16804] [INFO] Worker spawned (pid: 16804)
    • 4. 15:50 |termie| when the gunicorn fights, it wins 02:43 |termie| when the gunicorn urinates the result is a perfect mixture of champagne and green charteuse 16:41 |termie| the gunicorn shoots _you_ 09:51 |termie| the gunicorn cannot be managed http://thegunicorn.com/
    • 5. Details • a port of Ruby’s Unicorn • prefork • WSGI, Django, Paster • Light on resources, extensible
    • 6. Configuration • Paster INI • Python config file • Command line
    • 7. Fast Clients Only http://commons.wikimedia.org/wiki/File:Slow_Loris_Female.jpg
    • 8. nginx upstream app_server { server unix:/tmp/gunicorn.sock fail_timeout=0; } server { listen 80 default; server_name adam.therobots.org; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://app_server; break; } } }
    • 9. What about slow resources? gunicorn -k egg:gunicorn#eventlet myapp:app gunicorn -k egg:gunicorn#gevent myapp:app
    • 10. More about gunicorn More about me http://gunicorn.org/ http://adam.therobots.org/ http://pypi.python.org/pypi/ http://twitter.com/robotadam gunicorn adam@therobots.org http://github.com/benoitc/ gunicorn/
    • 11. Bonus Module! http://pypi.python.org/pypi/setproctitle www-data 9256 0.2 2.6 16696 13416 ? S Jun27 57:16 gunicorn: master [zine-prefork] www-data 9257 0.2 5.7 36204 29272 ? S Jun27 69:25 gunicorn: worker [zine-prefork] www-data 9258 0.3 5.7 36304 29388 ? S Jun27 75:52 gunicorn: worker [zine-prefork] www-data 9259 0.3 5.9 37232 30220 ? S Jun27 75:02 gunicorn: worker [zine-prefork] www-data 9260 0.3 5.7 36644 29560 ? S Jun27 75:29 gunicorn: worker [zine-prefork]

    ×