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.
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.Cchannel from this goroutine, by changing how thect.bc.CheckInworks.At the moment the
case <-tick.Chappens everyct.cfg.Timeouts.CheckinTimestamp. Its the same for every connection, meaning every connection gets that timer adding overhead and memory. The call tobt.bc.CheckInalso sends an event over a channel and again this happens on every connection based onct.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
agentIDas connected to the checkin handler and then based on thect.cfg.Timeouts.CheckinTimestampall connectedagentIDcan be updated in a single request to elasticsearch. When the client disconnects it unregisters theagentIDand 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.