Kubai Kevin

46 articles tagged Postgresql

Distributed locks: safe only with fencing

A lease can expire while its holder is still running. Fencing tokens, enforced by the protected resource, are what make a distributed lock safe.

17 min read · 13 November 2026

7 ADR traps that cause stale decisions

How architecture decision records go stale: template bloat, drifting status fields, hidden storage, broken numbering, missing context, no workflow trigger, no review.

15 min read · 12 November 2026

Pagination for large datasets: offset vs cursor

How offset and keyset pagination behave on large datasets, where each fails, and how to ship signed cursors that stay correct under writes.

15 min read · 8 November 2026

SQLAlchemy vs asyncpg: pooling in async services

How SQLAlchemy's async engine and asyncpg's pool actually relate, how to size pools against Postgres max_connections, and the failure modes that cause timeouts.

13 min read · 3 November 2026

Database restore drills that mean something

A repeatable PostgreSQL restore drill that measures recovery time, data loss window and integrity, plus the failure modes that make drills lie.

15 min read · 28 October 2026

Read replicas: the bug factory you built

Read replicas lag by design. Learn how to classify reads, route freshness-critical queries to the primary, and measure your exposure to stale reads.

15 min read · 18 October 2026

Webhook delivery that survives outages

How to build durable webhook delivery with a transactional outbox, at-least-once queues, idempotency keys, and a retry schedule that outlasts outages.

13 min read · 2 October 2026

Double-entry ledger: concurrent write errors

Why concurrent writes corrupt double-entry ledgers, and how to enforce the debit-equals-credit invariant with isolation, locks, and triggers.

15 min read · 1 October 2026

Portfolio projects hiring managers skip

Portfolio projects often fail screening for legibility, not code quality. Here is how to restructure a repo so a reviewer understands it fast.

19 min read · 25 September 2026

CQRS: when it pays off and when it breaks

CQRS trades strong consistency for independent read and write scaling. Learn the failure modes, how to measure projection lag, and when a read replica is enough.

12 min read · 21 September 2026

Idempotency keys: what they fix, what they don't

How idempotency keys work, where they fail, and the failure modes they don't cover: concurrent retries, key reuse, expiry, and partial failures.

14 min read · 21 September 2026

Golden paths that don't handcuff

How to build internal scaffolds and CLIs that stay reversible: pinned versions, a compatibility contract, drift detection, and a tested eject path.

12 min read · 21 September 2026

Context windows: agents that run for days

Long-running agents fail when context is treated as a log. Keep constraints verbatim, checkpoint durable state, and cap the working set per cycle.

17 min read · 19 September 2026

Stop Putting LLM Keys in .env

Why flat .env files fail at scale for LLM API keys, and how a secrets manager plus gateway brokering scoped credentials fixes rotation and leaks.

14 min read · 17 September 2026

Designing a Schema That Survives Embedding Model Upgrades

Why embedding columns break on model upgrades, how to version vectors, migrate legacy JSON payloads, and when to offload to a vector store.

11 min read · 13 September 2026

Durable Execution for Multi-Step Agent Workflows

Why cron and ad-hoc retries break multi-step agent workflows, and how durable execution runtimes model retries, idempotency, and compensation.

16 min read · 3 September 2026

Only boring stacks survive AI services

Why monoliths beat microservices for solo AI builders, how to spot the "one more abstraction" trap, and how to measure when vertical scaling stops working.

16 min read · 31 August 2026

Replace managed services with Postgres 17

How to decide whether to replace managed cache, search, and scheduler services with Postgres extensions, and how to measure the trade-off honestly.

14 min read · 16 August 2026

Agent SLOs: measure what agents actually do

Latency and 5xx SLOs miss stuck loops. Define outcome SLOs on completion rate, with schema, PromQL, and failure handling.

13 min read · 11 August 2026

Senior role projects: 3 real paths

Build three portfolio projects that demonstrate tenant isolation, retry-storm handling, and event sourcing, with concrete ways to measure each claim.

16 min read · 5 August 2026

CDC pipeline death spiral: one bad LLM call can crash…

How unconstrained LLM bursts stall CDC pipelines, and how to add backpressure at each layer with metrics, configs, and a worked failure example.

12 min read · 2 August 2026

Postgres vector search: what breaks first

pgvector works until load grows. Here is what fails first, how to measure it, and when a dedicated ANN service earns its operational cost.

13 min read · 24 July 2026

Poolers won’t save your serverless DB

Why poolers add latency and cost to bursty serverless workloads, and how multiplexing, the Aurora Data API, and direct connections compare.

14 min read · 19 July 2026

Serve 4G-as-baseline apps in 2026

Design APIs for 300 ms RTT, packet loss and data caps: payload budgets, stale-while-revalidate caching, adaptive fetch and honest measurement.

14 min read · 3 July 2026

Stop the writes — zero-downtime DB migrations

Zero-downtime migrations fail when writes keep flowing during the copy. A drain-copy-flip state machine, with instrumentation and a decision checklist.

13 min read · 2 July 2026

Postgres 17 swallowed Redis, Kafka, Timescale

How to evaluate consolidating Redis, Kafka and a time-series database into Postgres extensions, with honest limits, failure modes and a checklist.

14 min read · 2 July 2026

RAG on legacy systems: vector DB vs. full-text SQL

Compare vector databases and in-database vector search for adding RAG to legacy systems, with latency, cost, and operational trade-offs.

14 min read · 30 June 2026

AWS costs for Nairobi SaaS: 2026 bill split

How to split an AWS bill by service for a Nairobi-facing SaaS: cost drivers, measurement commands, and a decision checklist for region choice and DR.

13 min read · 28 June 2026

When flags become experiments

How to run feature flags and A/B tests on a $5 VPS with no data warehouse, using offline-tolerant self-hosted tooling and SMS replies as conversions.

15 min read · 28 June 2026

Spot AI’s hidden cost spike in your stack

AI refactors often trade cache hits for database reads, exhausting pools and inflating bills. Here is how to detect, verify and gate the change.

14 min read · 28 June 2026

Migrations? Stop running them live

Why live schema migrations cause outages, and how versioning the schema as a deployable artifact with expand/contract steps reduces that risk.

11 min read · 28 June 2026

Monolith to services without a rewrite

Most monolith-to-services migrations fail on data coupling, not code structure. Here is how to audit coupling and measure the latency tax before extracting.

14 min read · 27 June 2026

RAG is not enough: hybrid search + reranking in 2026

Dense retrieval alone ranks poorly. A two-stage pipeline of BM25 plus a cross-encoder reranker fixes it. Architecture, code, and how to measure it.

12 min read · 27 June 2026

Postgres 17 buried Redis, S3, cron

How to evaluate Postgres 17 as a cache, scheduler and blob store, with measurement steps, failure modes and a decision checklist.

11 min read · 26 June 2026

Store data once, serve everywhere: cheaper

How to serve reads from regional caches instead of replicating your database everywhere, with worked cost math, invalidation code, and failure modes.

12 min read · 25 June 2026

Log audit costs without breaking compliance

Compare PostgreSQL and ClickHouse for audit logging: write amplification, query latency, retention, cost modelling, and a decision checklist.

13 min read · 22 June 2026

Webhook Delivery: Retries, Idempotency, and Durability

Design reliable webhook ingestion with durable buffering, idempotency keys, bounded retries, and circuit breakers, plus how to measure each guarantee.

11 min read · 19 June 2026

Tool calling: stateless beats stateful under load

How request-scoped and pooled tool calls behave under load, what to instrument, and a decision checklist for choosing between them.

11 min read · 19 June 2026

Runbooks vs AI Runbooks: A Decision Framework

Compare static and AI-generated runbooks on detection, MTTR, cost, and auditability, with a 30-day experiment to test which fits your team.

12 min read · 18 June 2026

A Solo-Project Deploy Pipeline That Stays Under $20/Month

Build a test-and-deploy pipeline with GitHub Actions and a container host, then measure cost, cold start, and rollback time yourself.

16 min read · 15 June 2026

Why AI Interview Graders Reward Keywords Over Correct Design

AI interview graders score answers against training-data patterns, not correctness. Here is how the bias shows up and how to write answers that survive it.

12 min read · 14 June 2026

Build a search system in 2026: semantic, keyword

How to build a hybrid search service with PostgreSQL, pgvector, and Redis: schema, keyword and semantic queries, reranking, caching, and how to measure recall.

13 min read · 10 June 2026

Neon vs PlanetScale vs Turso: which broke first?

Diagnose connection drops, replica lag and proxy limits in Neon, PlanetScale and Turso, with reproducible tests and fixes that do not rely on guesswork.

13 min read · 10 June 2026

Soft deletes fail: what breaks first

Soft deletes leak into every query and bloat indexes. Here is how to measure the damage and move to a tiered live/archive/cold lifecycle.

13 min read · 9 June 2026

Event sourcing: pay the complexity tax only here

When an append-only event log earns its cost, when a temporal table is enough, and how to measure replay and projection lag before committing.

10 min read · 9 June 2026

RAG in prod: what tutorials won’t tell you

Why nightly embedding refreshes break RAG latency, and how a hot/cold retrieval split with partial vector updates fixes it.

14 min read · 8 June 2026