Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Add stats_tcp_retrans() #750

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

uhm0311
Copy link
Collaborator

@uhm0311 uhm0311 commented Apr 1, 2024

๐Ÿ”— Related Issue

โŒจ๏ธ 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

@namsic

This comment was marked as resolved.

@ing-eoking
Copy link
Collaborator

์ด์ „์— 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 ํ•˜๋Š” ๋ฐฉ์‹์€ ์–ด๋–ค๊ฐ€์š”?

@uhm0311 uhm0311 force-pushed the uhm0311/develop branch 2 times, most recently from a0815b2 to f161e22 Compare May 2, 2024 07:57
@uhm0311
Copy link
Collaborator Author

uhm0311 commented May 2, 2024

์ €ํฌ ์ชฝ์—์„œ ๋งŒ๋“  ๋กœ์ง์ธ ๊ฑด๊ฐ€์š”? ์•„๋‹ˆ๋ฉด 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 uhm0311 force-pushed the uhm0311/develop branch 2 times, most recently from 58cd6be to 3c6329e Compare May 2, 2024 09:19
ing-eoking

This comment was marked as resolved.

@uhm0311

This comment was marked as resolved.

@uhm0311 uhm0311 self-assigned this May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants