Mehdi Akiki

Writing archive

Everything published under Writing, newest first. Each entry is labelled as part of an investigation, an article or reference. Short engineering notes have their own archive.

  • 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 10 of 10 · Inside a database index

    Keeping a Derived Index in Sync Outside the Database

    I killed a program 200 times while it wrote documents and their search entries in two transactions: 104 documents became invisible to search, without any error. One transaction, or triggers, gave zero. When the copy lives in another system, only an outbox and reconciliation are left.
  • Published on

    Investigation · Part 9 of 10 · Inside a database index

    Deleted Rows Do Not Shrink the File: Free Pages and VACUUM

    I deleted half of a SQLite table and the file kept exactly the same size. The table gave its pages to a freelist, the index stayed half empty, and new rows used the holes. VACUUM fixed everything in 0.4 s, but it wrote three times the size of the result to do it.
  • 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.