You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
queue impacts computation resource usage of client and behavior of client. Now, we can tune queue usingRingScaleEachConn option and RUEIDIS_QUEUE_TYPE env.
but tune of queue is not easy. because observability of queue is poor. So we provide stats of queue . So user can tune the queue more predictable way.
Goals
We can monitor how many commands is waiting in queue.
Non-Goals
Now, we don’t design how to integrate stats with rueidisotel
Add WaitingCmdCount method to queue . WaitingCmdCount tells how many commands are waiting in queue. The new method ruturn waits
ring and flowBuffer has a new atomic.Uint32 type field waits . when new commands(or command) are added to queue from PutOne or PutMulti, waits become waits+1. When FinishResultmethod is called waits become waits -1.
Atomic operation is cheap, but makes additional overhead always. So if a user doesn’t want collecting stats overhead, user turn off collecting stats. So ring and flowBuffer has a new bool type field collectStats . collectStats is from constructor. if collectStats is false, do not operate on the waits .
mux can have multiple muxwire . So we should provide stats on multiple queues. Now we provide 4 metrics. maxWaitingCommandCount and average command count from totalWaitingCommandCount and queueCount tells how to tune queue is better.
Adding a new interface ClientStatsProvider not to happen breaking change int Client interface. If user wants to get ClientStats, user should type check to the Client.
sentinelClient aggregates stats from mConn and rConn calling WaitingCommandInQueueStats.
clusterClient aggregates stats from conns calling WaitingCommandInQueueStats.
Overall operation is cheap, but overhead is inevitable. So as I mentioned above, If want to collecting stats, user configures explicitly. So we introduce a new client option.
typeClientOptionstruct {
...CollectingClientStatsOptionCollectingClientStatsOption
}
// CollectingClientStatsOption defines options for enabling the collecting client statistics.typeCollectingClientStatsOptionstruct {
// EnableCollectingQueueStats determines whether to enable the collection of queue-related statistics.EnableCollectingQueueStatsbool
}
Maybe later, More metrics can be added too. So we define a new struct about client stats option.
Alternatives Considered
I’ve consideredwrCounter using stats. pros of wrCounter use no additional computation resource and overhead. But wrCounter increase even though commands are not entered to queue. So wrCounter is not accurate for stats.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Adding a Queue stats to rueidis client. The stats tells a status of queue.
Problem Definition
Background
I’ve already propose ring stats before(#537). Situation changed and It has become worth considering again with different reason.
Primary reason: issue
queueimpacts computation resource usage of client and behavior of client. Now, we can tunequeueusingRingScaleEachConnoption andRUEIDIS_QUEUE_TYPEenv.but tune of
queueis not easy. because observability ofqueueis poor. So we provide stats ofqueue. So user can tune thequeuemore predictable way.Goals
We can monitor how many commands is waiting in queue.
Non-Goals
Now, we don’t design how to integrate stats with
rueidisotelDesign
Queue
Add
WaitingCmdCountmethod toqueue.WaitingCmdCounttells how many commands are waiting in queue. The new method ruturnwaitsringandflowBufferhas a newatomic.Uint32type fieldwaits. when new commands(or command) are added to queue fromPutOneorPutMulti,waitsbecomewaits+1. WhenFinishResultmethod is calledwaitsbecomewaits-1.Atomic operation is cheap, but makes additional overhead always. So if a user doesn’t want collecting stats overhead, user turn off collecting stats. So
ringandflowBufferhas a newbooltype fieldcollectStats.collectStatsis from constructor. ifcollectStatsis false, do not operate on thewaits.Conn
muxcan have multiplemuxwire. So we should provide stats on multiple queues. Now we provide 4 metrics.maxWaitingCommandCountand average command count fromtotalWaitingCommandCountandqueueCounttells how to tunequeueis better.Client
Adding a new interface
ClientStatsProvidernot to happen breaking change intClientinterface. If user wants to getClientStats, user should type check to theClient.singleClient,sentinelClient,clusterClientimplement `ClientStatsProvider.sentinelClientaggregates stats frommConnandrConncallingWaitingCommandInQueueStats.clusterClientaggregates stats fromconnscallingWaitingCommandInQueueStats.Overall operation is cheap, but overhead is inevitable. So as I mentioned above, If want to collecting stats, user configures explicitly. So we introduce a new client option.
Maybe later, More metrics can be added too. So we define a new struct about client stats option.
Alternatives Considered
I’ve considered
wrCounterusing stats. pros ofwrCounteruse no additional computation resource and overhead. ButwrCounterincrease even though commands are not entered to queue. SowrCounteris not accurate for stats.Beta Was this translation helpful? Give feedback.
All reactions