[uWSGI] custom routing/workers dispatching

Theodor-Iulian Ciobanu theo19k at gmail.com
Mon Mar 21 21:56:39 CET 2016


Hello,

I'm a uWSGI newbie trying to get a Flask app with a small peculiarity
running: I want certain requests to be handled by certain workers only,
e.g. locations starting with /1 will be sent to worker #1, those
starting with /2 to the 2nd worker etc, and if none of the patterns
match, then just fallback to a normal balancing scheme.

Searching the docs, I found multiple ways of implementing a reverse
proxy that would forward requests to different backends that, if I
understood correctly, would actually be considered separate
applications, listening on different sockets, and as such requiring
multiple instances of uWSGI (or just one running in Emperor mode, I
guess). But this sounds like a configuration nightmare, since
adding/removing workers would actually mean adding/remove single worker
applications.

The subscription model would help with this, but it seems to cover
only domains, not locations on the virtual host. The closest I could
find was a page (that I'd link to link but can't find again) that
mentioned routing based on the request uri, but taking into account
directories only, i.e. I could specify a policy for /foobar and /foobaz
to be treated differently, while what I'm actually looking for is for a
way to e.g.:
- send /foo.* to worker #1
- send /ba[rz].* to worker #2
- send /qux.* to worker #3
- send everything else to anyone of the workers

(I'm aware this could theoretically cause an uneven load on the workers,
but in my particular case it actually shouldn't)

So, is there any way to implement this in uWSGI or do I need to go the
reverse proxy way? If the latter, what would be the best approach to it?


Thank you in advance and kind regards,

-- 
Theo


More information about the uWSGI mailing list