Tech C**P
12 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
UWSGI - Web server Gateway Interface
-----
uwsgi is a big C application which is used to deploy python applications on server. There is a full documentation of UWSGI in readthedocs, follow it and master it to handle loads of requests concurrently and use graceful reloading of the app. It is usually put behind a full web server like nginX by proxying.

Reference: https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html

#python #uwsgi #reference #flask #readthedocs
If you run python using uwsgi you may get an error like below:

open("./python_plugin.so"): No such file or directory [core/utils.c line 3321]
!!! UNABLE to load uWSGI plugin: ./python_plugin.so: cannot open shared object file: No such file or directory !!!

This error says that the plugin is not loaded. This error happens when you install uwsgi using pip. Distros should package uWSGI in a modular way, with each feature as a plugin. But when you install using language specific ways (pip, gem...) the relevant language is embedded, so you do not need to load the plugin.

#python #uwsgi #pip
If for any reason you had to increase uwsgi_pass timeout in nginX you can use uwsgi_read_timeout:

upstream uwsgicluster {
server 127.0.0.1:5000;
}

.
.
.


include uwsgi_params;
uwsgi_pass uwsgicluster;
uwsgi_read_timeout 3000;


You can also increase timeout in uwsgi. If you are using ini file you need to use harakiri parameter like below:

harakiri = 30

Its value is in seconds.

#uwsgi #nginx #uwsgi_pass #harakiri #timeout #uwsgi_read_timeout
DO NOT USE UWSGI multi-threaded mode with alpine image!

I've been stuck on this issue for a couple of days as our service returned 503 Gateway timeout while our server load was totally ok around 1.0 (1m load average). So our load test got failed at the be beginning of the test! We found out it is related to docker base image of python alpine. Use python slim image instead. Or in case you have many changes you can stick with alpine and change thread to 1 in uswgi configuration file.


#docker #alpine #uwsgi #python #slim #respawn