-
-
Save pontiyaraja/914d14b368270519c7bf9ce0762e8e38 to your computer and use it in GitHub Desktop.
Assessing pending activity of a Redis server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ~/tcp_redis_monitor.py 6379 | |
Timestamp Nb TX bytes RX bytes TX RMA RX RMA | |
1333983822.943 1 0 0 0.000 0.000 | |
1333983823.193 1 0 0 0.000 0.000 | |
1333983824.194 1 0 0 0.000 0.000 | |
1333983825.195 1 0 0 0.000 0.000 | |
1333983826.196 1 0 0 0.000 0.000 | |
>> Starting redis-benchmark with some pipelining | |
>> The client box is way slower than the server box, so transmit buffers are used | |
1333983827.197 197 27020 360 15739.062 90.000 | |
1333983828.198 197 27440 0 23663.922 58.008 | |
1333983829.200 261 26110 0 25830.694 18.354 | |
1333983830.201 182 25060 280 24926.614 128.307 | |
1333983831.202 182 25060 0 25052.249 70.128 | |
1333983832.203 293 20323 0 23994.704 22.189 | |
1333983833.205 201 20000 0 21161.996 7.021 | |
1333983834.206 201 20000 0 20297.350 377.221 | |
1333983835.207 201 20000 0 20056.584 494.355 | |
1333983836.208 201 9900 6560 16873.544 1902.636 | |
1333983837.209 201 35460 820 29794.285 893.490 | |
1333983838.210 201 35820 820 33991.473 487.706 | |
1333983839.211 201 36000 0 35320.193 356.110 | |
1333983840.212 186 37000 0 33447.827 1061.660 | |
1333983841.213 186 37000 0 35838.570 508.416 | |
1333983842.214 186 36800 0 36519.235 160.866 | |
>> Running redis-cli debug sleep 20 | |
>> which freezes the Redis event loop for 20 secs | |
>> Now incoming traffic is accumulating in the receive buffers | |
1333983843.215 202 15000 101200 31235.383 25868.399 | |
1333983844.216 202 0 184015 9883.070 133577.521 | |
1333983845.218 202 0 184015 3127.065 168056.266 | |
1333983846.219 202 0 184015 989.423 178965.557 | |
1333983847.220 202 0 184015 313.060 182417.325 | |
1333983848.221 202 0 184015 99.054 183509.486 | |
1333983849.222 202 0 184015 31.341 183855.052 | |
1333983850.223 202 0 184015 9.917 183964.391 | |
1333983851.224 202 0 184015 3.138 183998.987 | |
1333983852.225 202 0 184015 0.993 184009.933 | |
1333983853.226 202 0 184015 0.314 184013.397 | |
1333983854.227 202 0 184015 0.099 184014.493 | |
1333983855.229 202 0 184015 0.031 184014.840 | |
1333983856.230 202 0 184015 0.010 184014.949 | |
1333983857.231 202 0 184015 0.003 184014.984 | |
1333983858.232 202 0 184015 0.001 184014.995 | |
1333983859.233 202 0 184015 0.000 184014.998 | |
1333983860.234 202 0 184015 0.000 184014.999 | |
1333983861.235 202 0 184015 0.000 184015.000 | |
1333983862.236 202 0 184015 0.000 184015.000 | |
>> End of the freeze | |
1333983863.237 201 40000 0 17500.000 103508.437 | |
1333983864.238 264 31814 0 30834.359 32750.717 | |
1333983865.239 182 36200 0 33647.055 10362.531 | |
1333983866.240 182 35800 0 35205.514 3515.020 | |
1333983867.241 201 36200 0 35885.338 1112.174 | |
1333983868.242 201 36000 0 32769.752 554.399 | |
1333983869.243 201 35820 0 34880.195 230.259 | |
1333983870.244 201 36000 0 35533.890 170.355 | |
1333983871.245 272 29330 0 34087.989 127.027 | |
1333983872.246 201 16000 0 21503.883 280.661 | |
1333983873.248 201 16000 0 17718.963 409.428 | |
1333983874.249 201 16000 0 16502.641 129.546 | |
1333983875.250 201 14754 0 15847.539 40.989 | |
1333983876.000 201 20000 0 16715.368 157.917 | |
1333983877.001 201 20000 0 18927.909 214.029 | |
1333983878.002 201 20000 0 19598.674 307.954 | |
1333983879.004 201 39400 0 26906.924 97.439 | |
>> End of the benchmark | |
1333983880.005 1 0 0 13894.394 30.830 | |
1333983881.006 1 0 0 4396.273 9.755 | |
1333983882.007 1 0 0 1391.008 3.087 | |
1333983883.008 1 0 0 440.124 0.977 | |
1333983884.009 1 0 0 139.258 0.309 | |
1333983885.010 1 0 0 44.062 0.098 | |
1333983886.012 1 0 0 13.942 0.031 | |
1333983887.013 1 0 0 4.411 0.010 | |
1333983888.014 1 0 0 1.396 0.003 | |
1333983889.015 1 0 0 0.442 0.001 | |
1333983890.016 1 0 0 0.140 0.000 | |
1333983891.018 1 0 0 0.044 0.000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# --------------------------------------------------------- | |
import sys,time, math | |
# --------------------------------------------------------- | |
class ProcReader: | |
""" | |
Format of /proc/net/tcp | |
46: 010310AC:9C4C 030310AC:1770 01 | |
| | | | | |--> connection state | |
| | | | |------> remote TCP port number | |
| | | |-------------> remote IPv4 address | |
| | |--------------------> local TCP port number | |
| |---------------------------> local IPv4 address | |
|----------------------------------> number of entry | |
00000150:00000000 01:00000019 00000000 | |
| | | | |--> number of unrecovered RTO timeouts | |
| | | |----------> number of jiffies until timer expires | |
| | |----------------> timer_active (see below) | |
| |----------------------> receive-queue | |
|-------------------------------> transmit-queue | |
1000 0 54165785 4 cd1e6040 25 4 27 3 -1 | |
| | | | | | | | | |--> slow start size threshold, | |
| | | | | | | | | or -1 if the threshold | |
| | | | | | | | | is >= 0xFFFF | |
| | | | | | | | |----> sending congestion window | |
| | | | | | | |-------> (ack.quick<<1)|ack.pingpong | |
| | | | | | |---------> Predicted tick of soft clock | |
| | | | | | (delayed ACK control data) | |
| | | | | |------------> retransmit timeout | |
| | | | |------------------> location of socket in memory | |
| | | |-----------------------> socket reference count | |
| | |-----------------------------> inode | |
| |----------------------------------> unanswered 0-window probes | |
|---------------------------------------------> uid | |
""" | |
def __init__(self,port): | |
self.port = port | |
self.f = open( "/proc/net/tcp" ) | |
self.porthex = ":%04X" % (port) | |
def read(self): | |
now = time.time() | |
self.f.seek(0) | |
lines = self.f.readlines() | |
n, sum_tx, sum_rx = 0, 0, 0 | |
for line in lines: | |
t = line.split() | |
if not t[1].endswith(self.porthex): | |
continue | |
x = t[4].split(':') | |
n += 1 | |
sum_tx += int(x[0],16) | |
sum_rx += int(x[1],16) | |
return now,sum_tx,sum_rx,n | |
# --------------------------------------------------------- | |
def main(port): | |
""" | |
Display: timestamp | |
nb sockets | |
tx = pending data to transmit for all connections (bytes) | |
rx = pending data to receive for all connections (bytes) | |
running moving average of tx (1 sec, 4 points) | |
running moving average of rx (1 sec, 4 points) | |
""" | |
p = ProcReader(port) | |
t, tx, rx = 0.0, 0.0, 0.0 | |
print "%16s %6s %12s %12s %16s %16s" % ( "Timestamp", "Nb", "TX bytes", "RX bytes", "TX RMA", "RX RMA" ) | |
while 1: | |
x = p.read() | |
tx = (3*tx+x[1])/4 | |
rx = (3*rx+x[2])/4 | |
if int(x[0]) != t: | |
print "%16.3f %6d %12d %12d %16.3f %16.3f" % (x[0],x[3],x[1],x[2],tx,rx) | |
t = int(x[0]) | |
time.sleep(0.250-(time.time()-x[0])) | |
# --------------------------------------------------------- | |
if len(sys.argv) != 2: | |
sys.stderr.write( "Usage: %s port\n" % (sys.argv[0]) ) | |
sys.exit( -1 ) | |
main( int(sys.argv[1]) ) | |
# --------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment