Connection pools
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Layer 3 · Go deeper · 6 min

    Go deeper

    Size it, build it, then make the calls an interviewer will push you on.

    Build-up · 4 steps

    Two servers, four clients

    PgBouncer with two server connections and four clients, A to D. Each small box is one transaction.

    Step 1 of 4

    Session mode holds a server

    Each client keeps its server connection until it disconnects, idle gaps included. Two servers serve two clients; C and D wait.

    4 interview moments

    You’re the candidate

    The interviewer pushes on the hard parts. Pick an approach and see how it holds up.

    1. Deep dive 1 of 4

      Interviewer

      “Your orders service autoscales to 200 pods at dinner peak, each with a pool of 20. PostgreSQL allows 100 connections. What do you do?”

      Your move. Pick an approach:

    2. Deep dive 2 of 4

      Interviewer

      “A Lambda function opens a PostgreSQL connection inside its handler. A burst brings 1,000 concurrent invocations. What do you change?”

      Your move. Pick an approach:

    3. Deep dive 3 of 4

      Interviewer

      “A handler borrows a connection at the top, calls another service, runs 5 ms of SQL and returns the connection 50 ms later. What’s wrong?”

      Your move. Pick an approach:

    4. Deep dive 4 of 4

      Interviewer

      “Thirty-second reports and 3 ms checkout queries share one pool. Checkouts start timing out whenever reports run. What do you do?”

      Your move. Pick an approach:

    Build-up · 7 steps

    How a slow database takes a pod down

    One pod at dinner peak. 500 requests a second, one query each, a pool of 20, 200 request threads and HikariCP’s default 30-second checkout timeout.

    Step 1 of 7

    The database slows down

    A missing index or a lock makes queries take 400 ms instead of 4. Normally the pool runs about 2 connections busy.