elastic / elastic/fleet-server
Improve checkin bulker performance
- Dominant language
- Go
- Stars
- 113
- Forks
- 117
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 112
Description
**Describe the enhancement:**
At the moment each long poll connection gets a goroutine. Inside of that goroutine there is a select that performs actions depending on the channel that is triggered. I believe we could remove the `case <-tick.C` channel from this goroutine, by changing how the `ct.bc.CheckIn` works.
At the moment the `case <-tick.C` happens every `ct.cfg.Timeouts.CheckinTimestamp`. Its the same for every connection, meaning every connection gets that timer adding overhead and memory. The call to `bt.bc.CheckIn` also sends an event over a channel and again this happens on every connection based on `ct.cfg.Timeouts.CheckinTimestamp`.
I believe all of this can be simplified and reduce the load of the Fleet Server. Instead of using the ticker and the checkin call. The code can just register the `agentID` as connected to the checkin handler and then based on the `ct.cfg.Timeouts.CheckinTimestamp` all connected `agentID` can be updated in a single request to elasticsearch. When the client disconnects it unregisters the `agentID` and stops updating it in that single request.
This should reduce the number of times by X connections, and the number of messages going over the channels by X connections.
**Describe a specific use case for the enhancement or feature:**
I believe this could reduce the memory and CPU usage of the Fleet Server, especially when it is handling a large number of connections.
Contributor guide
Assessment
This issue has not been assessed yet.