I have an application which I don't want to modify.

It has multiple directories with static files which are defined as static via check-static directive in uwsgi's .ini-file. My problem is that each request to /api endpoint checks all directories for static content with lstat() system call and it take.. a little time, really, just 0.0005 seconds per call, but aren't zero seconds sounds better?

It would be nice if all the static content would be accessed with /static/ prefix in URL so I could replace check-static with static-map but I don't want to modify the application, any workaround is enough. If only uwsgi had option like:

check-static-exclude = /api

Maybe it is possible to achieve via uwsgi routing subsystem but I didn't find anything suitable in docs.

Update: todo re-check routes continue action.

  • Put a web server in front of it to serve all static files. – Michael Hampton Mar 12 at 20:54
  • At first I didn't think that communications between the servers (no matter via tcp or unix-sockets) would take less time than the static checks I'm trying to avoid, but then I've decided to re-check it. UNIX domain socket usually adds just 2 microseconds, so if the server for static can handle the request in less than 498 microseconds... it will do the trick! I will benchmark it on Monday and provide the details. – strizhechenko Mar 14 at 5:24
  • The checks have to happen somewhere. And this sounds like a premature micro-optimization. – Michael Hampton Mar 14 at 5:33
  • Yeah, it have to, of course, except the /api endpoint. It's certainly have no static content inside and serves about 95% or even 99% of total requests. Development team put the task for refactoring of static serving aside until the autumn, so I'm trying to make a quick & easy workaround to reduce I/O workload. – strizhechenko Mar 14 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.