Secure, test, and operate
Measure pools, queries, and failures
Observe connection reuse, database pressure, cache behavior, query latency, and errors before tuning pool size or cache time.
Monitor both Cloudflare and the origin database. Hyperdrive may reduce connection setup while a slow query or large pool still overloads the database.
Start with conservative pool settings. Measure active origin connections, query latency, timeouts, cache hit behavior, and error classes. Keep a direct recovery path and a way to disable query caching if stale results cause harm.
Run a bounded load test in a practice environment and correlate Worker observations with database connection and query metrics.
Measure one request with a narrow query and a request ID:
select id, title
from notes
where user_id = $1
order by created_at desc
limit 20;
Record application duration, database duration, rows returned, pool errors, and the query plan. Repeat after a warm request. If the result is slow, do not assume geographic distance is the cause: a scan, lock, or exhausted origin pool can dominate the same request.
Lesson completed