Skip to content

perf(db): keep the connection pool warm and bounded - #16

Merged
ziyan merged 1 commit into
masterfrom
perf/tune-connection-pool
Jul 6, 2026
Merged

ziyan merged 1 commit into
masterfrom
perf/tune-connection-pool

Conversation

@ziyan

@ziyan ziyan commented Jul 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

Remote mesh nodes showed SQL p50 ~5x the raw RTT: the default pool (2 idle,
unbounded open) makes bursty paths repeatedly pay the peer tunnel setup cost
(tcp + ssh + tls + postgres auth ≈ 1.5-2.5s), folded into whichever statement
triggered the dial.

  • keep 8 idle connections warm, for up to 5 minutes
  • cap open connections at 16 per node (4 nodes ≤ 64, postgres now at
    max_connections=200)

Changed

  • Database connection pool keeps idle connections warm and bounds open
    connections, avoiding repeated peer tunnel setup costs on remote nodes

Test plan

  • make test (postgres + -race), make lint, make lint-mulint all clean
  • config-only change; the effect will be measured on the live mesh (expect
    remote SQL p50 to drop from ~850-980ms toward the ~1x RTT floor)

The default pool keeps only two idle connections and opens unbounded new
ones, so bursty hot paths on remote mesh nodes repeatedly pay the peer
tunnel setup cost (tcp, ssh handshake, tls, postgres auth — several
cross-region roundtrips folded into whichever statement triggered the
dial). Keep eight warm for five minutes and cap each node at sixteen so
its footprint on the shared postgres stays predictable.

Claude-Session: https://claude.ai/code/session_01CgmQm9dfiuFwheFGfQA8Zz
@ziyan ziyan added the AI-generated Opened by an AI assistant label Jul 6, 2026
@codecov

codecov Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.28%. Comparing base (4a5f2ba) to head (e565ac0).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
db/db.go 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #16      +/-   ##
==========================================
- Coverage   62.49%   62.28%   -0.21%     
==========================================
  Files          28       28              
  Lines        2293     2299       +6     
==========================================
- Hits         1433     1432       -1     
- Misses        688      692       +4     
- Partials      172      175       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ziyan
ziyan marked this pull request as ready for review July 6, 2026 19:55
@ziyan
ziyan merged commit 0301d0e into master Jul 6, 2026
10 checks passed
@ziyan
ziyan deleted the perf/tune-connection-pool branch July 6, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-generated Opened by an AI assistant

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant