Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/#kong-community
Apache License 2.0
38.78k stars 4.77k forks source link

Is this normal? How to reduce memory usage. . #13366

Closed fairyqb closed 1 week ago

fairyqb commented 1 month ago

Is there an existing issue for this?

Kong version ($ kong version)

kong all

Current Behavior

my server has 20 cores and 32GB of memory. The nginx process corresponding to KONG is 1.5G RES for each nginx process and 300MB of shared memory. (20 * 1.2 GB) + 300MB = 24.3GB

Memory usage is 24.3/32= 75%, and the memory is very high, almost reaching 80%.

The CPU is usually very low, with a usage rate of 10%.

Expected Behavior

Is this normal? How to reduce memory usage. .

Steps To Reproduce

No response

Anything else?

No response

fairyqb commented 1 month ago

Information supplement:

The data cached by my luajit vm is all that is needed.

fairyqb commented 1 month ago

@chronolaw What is the feedback? I don't understand, thank you

chronolaw commented 1 month ago

I am not an expert of performance tuning, perhaps others could answer this question.

fairyqb commented 1 month ago

Now each nginx process reaches 2GB. Should I reduce the number of worker processes or increase the memory? Which solution is better?

hanshuebner commented 1 month ago

Now each nginx process reaches 2GB. Should I reduce the number of worker processes or increase the memory? Which solution is better?

In general, increasing the number of worker processes will not decrease your overall memory usage. Kong Gateway's memory usage generally depends on the size of the configuration more than on the amount of traffic that it handles, but this is not always the case. To give you further advice, details about your configuration (number of configuration entities, plugin configurations etc.) as well as the amount (rps) and nature (protocol, request sizes) of the traffic that you're handling are needed.

It can be said that worker process sizes of hundreds of megabytes are not untypical, but it is not normal to see the memory usage increase without changes in configuration or load patterns. You reported that "Now" the size of your workers has grown from "1.5" to "2" GB per worker process. What happened between "before" and "Now"? Did you make changes?

fairyqb commented 1 month ago

Now each nginx process reaches 2GB. Should I reduce the number of worker processes or increase the memory? Which solution is better?

In general, increasing the number of worker processes will not decrease your overall memory usage. Kong Gateway's memory usage generally depends on the size of the configuration more than on the amount of traffic that it handles, but this is not always the case. To give you further advice, details about your configuration (number of configuration entities, plugin configurations etc.) as well as the amount (rps) and nature (protocol, request sizes) of the traffic that you're handling are needed.

It can be said that worker process sizes of hundreds of megabytes are not untypical, but it is not normal to see the memory usage increase without changes in configuration or load patterns. You reported that "Now" the size of your workers has grown from "1.5" to "2" GB per worker process. What happened between "before" and "Now"? Did you make changes?

from "1.5" to "2" GB per worker process., kong.cache is all that is needed.

nowNick commented 1 month ago

Hi @fairyqb Could you give us more information about the Kong instance you are running. Could you provide the details that @hanshuebner asked in the previous message?

To give you further advice, details about your configuration (number of configuration entities, plugin configurations etc.) as well as the amount (rps) and nature (protocol, request sizes) of the traffic that you're handling are needed.

github-actions[bot] commented 2 weeks ago

This issue is marked as stale because it has been open for 14 days with no activity.

github-actions[bot] commented 1 week ago

Dear contributor,

We are automatically closing this issue because it has not seen any activity for three weeks. We're sorry that your issue could not be resolved. If any new information comes up that could help resolving it, please feel free to reopen it.

Your contribution is greatly appreciated!

Please have a look our pledge to the community for more information.

Sincerely, Your Kong Gateway team