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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Gate Releases on a Dependency License Allowlist
Inventory production dependency licenses, fail on copyleft licenses outside policy, and keep the report with every release.
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.
Assert Structured Logs in Tests
Capture log output in tests, assert required fields and redaction, and catch missing request context before production debugging does.
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.
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.
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.
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.
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.
Drain a Node Without Dropping Requests
Cordon first, drain with explicit flags, respect disruption budgets, and verify workloads moved before terminating the node.
Escalate Unacknowledged Alerts Automatically
Configure Alertmanager grouping and repeat intervals plus a two-tier escalation path, so a missed page reaches someone awake.
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.
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.
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.
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.
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.
Scan Databases for Unlabeled PII
Sample column values, run Presidio analyzers, and produce a report of likely personal data that lacks classification tags.
Protect Availability with a PodDisruptionBudget
Set minAvailable for critical deployments and verify that node drains respect the budget instead of evicting every replica.