CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 08:45:17 GMT
content-type: text/html; charset=utf-8
cache-control: max-age=0, private, must-revalidate
cf-cache-status: DYNAMIC
link: ; rel=preload; as=style; nopush,; rel=preload; as=script; nopush,; rel=preload; as=style; nopush,; rel=preload; as=script; nopush,; rel=preload; as=script; nopush
nel: {"report_to":"heroku-nel","response_headers":["Via"],"max_age":3600,"success_fraction":0.01,"failure_fraction":0.1}
referrer-policy: strict-origin-when-cross-origin
report-to: {"group":"heroku-nel","endpoints":[{"url":"https://nel.heroku.com/reports?s=4aVFMr%2BeW9gum5ALXmLBYhuNopyX2ESKHu0YS0Zxl%2F0%3D\u0026sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d\u0026ts=1760172317"}],"max_age":3600}
reporting-endpoints: heroku-nel="https://nel.heroku.com/reports?s=4aVFMr%2BeW9gum5ALXmLBYhuNopyX2ESKHu0YS0Zxl%2F0%3D&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&ts=1760172317"
server: cloudflare
strict-transport-security: max-age=0; includeSubDomains
vary: Accept,Accept-Encoding
via: 2.0 heroku-router
x-content-type-options: nosniff
x-permitted-cross-domain-policies: none
x-request-id: e52f2558-e84f-f328-6288-f6c4ba0f06e1
x-runtime: 0.129120
x-xss-protection: 0
content-encoding: gzip
set-cookie: _secure_speakerd_session=hkqqnkXM0M6PmWoMGGfsvJJpfQ9MGlZoiw5ssSN4mnH04oIllA2mwB0EnKvbkNU4Kx1Zcqg23CQ3%2FwkVvMmwMQ2Oe7qgmNOtFgwC2K6fefhoNQu7FecqwQxMTcenMWCQNiiZt%2FGmqROfy302R2VCxjPBKzWCVclJCqG9krOxu7UdtvUO6HV0Xgabx3Bpfbrfk%2By1Ii3ZNEkpHEb6Au9OBzILSJl3huYnSeB2T9S194NE2lz1ZZP7b0AB5%2BulNOb0wz2QhOXMXnuh%2F05seIIgPc5fz9B5%2BVdzRdftdHjgA0lIV3Doh9x%2BjscpVsGxxSpAGPgZWL1aGWPU38SGfWuodmaN45N6dFGrVGOR6xPSyLn3qGKf1R5UTvmt8iEirF5Bj7XnOULS6q0ZzB%2Ft9eOpWckc--08dj6RkrOlLgivC4--Hb249SPCf6bCpGcxFQrhOQ%3D%3D; HttpOnly; SameSite=Lax; Secure; Path=/; Expires=Sat, 25 Oct 2025 08:45:17 GMT
cf-ray: 98cd14923f8e9ac4-BLR
ネットワークサービスの依存発見に向いた
TCP/UDP通信の低負荷なトレース手法 / Low Overhead TCP-UDP Tracing in Kernel - Speaker Deck
ネットワークサービスの依存発見に向いた TCP/UDP通信の低負荷なトレース手法 / Low Overhead TCP-UDP Tracing in Kernel
第8回WebSystemArchitecture研究会
https://wsa.connpass.com/event/207143/
Yuuki Tsubouchi (yuuk1)
June 05, 2021
More Decks by Yuuki Tsubouchi (yuuk1)
Other Decks in Research
Featured
Transcript
-
2 Ϋϥυ্ͷΞϓϦέʔγϣϯͷґଘؔͷෳࡶԽ ɾ ɾ ɾ ΞΫηε૿Ճ εέʔϧΞτʹΑΔ ϗετͷ૿Ճ ػೳͷ૿Ճ ϚΠΫϩαʔϏεͷ࠾༻
ϛυϧΣΞͷ૿Ճ ɾ ɾ ɾ RDBαʔό KVαʔό ݕࡧαʔό Webαʔό ωοτϫʔΫ αʔϏε TCP/UDP -
ιέοτϕʔεͷτϨʔεख๏ͷൺֱ . . . Kernel User Service Socket Tracing
Process … Event Event Event ετϦʔϛϯά๏(Weave Scope) ϑϩʔू๏ ([Datadog], [SAC 20]) ϑϩʔूଋ๏ʢఏҊʣ . . . Kernel User Service Socket Tracing Process . . . Event Flow Event Event Event … … . . . . . . User Service Socket Tracing Process Event Event . . . Event Event Event Event … … . . . Event Event … … . . . ✗ ΧʔωϧˠϢʔβۭؒؒ ͷΠϕϯτͷίϐʔίετ ✗ TCP໋ଓϨʔτ͕૿ Ճ͢Δͱɺίϐʔίετ͕ ૿Ճ ෳͷϑϩʔΛूଋ Flow = ྆ͷΞυϨεͱϙʔτͷ ʢλϓϧʣ͕ಉҰͷ௨৴୯Ґ -
5 TCP໋ଓ τϨʔεॲཧͷCPUෛՙ ɾX࣠ TCP໋ଓ 5k ~ 35k ɾY࣠ ίΞ͋ͨΓͷCPUར༻
(0-25%) 0 5 10 15 20 25 5 10 15 20 25 30 35 CPU usage / core (%) TCP round trips / sec (x103) Snap-Poll(client) Snap-Poll(server) Streaming(client) Streaming(server) In-Kernel-Aggr(client) In-Kernel-Aggr(server) In-Kernel-Bundling(client) In-Kernel-Bundling(server) ɾఏҊख๏ͷCPUར༻2.2%ҎԼ ɾx࣠૿Ճʹରͯ͠ɺCPUར༻Λҡ࣋ ɾετϦʔϛϯά๏ɺX࣠ʹൺྫͯ͠Y͕࣠ ૿Ճɻ࠷େ20%ఔͷCPUར༻ɻ ɾΧʔωϧू๏ɺετϦʔϛϯά๏Α ΓY͕͍࣠ɻ -
7 ΧʔωϧͰͷෳϑϩʔͷूଋ๏ ɾωοτϫʔΫαʔϏεؒͷґଘΛΔ͚ͩͳΒɺ໋ϙʔτෆཁ ɾsrc, destΞυϨεɺϦοεϯϙʔτΛҰҙΩʔͱͯ͠ूଋ TCP/UDP Connections Hash map .
. . . . . Key Kernel User Service Service Value Socket daddr saddr lport protocol 4-tuple Tracing Process ɾΧʔωϧۭؒͷϋογϡ දʹੵ ɾTracingϓϩηε͕Ұఆपظ (1sఔ)ͰूΠϕϯτΛ όονऔಘ connect, accept, read, write,… . . . . . . -
8 Χʔωϧϑϩʔूଋ๏ͷΞϧΰϦζϜ ೖྗ: ιέοτߏମ S, ͪड͚ϙʔτϦετ P ूͷͨΊͷϋογϡද H ͷ࡞
function PROBE__TCP_CONNECT (S) INSERT_FLOW_EVENT(S, TCP) end function function PROBE__TCP_ACCEPT (S) INSERT_FLOW_EVENT(S, TCP) end function function PROBE__TCP_SENDMSG (S) INSERT_FLOW_EVENTS(S, TCP) end function function PROBE__TCP_RECVMSG (S) INSERT_FLOW_EVENTS(S, TCP) end function ग़ྗ: ूଋࡁΈͷϑϩʔϦετ function GET_LISTENING_PORTS_AND_DIRECTIONS (S) if P.lookup(S.sport) then return S.sport, INCOMING else return S.dport, OUTCOMING end if end function function INSERT_FLOW_EVENTS (S, proto) lport, dir = GET_LISTENING_PORTS_AND_DIRECTIONS(S) key ← {S.saddr, S.daddr, lport, dir, proto} H.update(key, stats) end function UDPলུ -
9 Χʔωϧूଋ๏ͷ࣮ 1. ΧʔωϧؔΛड͢Δ → LinuxͷkprobeΛ༻ ɾΧʔωϧͷΦϒδΣΫτʹҙͷϋϯυϥΛઃఆՄೳ 2. ΧʔωϧͰ҆શʹϋϯυϥΛهड़͢Δ →
Linux eBPFΛ༻ ɾִ͞ΕͨαϯυϘοΫεڥͰϓϩάϥϜΛ࣮ߦՄೳ 3. ϋογϡදʹूଋ͞ΕͨϑϩʔΛ֨ೲ → eBPF MapΛ༻ ɾMapʹϢʔβۭ͔ؒΒΞΫηεՄೳ ࣮ https://github.com/yuuki/go-conntracer-bpf ʹͯެ։ -
10 ࣮ͷུ֓ਤ TCP/UDP Connections Flow table . . . .
. . 4-tuple Kernel User Service Service Stat Socket Tracing Process connect, accept, sendto, recv . . . . . . tcp_v4_connect() inet_csk_accept() ىಈ࣌ʹͪड ͚ϙʔτͷ ϦετΛऔಘ tcp_sendmsg() tcp_cleanup_rbuf() UDPলུ kprobeͰΞλον͢Δ Χʔωϧؔ insert Batch APIʹΑ ΓෳϨίʔυ ಉ࣌औಘ MapΛ༻ -
11 ࣮ݧͷͨΊͷܭࢉػڥ Client (ཁٻଆ) Server (डଆ) Tracing Process Tracing Process
benchmark process benchmark process ڥ1: 1ର1 ωοτϫʔΫαʔϏε ڥ2: 1ରN ωοτϫʔΫαʔϏε Client (ཁٻଆ) Server (डଆ) Tracing Process benchmark process ɾɾɾ ɾɾɾ ɾɾɾ • CPU: Intel Xeon Gold 6212U @2.40GHz x 6ίΞ • ϝϞϦ: 16GB • OS: Ubuntu 20.10 Kernel 5.8.0-33 Connperf: https://github.com/yuuki/connperf ෛՙੜ • ࣗ࡞ͷΤίʔαʔόɾΫϥΠΞϯτ • ඵؒͷ৽نଓΛݻఆՄೳ -
12 τϨʔεॲཧͷCPUෛՙʢ1ର1ڥʣ ɾఏҊख๏ɺCPUར༻Λ2.2%ҎԼ·Ͱݮ TCP໋ଓ UDP ఏҊख๏ 0 5 10 15
20 25 5 10 15 20 25 30 35 CPU usage / core (%) Number of TCP connections (x103) Snap-Poll(client) Snap-Poll(server) Streaming(client) Streaming(server) In-Kernel-Aggr(client) In-Kernel-Aggr(server) In-Kernel-Bundling(client) In-Kernel-Bundling(server) 0 5 10 15 20 25 5 10 15 20 25 30 35 CPU usage / core (%) TCP round trips / sec (x103) Snap-Poll(client) Snap-Poll(server) Streaming(client) Streaming(server) In-Kernel-Aggr(client) In-Kernel-Aggr(server) In-Kernel-Bundling(client) In-Kernel-Bundling(server) 0 5 10 15 20 25 5 10 15 20 25 30 35 CPU usage / core (%) UDP round trips / sec (x103) Streaming(client) Streaming(server) In-Kernel-Aggr(client) In-Kernel-Aggr(server) In-Kernel-Bundling(client) In-Kernel-Bundling(server) TCPӬଓଓ -
13 ௨৴ઌͷαʔϏεʹର͢ΔCPUෛՙʢ1ରNڥʣ ɾඵؒଓΛ10kʹݻఆ (T=10k) ɾαʔϏεΛ200ʙ1000·Ͱ૿Ճ (R=0.98 .. 0.9) ɾαʔϏεͷ૿େʹରͯ͠ɺCPUར༻2%Ҏ
Լ ɾҟͳΔͪड͚ϙʔτΛͭ௨৴ઌ͕૿͑Δͱɺूଋ͕Լ ↪ CPUෛՙ͕૿େ͢Δͣ 0 1 2 3 4 5 200 400 600 800 1000 CPU usage per core (%) Number of network services In-Kernel-Bundling(client,TCP short-lived) In-Kernel-Bundling(server,TCP short-lived) In-Kernel-Bundling(client,TCP persistent) In-Kernel-Bundling(server,TCP persistent) In-Kernel-Bundling(server,UDP) In-Kernel-Bundling(client,UDP) ूଋ R = 1 - B / T B: ूଋ͞Εͨϑϩʔ T: ϢχʔΫϑϩʔ -
14 ΞϓϦέʔγϣϯͷԆΦʔόϔου TCP໋ଓ UDP Ping RTT 300μs ʹରͯ͠ɺఏҊख๏ͷΦʔόϔου 5.8 μsɻ
2%ͷΦʔόϔου૿Ճɻ 0 1 2 3 4 5 6 5 10 15 20 RTT overhead (µs) UDP round trips / sec Streaming 3.6 3.2 3.1 3.1 In−Kernel−Aggr 4.6 4.1 4.0 4.2 In−Kernel−Bundling 4.1 3.4 3.3 3.4 0 1 2 3 4 5 6 5 10 15 20 RTT overhead (µs) Number of TCP connections Streaming 0 0 0 0 In−Kernel−Aggr 2.4 2.1 2.3 2.2 In−Kernel−Bundling 2.4 2.2 2.1 2.1 0 1 2 3 4 5 6 5 10 15 20 RTT overhead (µs) TCP round trips / sec Streaming 2.2 2.1 2.1 2.5 In−Kernel−Aggr 4.7 4.7 5.0 5.7 In−Kernel−Bundling 4.8 4.9 5.0 5.8 TCP࣋ଓతଓ