Kubai Kevin

64 articles tagged Python

Python deps: uv vs Poetry vs pip-tools

Compare uv, Poetry and pip-tools by resolver, lockfile and environment model, with a worked example, failure modes and a decision checklist.

12 min read · 15 November 2026

Structured logging: searchable at scale

Why free-text logs get slow and expensive at scale, and how a stable schema, shared logger, and value-based retention fix both problems.

20 min read · 12 November 2026

FastAPI vs Django vs Flask: API picks for 2026

Compare FastAPI, Django, and Flask on concurrency, validation, ORM, auth, and operations, with a worked latency example and a 30-minute check.

15 min read · 9 November 2026

k6 vs Locust: traffic models that lie

Why closed-loop load tests under-report latency, how to build open-loop traffic models in k6 and Locust, and how to read the results without fooling yourself.

13 min read · 7 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

Dependency pinning: the lockfile lie

A lockfile records a resolution, not a guarantee. Learn where determinism breaks, how to enforce lockfiles in CI, and how pinning interacts with SCA.

16 min read · 31 October 2026

Retire API versions before they pile up

Most API version graveyards come from shipping versions without a deletion plan. Here is how to make old versions cheap to measure, warn about, and remove.

12 min read · 12 October 2026

LLM evals: LangSmith vs Promptfoo in prod

How to choose between hosted trace-based eval platforms and local CLI eval runners, with latency, cost, CI and data-residency tradeoffs.

15 min read · 3 October 2026

DuckDB in production: when it replaces a warehouse

When an embedded columnar database beats a cloud warehouse for analytics, how to size it, and the failure modes that decide the boundary.

14 min read · 30 September 2026

Prompt injection: what breaks first in prod

Why prompt injection defeats prompt-level defenses, and how to bound the blast radius with tool allowlists, argument scoping, URL filtering and confirmation gates.

15 min read · 27 September 2026

Tech debt: when half your stack is unfamiliar

A repeatable process for debugging, verifying and governing tools you didn't write, with baselines, contracts, environment measurement and tool cards.

14 min read · 26 September 2026

Rust rewrites: where they pay off, where they don't

A practical framework for deciding whether a Rust backend rewrite is worth it, with code, failure modes, and measurement steps.

12 min read · 21 September 2026

Dead-letter queues: stop poison messages

Design retry caps, DLQs, and alerts so a poison message is isolated in seconds. Includes working Redis Queue code and pytest tests.

15 min read · 21 September 2026

Platform engineering ROI: metrics that fund teams

How to connect platform work to business outcomes with flow metrics, honest attribution, and instrumentation you can build in an afternoon.

13 min read · 19 September 2026

Zero-trust AI: skip the latency tax

How to keep per-request identity and least privilege in inference services while moving handshakes and policy evaluation off the hot path.

14 min read · 15 September 2026

Offline Agents: Local-First Sync Patterns

Design offline-capable agents with operation logs, versioned conflict resolution, auditable sync, and GDPR-aware deletion propagation.

12 min read · 7 September 2026

LLM eval drift that users notice first

Three pipeline-level causes of user-visible LLM drift, how to instrument each one, and how to verify the fix with metrics rather than vibes.

16 min read · 28 August 2026

AI features rot faster than you build them

Model APIs, prompts and schemas change under you. Here is how to make AI feature contracts explicit, versioned and reversible without a rewrite.

15 min read · 27 August 2026

Agent auth: where the docs ended up lying

OAuth2 and OIDC assume reliable clocks, stable power and trusted hardware. Here is what breaks on constrained agent networks, and how to measure it.

14 min read · 24 August 2026

WebSockets vs Server-Sent Events: latency over 3G

Compare WebSocket and Server-Sent Events for real-time features on 3G/4G: reconnect behaviour, proxy timeouts, framing overhead, and how to measure each.

14 min read · 21 August 2026

Validating AI-Generated Code Before It Reaches Production

AI-written code often fails quietly under load. Here is how to validate it at build time, guard it at runtime, and keep on-call triage fast.

10 min read · 20 August 2026

Evolve your monolith without rewriting in 2026

A three-layer FastAPI layout (API, domain, infra) that keeps a monolith evolvable: worked code, failure modes, cache stampede fixes, and how to measure.

15 min read · 19 August 2026

AI unit costs: the metric both teams fight over

Why per-call AI cost estimates break down, and how to instrument a shared cost-per-outcome metric that product and finance both accept.

14 min read · 18 August 2026

Rust SDK vs FastAPI for LLM ops: trust in 2026

How to compare a compiled Rust inference service against a Python async API for LLM serving: cold starts, cache stampedes, memory, and how to measure each.

10 min read · 14 August 2026

Foreign AI models vs sovereign fintech stacks: 2026 reality

How to choose between offshore LLM APIs and locally hosted inference for regulated fintech, with latency math, cost break-even, and a compliance checklist.

12 min read · 13 August 2026

Agent followed instructions too literally: the cron job trap

Why agents that follow retry instructions literally hang forever, and how to fix it with per-request timeouts, async retries, and DNS limits.

12 min read · 11 August 2026

Designing APIs for High-Latency Satellite Links

How to keep an API reliable over high-latency satellite links: circuit breakers, retry budgets, failover gateways, and the metrics that show what broke.

14 min read · 10 August 2026

Least privilege for agents: the config line nobody writes

Why permissive agent tool defaults break in production, and how to add runtime, context-aware policy checks before every tool call.

14 min read · 10 August 2026

Why your multi-agent system degraded slowly

Multi-agent systems can lose p99 responsiveness while every agent stays healthy. Here is how payload creep, queueing and retries compound, and how to measure it.

14 min read · 9 August 2026

MCP servers: the 3 hidden costs nobody quotes

MCP servers are stateful async processes, not stateless APIs. Here are the real cost drivers, failure modes, and how to measure them yourself.

16 min read · 5 August 2026

Built a multi-agent system without LangGraph

Build a multi-agent research pipeline with Redis Streams, Step Functions retries and FastAPI, plus the failure modes that matter and how to measure them.

13 min read · 27 July 2026

Edge agents vs cloud round-trips in 2026

A practical guide to building on-device agents with ONNX Runtime, Redis caching, confidence-based cloud fallback, and honest ways to measure latency and memory.

11 min read · 23 July 2026

Purpose-built beats general AI tools

When a general AI platform beats a purpose-built stack, how to choose, and how to measure latency, cost and fallback behaviour yourself.

16 min read · 19 July 2026

Observability for Long-Running LLM Agent Workflows

Design an observability stack for agentic LLM workloads: millisecond event timestamps, queue-depth metrics, and bounded buffering that survives outages.

14 min read · 17 July 2026

Build agent workflows that survive restarts

How to build agent task pipelines that resume after crashes, schema drift and model changes, using Redis streams, idempotent steps and replay.

12 min read · 6 July 2026

AI model poisoning: 3 real attacks on datasets

How data, model, and dependency poisoning enter AI pipelines, plus concrete controls for provenance, review, sandboxing, and rollback.

15 min read · 4 July 2026

Evaluate agents with Spark vs custom harness

A practical comparison of Spark-based and custom Python agent evaluation harnesses, with failure modes, cost arithmetic, and a decision checklist.

12 min read · 3 July 2026

AI agents: circuit breakers are not optional

AI agents fail by hanging and returning plausible garbage, not by crashing. Here is how to add a circuit breaker that catches semantic failures.

13 min read · 3 July 2026

AI Code Generation: Failure Modes and Guardrails

AI code assistants change interfaces, concurrency and state in ways that pass review. Here are the failure modes and the checks that catch them.

11 min read · 3 July 2026

CI/CD for Django in 20ms Africa networks

Design a Django CI/CD pipeline for 1-2 vCPU runners, slow links and metered egress: caching, image size, migrations and health checks.

13 min read · 3 July 2026

JSON mode's hidden costs revealed

LLM JSON mode guarantees syntax, not usable data. A two-stage extraction-plus-correction pipeline makes parsing reliable and cheap without fine-tuning.

12 min read · 3 July 2026

Keeping AI-Generated Code from Rotting Your Repository

How to detect and contain AI-generated code debt with linters, review gates, and measurement instead of expensive governance platforms.

12 min read · 3 July 2026

Meter dev-tool pricing in 2026

Build usage-metered pricing for a dev tool: Stripe metered billing, Redis counters, idempotent usage events, and the edge cases that break first.

11 min read · 2 July 2026

AI wrote the docs — humans wrote the gaps

AI generates API reference docs well but omits rate limits, deprecations and retry rules. A pattern for keeping human-written edge cases in sync with code.

13 min read · 1 July 2026

Tame Python async’s hidden traps

Compare threaded and task-based async in Python: how each works, where each fails, how to measure the tradeoff yourself, and a checklist for choosing.

11 min read · 29 June 2026

Price AI-proof skills in 2026

How to build an auditable compensation evidence pack that separates human-only work from AI-assisted output, with reproducible tooling and a negotiation script.

14 min read · 29 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

Negotiate salaries with AI skills in 2026

A practical method for quantifying which parts of a job AI can automate, building a defensible salary anchor, and handling pushback in negotiation.

11 min read · 27 June 2026

AI fixes legacy code nobody owns

How to combine static analysis, runtime traces, and LLM contextualization to make unowned legacy systems legible, with code and failure modes.

19 min read · 27 June 2026

Negotiate pay in 2026 with AI proof points

A repeatable method for turning Git history into reviewable evidence of human-owned engineering work, plus how to measure it honestly.

11 min read · 25 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

CI/CD for AI code: test, secure, rollback fast

A CI/CD pattern for AI-assisted code changes: deterministic locks, prompt-injection checks, smoke tests, metrics gates, and blue-green rollback.

13 min read · 23 June 2026

Unlock Python 3.13's free-threaded GIL for web apps

Free-threaded Python removes the GIL, but C extensions, shared state and pools break. A practical checklist for migrating a web service safely.

14 min read · 22 June 2026

Vibe code: works great, fails forever

Ten failure modes that make vibe-coded MVPs unmaintainable, with code fixes, measurement recipes, and a hardening checklist for each.

13 min read · 20 June 2026

Serverless Cold Starts: Cost Levers and How to Measure Them

Cold starts are a cost and consistency problem, not just latency. Learn how to measure latency-per-dollar and tune concurrency, memory, and architecture.

12 min read · 20 June 2026

Use feature flags to deploy AI models safely

Use feature flags to canary, shadow and roll back AI model changes without redeploys, with code, metrics and failure-mode handling.

15 min read · 20 June 2026

Tiered API abuse defense: match cost to attacker economics

Five API abuse patterns that inflate cloud bills, why edge-only blocking fails, and how to build tiered defenses with measurable cost-per-request targets.

11 min read · 20 June 2026

Rebalance pay when AI fills half your role

Measure AI's share of your codebase, then renegotiate scope, level, and pay with evidence instead of anecdotes or cost-of-living framing.

13 min read · 15 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

AI Static Analysis vs Rule-Based SAST: A Practical Comparison

How AI-assisted static analysis compares with rule-based SAST on scan latency, false negatives, cost, and ops, plus how to measure both on your own repos.

14 min read · 13 June 2026

Designing an AI Alert Triage Layer That Reduces Pages

How to build an AI alert-triage service between Alertmanager and your pager: fingerprinting, LLM filtering, fail-open rules, and honest measurement.

14 min read · 12 June 2026

AI interviews now ask for this

AI-assisted coding has changed what engineering interviews probe: flaky tests, observability overhead, secret rotation, and auditing generated code.

16 min read · 10 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

Price your remote job like a New York dev

A worked method for turning a target take-home figure into a defensible hourly rate for US clients, including FX handling, tax and VAT lines, and quote logging.

13 min read · 8 June 2026