How to limit the usage of memory?


I want to limit the usage of memory like 4G.

How to limit the usage of memory in kong.conf?

The main values which control memory usage are mem_cache_size and nginx_worker_processes, but other relevant configurations, depending on the requests coming into your Kong instance, are nginx_http_client_header_buffer_size and nginx_http_client_body_buffer_size, amongst a few other configurations. I would suggest reading up on those configurations, and tuning them for the size of Kong instance and box you’re running.

1 Like


Thank you for your answer!!
I understood that the main values of controlling the usage of memory are “mem_cache_size” and “nginx_worker_processes”.

I have one more question.
I usually use “docker stats” command to check the usage of memory.

When I Implemented a load test by changing only the value of “nginx_worker_processes”, I found that the usage of memory has changed. However, when I changed only the value of “mem_cache_size”, the usage of memory has not changed.
Is it correct that the rate of the usage of memory for cache will be changed by changing the value of “mem_cache_size”?

I am a beginner of Kong and I don’t have enough tech knowledge. So if I ask strange question, I am so sorry.


I’m not 100% on the internals of openresty, but I wonder if like other memory on Linux you need to actually use the memory in a test to have the configuration make a difference.