uWSGI 1.9.19

Changelog [20131109]

This release starts the ‘hardening’ cycle for uWSGI 2.0 (scheduled for the end of december 2013).

The metrics subsystem was the last piece missing and this version (after 1 year of analysis) finally includes it.

During the following 2 months we will start deprecating features or plugins that got no-interest, are known to be broken or are simply superseedby more modern/advanced ones.

Currently the following plugin and features are scheduled for removal:

  • The Go plugin, superseeded by the gccgo one. (eventually the Go plugin will be brought back if something changes in the fork() support)
  • Auto-snapshotting, was never documented, it has tons of corner case bugs and it is huber-complex. The features added by the MasterFifo allows for better implementations of snapshotting.

Waiting for decision:

  • the erlang plugin is extremely old, was badly engineered and should be completely rewritten. If you are a user of it, please contact the staff. Very probably we will not be able to maintain it without sponsorship.
  • the matheval support could be removed soon (unless we find some specific use that could require it), substituted by some form of simple math directly implemented in the option parser
  • the admin plugin should be substituted with something more advanced. An api for defining dynamic options is on-work

Bugfixes

  • completely skip cgroups initialization when non-root
  • tons of post-static_analysis fixes by Riccardo Magliocchetti
  • fixed the greenlet plugin reference counting
  • avoid kevent storm for stats pusher thread
  • fixed rbtimers math
  • both ‘cache’ and ‘file’ routers got a ‘no_content_length’ key option to avoid settign the Content-Length header
  • the PyPy plugin automatically enables threads/GIL
  • manage dot_segments in HTTP parser
  • improved srand() usage

New features

The Metrics subsystem

This was the last piece missing before uWSGI 2.0. The Metrics subsystem allows you to store “numbers” related to monitoring, graphing and quality checks and exports them in various ways.

Official docs: The Metrics subsystem

The Tornado loop engine

While working on nodejs integration we realized that contrary to what we used to believe, Tornado (an asynchronous, callback based module for python) is usable in uWSGI.

Note: The plugin is not built-in by default

Official docs: The Tornado loop engine

The ‘puwsgi’ protocol

A “persistent” (keep-alive) version of the ‘uwsgi’ parser has been added named ‘puwsgi’ (persistent uwsgi).

This protocol works only for request without a body and requires support from the frontend. Its use is currently for custom clients/apps, there is no webserver handler supporting it.

The —puwsgi-socket <addr> will bind a puwsgi socket to the specified address

–vassal-set

You can tell the Emperor to pass specific options to every vassal using the –set facility:

  1. [uwsgi]
  2. emperor = /etc/uwsgi/vassals
  3. vassal-set = processes=8
  4. vassal-set = enable-metrics=1

this will add —set processes=8 and —set enable-metrics=1 to each vassal

The ‘template’ transformation

This is a transformation allowing you to apply all of the internal routing patterns to your responses.

Take the following file (foo.html)

  1. <html>
  2. <head>
  3. <title>Running on ${SERVER_NAME}</title>
  4. </head>
  5. <body>
  6. Your ip address is: ${REMOTE_ADDR}<br/>
  7. Served requests: ${metric[worker.0.requests]}<br/>
  8. Pid: ${uwsgi[pid]}<br/>
  9. A random UUID: ${uwsgi[uuid]}
  10. </body>
  11. </html>

we will apply the ‘template’ transformation to it:

  1. [uwsgi]
  2. http-socket = :9090
  3. ; enable the metrics subsystem
  4. enable-metrics = true
  5. ; inject the route transformation
  6. route-run = template:
  7. ; return a file (transformation will be applied to it)
  8. route-run = file:filename=foo.html,no_content_length=1

everything available in the internal routing subsystem can be used into the template transformation.

Performance are stellar, so instead of old Server Side Includes, you may want to try it.

Not enough ? combine it with caching:

  1. [uwsgi]
  2. http-socket = :9090
  3. ; enable the metrics subsystem
  4. enable-metrics = true
  5. ; load foo.html in the cache
  6. cache2 = name=mycache,items=10
  7. load-file-in-cache = foo.html
  8. ; inject the route transformation
  9. route-run = template:
  10. ; return the cache item (transformation will be applied to it)
  11. route-run = cache:key=foo.html,no_content_length=1

Again ?

what about chunked encoding ?

  1. [uwsgi]
  2. http-socket = :9090
  3. ; enable the metrics subsystem
  4. enable-metrics = true
  5. ; load foo.html in the cache
  6. cache2 = name=mycache,items=10
  7. load-file-in-cache = foo.html
  8. ; inject the route transformation
  9. route-run = template:
  10. ; inject chunked encoding
  11. route-run = chunked:
  12. ; return the cache item (transformation will be applied to it)
  13. route-run = cache:key=foo.html,no_content_length=1

or gzip ?

  1. [uwsgi]
  2. http-socket = :9090
  3. ; enable the metrics subsystem
  4. enable-metrics = true
  5. ; load foo.html in the cache
  6. cache2 = name=mycache,items=10
  7. load-file-in-cache = foo.html
  8. ; inject the route transformation
  9. route-run = template:
  10. ; inject gzip
  11. route-run = gzip:
  12. ; return the cache item (transformation will be applied to it)
  13. route-run = cache:key=foo.html,no_content_length=1

Availability

uWSGI 1.9.19 has been released on 20131109, you can download it from:

https://projects.unbit.it/downloads/uwsgi-1.9.19.tar.gz