Does Kubernetes Watch API costs much memory if there are many events returned by Watch

7/22/2021

We are using Event.Watch and Event.List together as List and Watch functions for cache.Reflector. We are seeing significant memory and CPU increases when there are lots of events (450k - 900k) and we are trying to determine the causes.

For List, we store the results of List in memory, which definitely increases memory usage. However, I am not sure about Watch. I can see Watch takes lots of CPU if it gets busy and there are lots of update/add/delete on the Event objects to report and process.

Does Watch also take lots of memory too? If so, where in the process it takes memory? FWIK, Watch sends REST requests to API server to watch specific objects. The stream of events will then be sent to the result channel of a Watcher where receivers (e.g., Reflector) can get.

-- ZigZagZebra
kubernetes
rest
watch

0 Answers