Recipes

Step-by-step solutions for real development tasks.

699 published

Page 17 of 20

Release Behind a Flag and Remove It on Schedule

Ship dark, enable for a small percentage, watch metrics, and delete the flag within a fixed window so branches do not accumulate.

~25 min
release · feature-flags · operations

Test Both Sides of a Feature Flag

Run the same behaviour tests with the flag on and off, assert the default and kill switch, and retire the flag when it expires.

~30 min
testing · feature-flags · release

Add Full-Text Search Without LIKE Scans

Build a generated tsvector column, index it with GIN, and query with websearch_to_tsquery and ranking instead of leading-wildcard LIKE.

~35 min
postgresql · search · indexes

Implement a GDPR Right-to-Erasure Deletion Job

Build an idempotent erasure job that deletes disposable personal data, anonymizes retained records, records a minimal audit tombstone, and verifies completion across tables.

~50 min
privacy · gdpr · postgresql

Fan Out CI with a GitHub Actions Matrix

Run the same job across supported runtimes in parallel, fail fast on the first broken combination, and keep one required status check.

~20 min
github-actions · ci · matrix

Add Golden File Tests for API Responses

Commit canonical API responses as golden files, review every diff in pull requests, and regenerate only through an explicit opt-in command.

~30 min
testing · regression · api

Add a gRPC Health Check Probe

Expose the standard grpc.health.v1 service, wire Kubernetes probes through grpc-health-probe, and flip to NOT_SERVING during shutdown.

~35 min
grpc · kubernetes · health-check

Lint and Render Helm Charts Before Every Release

Catch schema errors, missing values, and broken templates by linting and rendering every chart in CI before it reaches a cluster.

~25 min
helm · kubernetes · ci

Enable HTTP/2 on NGINX with ALPN

Serve an existing HTTPS virtual host over HTTP/2 by enabling ALPN, turning on the ngx_http_v2 module, and verifying the negotiated protocol with curl.

~25 min
nginx · http · performance

Review Terraform Plans Before Anyone Applies

Publish the plan as a reviewable artifact, require approval, and apply exactly that plan so the approved diff is what reaches the cloud.

~30 min
terraform · iac · review

Clean Up Expired Idempotency Keys

Partition idempotency records by day, drop old partitions on a schedule, and keep a retention window longer than the client retry horizon.

~35 min
postgresql · idempotency · maintenance

Test Idempotency Keys End to End

Replay the same request key and assert one side effect, an identical response, and a conflict when the payload changes.

~40 min
testing · idempotency · api

Fail the Pipeline on Fixable Image Vulnerabilities

Scan the built container image, ignore unfixed findings, and block promotion on high or critical vulnerabilities that already have a patch.

~25 min
security · containers · ci

Tune Ingress Timeouts for Slow Endpoints

Raise proxy read and send timeouts only for routes that need them, and keep the default short everywhere else.

~25 min
kubernetes · ingress · timeouts

Terminate TLS at the Ingress with cert-manager

Request a certificate through an ACME issuer, store it in a Secret, and redirect every plain HTTP request to HTTPS.

~30 min
tls · kubernetes · ingress

Index JSONB Attributes for Containment Queries

Add a GIN index on JSONB attributes, query with containment operators, and confirm the planner uses the index instead of scanning.

~30 min
postgresql · jsonb · indexes

Tune a HorizontalPodAutoscaler for Stable Scaling

Set behavior policies, a sensible utilization target, and a floor that survives bursty traffic instead of flapping between replica counts.

~30 min
kubernetes · autoscaling · capacity

Spread Replicas Across Zones with Topology Constraints

Use topologySpreadConstraints with DoNotSchedule so one zone failure cannot take every replica, then verify the spread on real pods.

~30 min
kubernetes · scheduling · availability

Layer Environment Differences with Kustomize Overlays

Keep one shared base manifest and a thin overlay per environment, so staging and production differ only where they must.

~30 min
kubernetes · kustomize · deployment

Gate Releases on a Dependency License Allowlist

Inventory production dependency licenses, fail on copyleft licenses outside policy, and keep the report with every release.

~20 min
licensing · compliance · ci

Write a Realistic Load Test Scenario

Model arrival rate, ramp-up, and think time in k6, assert p95 latency and error thresholds, and run it against staging before release.

~40 min
testing · performance · k6

Assert Structured Logs in Tests

Capture log output in tests, assert required fields and redaction, and catch missing request context before production debugging does.

~25 min
testing · logging · observability

Test That Logs Redact Sensitive Fields

Add an automated test that captures structured log output and fails if emails, tokens, or card numbers appear in plain text.

~30 min
logging · privacy · testing

Sample High-Volume Info Logs Without Losing Errors

Reduce log volume and cost by sampling info-level events deterministically per request while keeping warnings, errors, and slow requests at full fidelity.

~30 min
logging · observability · cost

Bound Lock Waits in Schema Migrations

Set lock_timeout and statement_timeout inside migrations so DDL fails fast instead of queueing behind a long query and freezing reads.

~30 min
postgresql · migrations · locking

Test Migration Rollbacks in CI

Apply, roll back, and re-apply every migration against a throwaway database, and fail the build when the down path breaks or drifts.

~35 min
database · migrations · ci

Add Mutation Testing to Critical Modules

Run Stryker on money and authorization code, set a mutation score threshold, and strengthen tests for the mutants that survive.

~40 min
testing · quality · ci

Drain a Node Without Dropping Requests

Cordon first, drain with explicit flags, respect disruption budgets, and verify workloads moved before terminating the node.

~25 min
kubernetes · maintenance · availability

Escalate Unacknowledged Alerts Automatically

Configure Alertmanager grouping and repeat intervals plus a two-tier escalation path, so a missed page reaches someone awake.

~30 min
alerting · oncall · reliability

Standardize the On-Call Handoff

Run a 15-minute handoff that transfers open incidents, recent changes, and known risks with a written summary in the channel.

~15 min
on-call · operations · incident-response

Retry Outbound Webhooks with Bounded Exponential Backoff

Deliver outbound webhooks reliably with bounded exponential backoff, jitter, Retry-After handling, and a replayable failure store for terminal errors.

~40 min
webhooks · reliability · queues

Test Pagination at Its Boundaries

Cover empty results, exact page size, last page, invalid cursors, and tied sort keys so clients never loop or skip records.

~30 min
testing · pagination · api

Add a Partial Index for Active Rows

Index only the rows queries actually read, cutting index size and write cost for soft-deleted or status-filtered tables.

~30 min
postgresql · indexes · performance

Order Row Locks to Prevent Deadlocks

Acquire locks in one deterministic order across every writer, add a lock timeout, and prove with a concurrency test that 40P01 stops happening.

~25 min
postgresql · deadlocks · transactions

Scan Databases for Unlabeled PII

Sample column values, run Presidio analyzers, and produce a report of likely personal data that lacks classification tags.

~40 min
privacy · pii · data-governance

Protect Availability with a PodDisruptionBudget

Set minAvailable for critical deployments and verify that node drains respect the budget instead of evicting every replica.

~25 min
kubernetes · availability · operations