High memory consumption when proxying to a Comet server

Rogério Schneider stockrt at gmail.com
Mon Apr 12 04:16:33 MSD 2010


Folks,

When proxying to a Comet server, I was able to notice that Nginx is
eating and not releasing a massive amount of memory.

As we all know, Comet servers can have this "streaming" mode, where we
receive a chunked HTTP request that never ends.

Is there some problem that avoids Nginx to release memory when in
proxy mode, before the connection ends at all?

I am using Nginx to balance between some instances of the Comet server:
    upstream comet {
        server comet:8081;
        server comet:8082;
        ...
    }

Memory consumption for Nginx procs for each minute during the tests:
271.3 MiB + 368.0 KiB = 271.6 MiB	nginx (9)
273.3 MiB + 368.0 KiB = 273.6 MiB	nginx (9)
274.8 MiB + 368.0 KiB = 275.2 MiB	nginx (9)
276.6 MiB + 368.0 KiB = 277.0 MiB	nginx (9)
278.8 MiB + 368.0 KiB = 279.2 MiB	nginx (9)
281.0 MiB + 368.0 KiB = 281.4 MiB	nginx (9)
283.2 MiB + 368.0 KiB = 283.6 MiB	nginx (9)
285.4 MiB + 368.0 KiB = 285.8 MiB	nginx (9)
287.2 MiB + 368.0 KiB = 287.6 MiB	nginx (9)
288.9 MiB + 368.0 KiB = 289.3 MiB	nginx (9)

I could also notice that the bigger is the message I send through the
Comet server (thus, through Nginx too) the bigger is the memory
allocation in the Nginx procs.
Also, if this helps, Nginx only writes down the access_log when the
client closes the connection.

What could I do to avoid this "leak" behaviour for long lasting proxy
connections in Nginx?

Regards,
-- 
Rogério Schneider

http://stockrt.github.com



More information about the nginx mailing list