Skip to content

Instantly share code, notes, and snippets.

@gszr
Last active April 8, 2024 18:33
Show Gist options
  • Save gszr/37d0f72de9af209037c0ff3e2c95cd45 to your computer and use it in GitHub Desktop.
Save gszr/37d0f72de9af209037c0ff3e2c95cd45 to your computer and use it in GitHub Desktop.
Kong Memory Usage

Some notes on Kong memory usage

As I was tweaking the Kong config I use in my VPS, I took the opportunity to take some screenshots of the Kong container memory usage pattern. What follows is a brief summary of my findings.

The deployment is pretty small:

$ http :8001/services | jq '.data | length'
11

$ http :8001/routes | jq '.data | length'
11

$ http :8001/plugins | jq '.data | length'
3
# all basic auth

Overview

Screenshot_20240407_123605.png

The baseline behavior is as seen on the 12:06-12:26 time window.

At around 12:32, I restarted Kong, changing the mem_cache_size from 128mb (default) to 32mb. Soon thereafter, the comsumption grew, slowly, as seen below:

Screenshot_20240407_130030.png

Zooming in a bit:

Screenshot_20240407_123822.png

Screenshot_20240407_133909.png

Zooming out, to include the past day:

Screenshot_20240407_134000.png

The memory usage grows, and plateaus at ~ 670mb.

An hour later (after lunch : ), I pushed a config change, removing a few unused plugins:

  • acme

  • rate-limiting

  • ip-restriction

A few captures of the moments following the restart (around 13:52):

Screenshot_20240407_140632.png

Screenshot_20240407_140643.png

Zooming in:

Screenshot_20240407_140738.png

Now, zooming out to see more clearly the initial effect of both config changes:

Screenshot_20240407_143826.png

As before, usage kept growing, plateauing in the same vicinity (~ 670mb):

Screenshot_20240408_150424.png

Conclusion

The goal here is only to share what I found interesting while poking around; no significant conclusions were drawn; however, it would IMO be valuable to further study this behavior and understand the reason for the numbers here -- in particular the memory usage plateau. (As Zhgonwei mentioned in his memory usage demo and today in standup, the memory used by the shms is displayed in each of the workers, even though it's shared, so the numbers don't match actual memory usage.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment