[Python] Tracking Down Python / uWSGI Memory Usage

Discussão em 'Python' iniciado por Stack, Setembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    When I run top I see (uWSGI using ~860MB of RES; this is in Docker):

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    11 root 20 0 1048736 360688 19064 S 0.3 17.6 1:17.00 uwsgi
    12 root 20 0 1018840 328140 18964 S 0.3 16.0 1:42.41 uwsgi


    RES stands for the resident size, which is an accurate representation of how much actual physical memory a process is consuming.
    ​

    I would like to understand what is using that much RAM. I tried to use the standard Python heap analysis tools however they don't reveal anything that large. For example using pympler, I see:

    types | # objects | total size
    ============================ | =========== | ============
    dict | 7933 | 9.15 MB
    str | 50742 | 8.40 MB
    code | 18044 | 2.20 MB
    type | 2347 | 2.03 MB
    unicode | 3188 | 1.56 MB
    tuple | 8012 | 588.46 KB
    list | 4425 | 550.81 KB
    weakref | 3707 | 318.57 KB
    set | 828 | 308.59 KB
    builtin_function_or_method | 3432 | 241.31 KB
    cell | 3267 | 178.66 KB
    function (__init__) | 1417 | 166.05 KB
    getset_descriptor | 2337 | 164.32 KB
    wrapper_descriptor | 1968 | 153.75 KB
    _sre.SRE_Pattern | 290 | 123.77 KB


    Could there be some sort of off heap memory usage? Perhaps uwsgi itself is using that much RAM?

    UDPATED

    My current uwsgi.ini file:

    [uwsgi]
    strict = true

    http = :8000
    module = my_service.wsgi
    master = true
    processes = 2
    threads = 2

    buffer-size = 10000

    Continue reading...

Compartilhe esta Página