# Performance and Reliability

> We find what makes a system slow or fragile, fix it at the cause, and prove the fix on the live system. For services, queues, databases and Kubernetes clusters under real load.

Page: https://www.leafcompute.com/services/distributed-systems

## Slow or fragile systems have a cause

When a product slows down or falls over under load, the cause is usually specific: a query that scans too much, a dependency that times out and gets retried by everyone at once, a queue that grows faster than it drains, or a platform limit nobody knew was there. Adding servers hides it for a while and raises the bill.

We find the cause, fix it there, and show the result on the live system.

## What we work on

- **Slow databases.** Query plans, indexes, connection pooling, locks and write volume. We have moved a 491 GB PostgreSQL database with 248.7 million rows in its largest table off Aurora Serverless, and it now takes 2,818 commits a second.
- **Failure handling.** Timeouts, retries and circuit breakers designed together, so a slow dependency doesn't turn into a retry storm.
- **Queues and background jobs.** Idempotent jobs, back-pressure and dead-letter handling, so work is done once and failures are visible quickly.
- **Data that stays consistent.** Transactions, locks and idempotency chosen for the access pattern, not by habit.
- **Scaling without surprises.** Autoscaling tuned from measured load, with limits that protect the rest of the system.
- **Kubernetes under load.** Scheduling, bin packing, node provisioning and scale-down, so the cluster grows when it must and shrinks when it can.

## Where we've done it

All of these are from the [Olostep case study](/case-studies/olostep), a platform serving 18 to 25 million API requests a day:

- **A retry storm.** We traced a feedback loop that had pushed one engine from 1 million to 8.4 million jobs a day, and stopped it.
- **A cluster stuck at 256 nodes.** The auto-provisioner was running out of pod IP addresses. After the fix the cluster went from 47 to 283 nodes, and the browser fleet later reached 703 nodes at peak.
- **Bursts.** One engine scales from 5 to 1,850 pods inside a single burst.
- **Failures reported in seconds.** Failed jobs used to surface after an 8-minute timeout. They now report in seconds, checked in production with 191 of 191 reports accepted.
- **A faster hot path.** A URL resolver rewritten in Rust handles 700,000 URLs a minute on one 4-vCPU node in load tests, with about 150 times less CPU per lookup than the old path. It is built and tested, and most traffic is not routed to it yet.

On [CU Rewards](/case-studies/curewards), a platform behind 60+ credit-union storefronts, search performance went from 70% to 90%.

## How we work

1. **Measure.** Read what the system already reports, add what is missing, and reproduce the problem.
2. **Diagnose.** Follow one slow request or failed job end to end until the cause is clear, and write it down with the evidence.
3. **Fix in small steps.** Each change has a way back and is checked against the live system before and after.
4. **Keep it fixed.** Alerts on the signal that mattered, a load test where it is worth it, and notes your team can use next time.

## Engineering notes

How we think about this work, in detail: [circuit breakers in production](/blog/circuit-breakers), [choosing the right lock](/blog/choosing-the-right-lock), [message queue patterns for reliable delivery](/blog/message-queue-patterns), [PostgreSQL query optimization](/blog/postgresql-optimization) and [how high cardinality hurts Prometheus](/blog/how-high-cardinality-hurts-prometheus).

## How it starts

A short architecture review of the part that worries you most, with a written plan and the cost of each step.

## Common questions

### How do you find the cause of a slow system?

By measuring before changing anything. We read the metrics, traces and logs you already have, add what is missing, and follow one slow request or one failed job end to end. The output is a short written diagnosis with the evidence, not a list of general best practices.

### Can you work on a system that is live and under load?

Yes, that is the usual case. Changes go out in small steps with a way back, and each one is checked against the live system before and after. On one platform we caught an infrastructure change that would have destroyed live capacity before it was applied.

### What kinds of systems do you work on?

Distributed back ends built from services, queues and databases, most often on Kubernetes. Recent work covers PostgreSQL, Google Kubernetes Engine, AWS, Pub/Sub and SQS queues, and browser and AI workloads that burst hard.

### Do we need a rewrite to fix performance?

Rarely. Most problems come from a few places such as a query, a retry policy, a limit nobody knew about or an autoscaling rule. We fix those first. If a part does need rebuilding, we say which part and why.

### How does an engagement start?

With a short review of the part that worries you most. You get a written plan with the cause, the fix and the cost of each step, and you decide what to do next.

---
Leaf Compute: https://www.leafcompute.com · hello@leafcompute.com
