Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gunicorn high memory usage by multiple identical processes?

I am puzzled by the high percentage of memory usage by Gunicorn. The application I am running is a deep learning framework for automatic image recognition.

The memory usage is constantly hovering around 67%, even after I increased the memory size from 1GB to 3GB. What is even puzzling is that the memory seems to be used by multiple identical Gunicorn Processes, as shown below. I have manually killed some high-ram-usage processes such as PID 2004 and 1860, but they constantly came back and the 67% of memory usage remained and sometimes got even higher. As a result, image reading tool such as cv2.imread constantly fails to deal with a large-sized image because of out of memory.

$ ps aux --sort=-%mem

USER  PID  %CPU %MEM VSZ     RSS    TTY    STAT START   TIME COMMAND
user  2004  5.6 39.0 2304052 1201968 ?     S    17:33   0:08 /home/user/anaconda3/envs/project/bin/python /home/user/anaconda3/envs/project/bin/gunicorn --workers 2 --bind unix:/home/user/project-master/project.sock -m 007 wsgi:app
user  1860  2.5 38.6 2289024 1189396 ?     S    17:14   0:32 /home/user/anaconda3/envs/project/bin/python /home/user/anaconda3/envs/project/bin/gunicorn --workers 2 --bind unix:/home/user/project-master/project.sock -m 007 wsgi:app
user  1694  0.0  0.5  43620 17416 ?        Ss   17:14   0:00 /home/user/anaconda3/envs/project/bin/python /home/user/anaconda3/envs/project/bin/gunicorn --workers 2 --bind unix:/home/user/project-master/project.sock -m 007 wsgi:app

I wonder whether it is normal to have such high ram usage for Gunicorn-served web application? If not, is there any way I can fix it? Thanks!

like image 319
renjie ge Avatar asked Oct 27 '22 23:10

renjie ge


1 Answers

I had the same problem with some images once.

Try deleting the variables like that:

del img, otherVar
like image 153
Gamliel Cohen Avatar answered Nov 15 '22 10:11

Gamliel Cohen