Recipes

Step-by-step solutions for real development tasks.

699 published

Page 4 of 20

Switch from Offset to Cursor Pagination

Use a cursor based on the last item's sort key so page 2 does not skip or duplicate items when new data arrives between requests.

~25 min
api · pagination · cursor

Shard Tests Across CI Runners for Speed

Split the test suite into N shards by historical duration so all runners finish at the same time instead of one straggler.

~25 min
testing · parallel · sharding

Partition a Large Table by Date for Pruning

Partition by month so a query on the last 30 days scans one partition not the entire years of history.

~30 min
database · partition · pruning

Hash Passwords with Argon2id Tuned Parameters

Use Argon2id with memory and iteration parameters tuned to the hardware so offline cracking takes years not hours.

~20 min
security · passwords · argon2

Guarantee Drain Safety with a Pod Disruption Budget

Set a Pod Disruption Budget so a voluntary drain like a node upgrade cannot evict the last replica and cause downtime.

~15 min
kubernetes · pdb · drain

Set Pipeline Artifact Retention by Type

Configure artifact retention rules so build outputs expire after 14 days but signed releases are kept for a year.

~15 min
ci · artifacts · governance

Use Restore Keys for Fallback Cache Matching

Configure cache restore keys so a partial key match still reuses a previous cache when the exact key misses.

~15 min
ci · caching · fallback

Notify On-Call on Pipeline Failure with Context

Send a structured notification with the failing job, logs link, and last commit when a critical pipeline fails.

~15 min
ci · alerts · notifications

Route Jobs to Runners by Label

Assign runner labels so GPU jobs go to GPU runners and lint jobs go to the cheapest available runner.

~10 min
ci · runners · routing

Scan for Secrets Leaked in Pipeline Output

Add a secret scanning step that checks build logs and artifacts for leaked tokens before publishing.

~20 min
ci · security · secrets

Skip Heavy Jobs When Only Docs Changed

Use dorny paths-filter to detect doc-only changes and skip compilation and test jobs to save runner time.

~15 min
ci · optimization · paths

Set a Pipeline Timeout Budget per Stage

Configure per-job timeouts so a hung step fails fast instead of burning runner minutes for the default six hours.

~10 min
ci · optimization · timeouts

Enforce Pod Security Standards at Admission

Apply a restricted Pod Security Standard at the namespace level so privileged containers are rejected by the API server.

~20 min
kubernetes · security · psa

Spread Pods Across Zones with Topology Constraints

Add a topologySpreadConstraint so a zone failure takes down at most one replica not the whole deployment.

~20 min
kubernetes · topology · spread

Use a Blameless Postmortem Template for Incidents

Fill a structured template with timeline, root cause, impact, and action items so the postmortem focuses on systems not people.

~20 min
observability · incident · postmortem

Precompute Aggregates in a Materialized View

Store the daily sum in a materialized view refreshed nightly so the dashboard query reads one row instead of scanning a million.

~25 min
performance · database · precompute

Prefetch Route Data on Link Hover

Add a mouseenter listener that prefetches the next route's data so navigation feels instant on click.

~15 min
performance · frontend · prefetch

Automate Privacy Impact Assessment Checks

Run a data flow analysis so a new field that contains PII is flagged for review before it is added to the schema.

~25 min
security · privacy · compliance

Add Property-Based Testing with fast-check

Replace hand-written examples with property-based generators that explore the input space and shrink failures to a minimal counterexample.

~30 min
testing · property-based · fast-check

Detect N+1 Queries with an ORM Logger

Enable query logging in tests so a list endpoint that fires one query per item is visible in the log and fixed with a join.

~25 min
performance · database · n-plus-one

Analyze a Slow Query Plan with EXPLAIN

Run EXPLAIN ANALYZE on the slow query so the plan shows whether it is a sequential scan, a bad join, or missing index.

~20 min
database · query-plan · explain

Rate Limit with a Redis Token Bucket

Implement a token bucket in Redis so distributed rate limiting works across multiple instances with atomic decrements.

~25 min
security · rate-limit · redis

Pool Database Connections with RDS Proxy

Put an RDS Proxy between Lambda and the database so connection opens are pooled and a Lambda spike does not exhaust DB connections.

~25 min
cloud · rds · proxy

Guarantee Read-After-Write Consistency

Route reads from the same session to the primary or use a causal token so a user sees their own write immediately.

~25 min
database · consistency · read-write

Route Reads to a Replica and Writes to Primary

Split the connection so read-heavy endpoints hit the replica and the primary is reserved for writes, cutting read latency by half.

~20 min
performance · database · replica

Respect prefers-reduced-motion for Animations

Disable or shorten animations when the user sets reduce-motion so vestibular sensitivity is respected not ignored.

~10 min
frontend · accessibility · motion

Monitor Replication Lag and Alert on Threshold

Query the replication lag and alert when it exceeds 5 seconds so a stale read replica does not serve outdated data.

~20 min
database · replication · lag

Require Status Checks Before Merge with Strict Mode

Enable branch protection with strict status checks so a pull request cannot merge if any required check is pending or failing.

~15 min
ci · github · branch-protection

Rightsize Resource Requests from Metrics

Read the 95th percentile CPU and memory from metrics and set requests to p95 so pods are not throttled or over-provisioned.

~25 min
kubernetes · resources · rightsize

Serve Responsive Images with srcset Sizes

Provide srcset with 480, 800, and 1200 widths so the browser downloads the smallest image that fills the viewport.

~15 min
frontend · images · responsive

Retry with Exponential Backoff and Full Jitter

Add full jitter to the backoff so retries spread across time and do not synchronize into a retry storm on recovery.

~15 min
api · retry · backoff

Compose Reusable Workflows to Share CI Logic

Extract repeated CI steps into a reusable workflow so consumer repos call it with one line instead of duplicating YAML.

~20 min
ci · reusable · dry-run

Tune Rolling Update Max Surge for Capacity

Set maxSurge to 1 and maxUnavailable to 0 so updates add a new pod before removing an old one and capacity never drops.

~15 min
kubernetes · rolling-update · deploy

Show Route Transitions with Suspense Boundaries

Wrap each route in a Suspense boundary with a fallback spinner so navigation shows a skeleton instead of a blank flash.

~15 min
frontend · react · suspense

Fail Over DNS with Route53 Health Checks

Configure a health check on the primary and a failover record so traffic routes to the standby within 30 seconds of failure.

~20 min
cloud · route53 · failover

Tier S3 Objects with Lifecycle Rules

Transition objects to Infrequent Access after 30 days and Glacier after 90 so storage costs drop without deleting data.

~15 min
cloud · s3 · lifecycle