Mehdi Akiki

Posts tagged "following a tcp connection"

  • Published on

    Investigation · Part 10 of 10 · Following a TCP connection

    What a Connection Pool Saves, and the Stale Connection It Gives You Back

    Reusing one connection made 1000 HTTPS requests 21 times faster, and with the stock Python server it first made them 60 times slower. I measured what a pool saves, what a stale connection returns, and which retry pays the same customer two times.
  • Published on

    Investigation · Part 9 of 10 · Following a TCP connection

    What a TLS Handshake Costs

    On loopback a TCP connect costs tens of microseconds and a TLS 1.3 handshake costs about one to three milliseconds. I counted the records, the bytes and the CPU on both sides, compared an RSA and an ECDSA certificate, measured resumption, and found 42 ms that were not TLS at all.
  • Published on

    Investigation · Part 8 of 10 · Following a TCP connection

    How a Name Becomes an Address: What getaddrinfo Really Does

    Connecting to localhost took 77 microseconds and connecting to 127.0.0.1 took 12, to the same server. I followed getaddrinfo with strace: four sources tried in order, files read on every call, answers sorted with IPv6 first, and a lookup that blocks the thread.
  • Published on

    Investigation · Part 7 of 10 · Following a TCP connection

    TIME_WAIT: Why a Closed Connection Stays Around

    My client and my server closed 500 connections, and the kernel kept 500 sockets for 60 more seconds. I measured which side keeps TIME_WAIT, why tcp_fin_timeout does not change it, how the client side runs out of local ports, and why a restarted server can fail to bind.
  • Published on

    Investigation · Part 6 of 10 · Following a TCP connection

    What close() Really Sends: FIN, RST and Unread Data

    close() returns 0 and the program learns nothing more. I made five small experiments to see what the other side gets: a clean end of file, a reset, a half-closed connection, a broken pipe that kills a C program, and CLOSE-WAIT sockets that never go away.