arcus-memcached icon indicating copy to clipboard operation
arcus-memcached copied to clipboard

FEATURE: Add stats_tcp_retrans()

Open uhm0311 opened this issue 10 months ago โ€ข 4 comments

๐Ÿ”— Related Issue

  • https://github.com/jam2in/arcus-works/issues/498

โŒจ๏ธ What I did

  • stats ๋ช…๋ น์–ด์— TCP ์žฌ์ „์†ก ์ˆ˜์น˜๋ฅผ ํ•จ๊ป˜ ์ถœ๋ ฅํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.
  • prometehus์˜ node_exporter์™€ ๊ฐ™์€ ๋ฐฉ๋ฒ•์œผ๋กœ retrans ์ˆ˜์น˜๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
  • /proc/net/snmp file์—์„œ Tcp: RetransSegs์— ํ•ด๋‹นํ•˜๋Š” ๊ฐ’์„ int64_t๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
  • /proc/net/snmp ํŒŒ์ผ ๋‚ด์šฉ ์˜ˆ์‹œ๋Š” ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.
$ cat /proc/net/snmp
Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates
Ip: 1 64 1157539 0 2 0 0 0 1157535 1017212 0 0 0 0 0 0 0 0 0
Icmp: InMsgs InErrors InCsumErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps
Icmp: 151318 127 0 131 7 0 0 1 151158 21 0 0 0 0 151158 0 0 0 0 0 0 0 151158 0 0 0 0
IcmpMsg: InType0 InType3 InType5 InType8 InType11 OutType0
IcmpMsg: 21 131 1 151158 7 151158
Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors
Tcp: 1 200 120000 -1 6210 26425 2397 3871 6 1000039 866909 14396 0 8094 0
Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
Udp: 6190 0 0 6190 0 0 0 0 0
UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
UdpLite: 0 0 0 0 0 0 0 0 0
  • ์•„๋ž˜๋Š” ์‹ค์ œ ๋ช…๋ น์–ด ์‚ฌ์šฉ ์‹œ ์ถœ๋ ฅ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค.
$ echo stats | nc localhost 11211
...
STAT tcp_retrans 9815302
...
END

uhm0311 avatar Apr 01 '24 07:04 uhm0311

๋‚ด์šฉ ์ถ”๊ฐ€

โŒจ๏ธ What I did

  • prometehus์˜ node_exporter์™€ ๊ฐ™์€ ๋ฐฉ๋ฒ•์œผ๋กœ retrans ์ˆ˜์น˜๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
  • /proc/net/snmp file์—์„œ Tcp: RetransSegs์— ํ•ด๋‹นํ•˜๋Š” ๊ฐ’์„ uint64_t๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
  • /proc/net/snmp ํŒŒ์ผ ๋‚ด์šฉ ์˜ˆ์‹œ๋Š” ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.
$ cat /proc/net/snmp
Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates
Ip: 1 64 1157539 0 2 0 0 0 1157535 1017212 0 0 0 0 0 0 0 0 0
Icmp: InMsgs InErrors InCsumErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps
Icmp: 151318 127 0 131 7 0 0 1 151158 21 0 0 0 0 151158 0 0 0 0 0 0 0 151158 0 0 0 0
IcmpMsg: InType0 InType3 InType5 InType8 InType11 OutType0
IcmpMsg: 21 131 1 151158 7 151158
Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors
Tcp: 1 200 120000 -1 6210 26425 2397 3871 6 1000039 866909 14396 0 8094 0
Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
Udp: 6190 0 0 6190 0 0 0 0 0
UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
UdpLite: 0 0 0 0 0 0 0 0 0

namsic avatar Apr 01 '24 11:04 namsic

์ด์ „์— Offline์—์„œ ๋ง์”€๋“œ๋ฆฐ ๋ฐ๋กœ ํ˜„์žฌ ์ด์ „ PR๊ณผ ์ถฉ๋Œ์ด ๋‚œ ๊ด€๊ณ„๋กœ stats ๋ชจ๋“ˆ์ด ์•„๋‹Œ ๋‹ค๋ฅธ ์œ„์น˜๋กœ ์ด๋™ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

@namsic

prometehus์˜ node_exporter์™€ ๊ฐ™์€ ๋ฐฉ๋ฒ•์œผ๋กœ retrans ์ˆ˜์น˜๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

์ €ํฌ ์ชฝ์—์„œ ๋งŒ๋“  ๋กœ์ง์ธ ๊ฑด๊ฐ€์š”? ์•„๋‹ˆ๋ฉด prometheus ์˜ ๋กœ์ง์ธ๊ฐ€์š”?

@uhm0311

@jhpark816 ๋‹˜๊ป˜์„œ ๋ง์”€ํ•˜์‹  ๋Œ€๋กœ stats lock์„ ์žก๊ณ  ๋“ค์–ด๊ฐ€๊ธฐ์— ๋‹ค๋ฅธ connection์˜ ์„ฑ๋Šฅ์— ์˜ํ–ฅ์„ ๋ผ์น  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์ด ๋ถ€๋ถ„์— ๋Œ€ํ•˜์—ฌ stats๋ฅผ ๋‚ ๋ฆฐ connection ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๋‹ค๋ฅธ connection์˜ ๋ช…๋ น์–ด ์ˆ˜ํ–‰์— ์˜ํ–ฅ์„ ์ฃผ๋Š” ์ง€ ์„ฑ๋Šฅ ๊ฒ€์‚ฌ๊ฐ€ ํ•„์š”ํ•  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  /proc/net/snmp ๋‚ด ๋‚ด์šฉ์„ ๋ณด๋ฉด ํฌ๊ธฐ๊ฐ€ ํฌ์ง€ ์•Š์€ ๊ฒƒ์œผ๋กœ ๋ณด์ด๋ฏ€๋กœ stats ํ˜ธ์ถœ๋งˆ๋‹ค ํŒŒ์ผ์„ ๋ถˆ๋Ÿฌ์™€ parsingํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ memcached ๊ตฌ๋™ ์ดˆ๊ธฐ์— ํ•ด๋‹น ํŒŒ์ผ์„ memory mapping ํ•˜๋Š” ๋ฐฉ์‹์€ ์–ด๋–ค๊ฐ€์š”?

ing-eoking avatar May 02 '24 02:05 ing-eoking

์ €ํฌ ์ชฝ์—์„œ ๋งŒ๋“  ๋กœ์ง์ธ ๊ฑด๊ฐ€์š”? ์•„๋‹ˆ๋ฉด prometheus ์˜ ๋กœ์ง์ธ๊ฐ€์š”?

prometheus์—์„œ ๋งŒ๋“  ๋กœ์ง์ž…๋‹ˆ๋‹ค.


memcached ๊ตฌ๋™ ์ดˆ๊ธฐ์— ํ•ด๋‹น ํŒŒ์ผ์„ memory mapping ํ•˜๋Š” ๋ฐฉ์‹์€ ์–ด๋–ค๊ฐ€์š”?

/proc/net/snmp ํŒŒ์ผ์€ pseudo ํŒŒ์ผ๋กœ, Disk IO๊ฐ€ ํ•„์š”ํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ๋งคํ•‘ํ•˜์ง€ ์•Š์•„๋„ ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

https://unix.stackexchange.com/questions/8274/what-happens-when-i-open-and-read-from-proc


๋ช…๋ น์–ด ์ˆ˜ํ–‰์— ์˜ํ–ฅ์„ ์ฃผ๋Š” ์ง€ ์„ฑ๋Šฅ ๊ฒ€์‚ฌ๊ฐ€ ํ•„์š”ํ•  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

vCore 4๊ฐœ ๊ธฐ์ค€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์„ฑ๋Šฅ์„ ๋ณด์ž…๋‹ˆ๋‹ค.

149.169391 seconds for call function 1000003 times.
0.000149 seconds per function call.

ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์œผ๋ฉฐ, stats_tcp_retrans() ํ•จ์ˆ˜์˜ ๊ตฌํ˜„์€ PR ํ˜•ํƒœ์™€ ๋™์ผํ•ฉ๋‹ˆ๋‹ค.

uint64_t loop = 1000003;

void with_gettimeofday(void) {
    uint64_t i = 0;
    struct timeval start, end;

    gettimeofday(&start, NULL);
    for (i = 0; i < loop; i++) {
        stats_tcp_retrans();
    }
    gettimeofday(&end, NULL);

    double elapsed = (end.tv_sec - start.tv_sec) + ((end.tv_usec - start.tv_usec)/1000000.0);

    printf("%lf seconds for call function %lld times.\n", elapsed, loop);
    printf("%lf seconds per function call.\n", elapsed / loop);
}

int main() {
    with_gettimeofday();

    return 0;
}

uhm0311 avatar May 02 '24 08:05 uhm0311

@ing-eoking

๋ฐ˜์˜ํ–ˆ์Šต๋‹ˆ๋‹ค.

uhm0311 avatar May 03 '24 02:05 uhm0311