Metrics of total_net_output_bytes and instantaneous_output_kbps are wrong

14 views
Skip to first unread message

Gen Liu

unread,
Jun 20, 2017, 2:50:40 AM6/20/17
to Redis DB
Recently I noticed that the traffic of a redis server is significant higher than normal(at about 2GB/s) and 
is about to exceed the hardware limits. I searched around and found many people are facing this problem.
So I dig into the code and find there is a bug. and here are the details:

Redis counts more bytes than it actually wrote when dealing with pending replies, and this would make 
metrics of instantaneous_output_kbps and total_net_output_bytes increase very fast.  

In src/networking.c writeToClient function:

while(clientHasPendingReplies(c)) {
    //...
    nwritten = write(/*...*/);
    totwritten += nwritten;
    //...
    server.stat_net_output_bytes += totwritten;
}

totwritten is counted(and not reset) each time the loop runs.  


 BTW I made a pull request on Github.


Gen Liu

unread,
Jun 21, 2017, 4:02:22 AM6/21/17
to Redis DB
this bug has been fixed yesterday.

在 2017年6月20日星期二 UTC+8下午2:50:40,Gen Liu写道:
Reply all
Reply to author
Forward
0 new messages