# Performance Antipatterns: Common Design Mistakes That Slow Systems Under Load

> A field guide to common mistakes that pass a demo but fail under real traffic, how to spot each by its symptoms, and how to measure before you fix.

**In short:** Performance antipatterns are common design mistakes that pass a demo but slow a system under real traffic, so measure before you fix them.

From "System design", a free course by Venkat R. Murty: https://designervenkat.online/learn/system-design/performance-antipatterns

## What You Will Learn

Some designs work well in a test. You try them with one user, the page loads fast, and the team ships. Then real traffic arrives. Pages crawl, servers run hot, and some requests time out. This lesson names the common mistakes behind many of these failures. Each one is called an antipattern, and each has symptoms you can learn to recognize.

By the end, you will be able to group the named antipatterns by where the waste happens, match each one to its symptoms, and follow a simple loop for fixing them: measure, find the bottleneck, change one thing, and measure again.

- **Antipattern:** A common design or coding habit that seems sensible at first but causes trouble as load grows.
- **Symptom:** A visible sign of a problem, such as slow responses, errors, or a rising bill.
- **Latency:** The time one request takes, from the moment it starts until the reply arrives.
- **Throughput:** How much work a system finishes in a set amount of time.
- **Round trip:** One request sent over the network and one reply sent back.
- **Bottleneck:** The one step that limits the whole system, like a narrow pipe in a long line of pipes.
- **I/O:** Input and output: reading or writing data to a disk, a database, or another machine over a network.
- **Thread:** A worker inside a program that carries out tasks. A server often runs many threads at once.
- **Tenant:** One customer or group that shares a system with other customers.
- **Load:** The amount of work arriving at a system in a given time.

## What Is an Antipattern?

A design pattern is a good, repeatable answer to a common problem. An antipattern is the opposite: a repeatable answer that looks good at first and then hurts. Antipatterns often start as reasonable designs. They pass tests because tests use few users, small data, and a quiet network. Under real load, the same design starts to cost time, memory, money, or stability.

This is what separates an antipattern from a one-off bug. A bug is a mistake in one place that you fix once. An antipattern is a habit that shows up again and again, because the choice feels natural. A new feature copies it, another team copies it, and soon it is everywhere in the product.

You usually notice an antipattern by its symptoms, not by reading its code. The sections below list the signs to watch for when load goes up.

> **Tip:** Do not wait for an outage to look for these problems. Ask how each part of the system behaves when ten times more people use it, and where its work goes.

Microsoft's Azure Architecture Center publishes a catalog of ten named performance antipatterns, based on problems its customers saw in production. This lesson uses that catalog as its guide.

### How Do You Spot the Symptoms?

Most antipatterns show up in a few familiar ways. Learn these signs first, because they point you toward the right group of causes.

- **Rising latency:** Response times grow as traffic grows, even though the work for each request stays the same.
- **High CPU or I/O:** Servers or the database stay busy, or disks and network links sit near their limits, while little useful work gets done.
- **Timeouts:** Calls give up before a reply arrives, so users see errors or screens that never finish loading.
- **Cost spikes:** The bill jumps during busy hours because the system does far more work than the users actually need.

## Where Does the Waste Happen?

The easiest way to learn the named antipatterns is to group them by where the waste occurs. Some waste time on data access. Some waste processing power and threads. Some waste shared resources or make failures worse. Each card below gives a one-line definition and the symptom to look for.

### Data Access Waste

Reading and writing data is often the slowest step in a request. These five antipatterns waste that step.

- **Busy Database:** Offloading too much processing to the database, so it spends its time running logic instead of answering requests. Symptom: throughput falls and even simple database operations slow down.
- **Chatty I/O:** Sending many small network requests where a few larger ones would do. Symptom: high latency and low throughput, because every round trip adds delay.
- **Extraneous Fetching:** Retrieving more data than an operation needs. Symptom: heavy I/O, slow responses, and growing contention on the data store.
- **Monolithic Persistence:** Keeping data with very different usage patterns in one shared data store. Symptom: one kind of load slows down another, because they compete for the same store.
- **No Caching:** Fetching the same unchanged data again and again instead of keeping a nearby copy. Symptom: the same expensive reads repeat on every request, and costs climb with traffic.

Chatty I/O and Extraneous Fetching often appear together. A team that fixes many small calls by asking for everything in one big call may swap one problem for the other. Watch both.

### Compute and Thread Waste

These antipatterns waste the program's own processing power and its worker threads.

- **Busy Front End:** Doing heavy work on the threads that answer user requests, instead of handing that work to background workers. Symptom: pages slow down for everyone while a few heavy tasks run.
- **Synchronous I/O:** Blocking the calling thread while a read or write finishes, so the thread sits idle and cannot serve other work. Symptom: each server handles fewer requests, and capacity runs out early.
- **Improper Instantiation:** Creating and destroying objects again and again when they were meant to be shared and reused, such as clients or connections. Symptom: extra CPU use and slower requests, because the same setup work repeats on every call.

### Shared Resource and Failure Waste

The last two antipatterns involve other users of the same system, and how clients react when something goes wrong.

- **Noisy Neighbor:** One tenant uses a disproportionate share of a shared resource, so the other tenants slow down. Symptom: some customers complain of slowness while the system overall looks healthy.
- **Retry Storm:** Clients retry failed requests to a server too often or too quickly. Symptom: a flood of repeated attempts from the same clients, and recovery stalls even after the original fault is fixed.

## Worked Example: The Slow Order History Screen

Take an online shop. Its order history screen lists past orders, and each order shows the items bought. The page loads slowly, and it gets worse on busy days. Here is how to read the problem step by step.

1. **Measure the page:** Time the request on the server and count the database calls it makes. The server runs one query for the list of orders, then one more query for each order's items. With 50 orders, one page means 51 queries.
2. **Name the antipatterns:** Many small calls in a row is Chatty I/O. The query also selects every column, including a large receipt field the screen never shows. That is Extraneous Fetching. Over-fetching often appears as a side effect of trying to fix Chatty I/O.
3. **Change one thing:** Replace the per-order calls with one joined query that returns only the fields the screen displays. The database is now asked once, and the receipt field is left out.
4. **Measure again:** Run the same test under the same load. The page now makes 1 round trip instead of 51, and it reads far less data. Check that the screen still shows the right orders and items.

The sample below simulates this with an in-memory database, so it runs anywhere. It counts the queries that the slow version and the fast version send.

```python
import sqlite3

db = sqlite3.connect(':memory:')
db.execute('CREATE TABLE orders (id INTEGER, total INTEGER, receipt TEXT)')
db.execute('CREATE TABLE items (order_id INTEGER, name TEXT)')
for i in range(1, 51):
    db.execute('INSERT INTO orders VALUES (?, ?, ?)', (i, i * 10, 'big ' * 200))
    db.execute('INSERT INTO items VALUES (?, ?)', (i, 'item-' + str(i)))

count = 0

def run(sql, args=()):
    global count
    count += 1
    return db.execute(sql, args).fetchall()

# Slow way: one query for the list, then one query per order
orders = run('SELECT * FROM orders')
for row in orders:
    run('SELECT name FROM items WHERE order_id = ?', (row[0],))
print('slow round trips:', count)
print('receipt characters read:', sum(len(r[2]) for r in orders))

# Fast way: one joined query for only the displayed fields
count = 0
rows = run('SELECT o.id, o.total, i.name FROM orders o JOIN items i ON i.order_id = o.id')
print('fast round trips:', count)
print('rows returned:', len(rows))

```

Output:

```text
slow round trips: 51
receipt characters read: 40000
fast round trips: 1
rows returned: 50

```

The numbers here are small on purpose. On a real network, every round trip adds delay, so removing 50 of them saves far more time than it saves on this laptop.

> **Tip:** Ask the database only for what the page shows. Pick the columns you need, and let the database do the joining in one request rather than many.

## How Do You Diagnose and Fix Them?

Antipatterns are easy to guess at and easy to get wrong. A team might add servers when the real problem is one repeated query, or rewrite code that was never slow. A simple loop prevents most of these mistakes.

1. **Measure first:** Collect timings and counts for the slow path before you change anything. Record latency, throughput, and how busy the CPU, the disks, and the database are.
2. **Find the bottleneck:** Find the single step that takes the most time or the most resources. Ask whether the database does real data work, whether there are many small calls, or whether threads sit waiting on I/O.
3. **Change one thing:** Apply the remedy for the antipattern you matched. If you change five things at once, you will not know which one helped, or which one made things worse.
4. **Measure again:** Compare the new numbers with the old ones under the same load. Keep the change only if the numbers improve.

Azure's guidance also warns that a lab test cannot fully copy real users and their habits. Tests are still needed for a baseline, but production monitoring, instrumentation, and logs are what reveal the root cause.

> **Tip:** Before you change anything, write down the one number you expect to move, such as database calls per page. If that number does not move after the change, your guess was wrong.

Imagine a team that sees slow pages and decides the servers are too small. They buy more machines. Each machine still runs the same 51 queries, so the database becomes the limit and the bill rises. The real bottleneck was the query pattern, and more servers could not fix it.

### Which Remedy Matches Each Antipattern?

Each antipattern has a typical first fix. Treat these as starting points to test, not as rules to apply without measuring. The detailed build-out of each fix belongs to other lessons.

- **Data access fixes:** For Busy Database, move some logic back into the application when the database is only being asked to process data. For Chatty I/O, batch calls into fewer requests. For Extraneous Fetching, select only the columns and rows the operation uses. For Monolithic Persistence, give each kind of data a store that fits its usage. For No Caching, keep a copy of repeated reads, which later lessons explain.
- **Compute and thread fixes:** For Busy Front End, move heavy work to background workers. For Synchronous I/O, go async so the thread can serve other requests while the read or write finishes. For Improper Instantiation, create shared objects such as clients once and reuse them.
- **Shared and failure fixes:** For Noisy Neighbor, limit how much any one tenant can take from shared resources. For Retry Storm, add exponential backoff, which means waiting longer after each failed attempt.

### Retry Backoff in Code

The sample below shows the wait schedule for exponential backoff with a cap. Each wait doubles until it reaches the cap, so the client stops hammering the server. This sample leaves out random jitter to stay simple and repeatable. Retries in real systems need more care, and that design is covered in another lesson.

```python
base_seconds = 1
cap_seconds = 8
for attempt in range(1, 6):
    delay = min(cap_seconds, base_seconds * 2 ** (attempt - 1))
    print('attempt', attempt, 'waits', delay, 'seconds')

```

Output:

```text
attempt 1 waits 1 seconds
attempt 2 waits 2 seconds
attempt 3 waits 4 seconds
attempt 4 waits 8 seconds
attempt 5 waits 8 seconds

```

Waiting alone is not enough when a crowd of clients fails at the same moment. Without jitter, they all wait the same time and retry together, which recreates the spike.

## Check Your Understanding

Each question describes a new situation. Use the symptoms to pick the antipattern that fits best.

**Quick check:** A mobile app's login endpoint starts timing out during a sale. Each failed request is immediately retried by the clients, and traffic to the already struggling server triples. Which antipattern is this, and why does the retry behavior make the outage worse?

A. Chatty I/O, because the app sends many small login requests in a row
B. Retry Storm, because immediate retries add load to a server that is already struggling
C. No Caching, because the login data is fetched again on every attempt
D. Noisy Neighbor, because one tenant is using most of the server

**Answer:** B. This is a Retry Storm. Each immediate retry adds more requests to a server that cannot keep up, so the load grows just when the server most needs room to recover. Longer, spaced-out waits between attempts give it that room.

**Quick check:** A dashboard page asks the database for the latest value of each of 200 sensors, one call at a time. Load time is fine on a quiet day but reaches several seconds at peak. The app server's CPU is low, and most of the time is spent waiting on the database. Which antipattern fits best?

A. Busy Front End, because the page does heavy work on user threads
B. Chatty I/O, because the page makes hundreds of small database calls one after another
C. Improper Instantiation, because each call creates a new object
D. Monolithic Persistence, because sensor data and user data share one store

**Answer:** B. Low CPU and long waits on I/O point away from heavy processing. Many small calls, each adding its own delay, is the sign of Chatty I/O. Reading the values in one batched request removes most of those round trips.

**Quick check:** A team finds that its order page reads a large photo column for every order, although the page only shows the order number and the total. Which fix addresses the root problem best?

A. Add more app servers so each one can handle the large reads
B. Select only the order number and the total columns
C. Retry each failed read immediately with no delay
D. Move the page's sorting work into a background job

**Answer:** B. The waste is data the page never displays, which is Extraneous Fetching. Selecting only the needed columns removes the unneeded I/O. More servers would only spread the same waste across more machines.

## Key Takeaways

A performance antipattern is a tempting habit that works in a demo and fails under real load. Learn the symptoms first: rising latency, busy CPU or I/O, timeouts, and cost spikes. Group the named antipatterns by where the waste happens, and remember that each one has a usual remedy. Then measure, find the bottleneck, change one thing, and measure again. Later lessons teach how to build each remedy in detail.

## Sources

- [Azure Architecture Center: Performance testing and antipatterns for cloud applications](https://learn.microsoft.com/en-us/azure/architecture/antipatterns/)
- [Azure Architecture Center: Extraneous Fetching antipattern](https://learn.microsoft.com/en-us/azure/architecture/antipatterns/extraneous-fetching/)
- [Azure Architecture Center: No-Caching antipattern](https://learn.microsoft.com/en-us/azure/architecture/antipatterns/no-caching/)
- [Azure Architecture Center: Busy Database antipattern](https://learn.microsoft.com/en-us/azure/architecture/antipatterns/busy-database/)
- [Azure Architecture Center: Retry Storm antipattern](https://learn.microsoft.com/en-us/azure/architecture/antipatterns/retry-storm/)
- [Azure Architecture Center: Noisy Neighbor antipattern (source file)](https://github.com/microsoftdocs/architecture-center/blob/main/docs/antipatterns/noisy-neighbor/noisy-neighbor.yml)
- [Performance antipatterns for cloud applications (summary of the Azure catalog, including Chatty I/O and Synchronous I/O)](https://performancetestexpert.wordpress.com/2019/05/09/performance-antipatterns-for-cloud-applications/)
- [Let's cause scalability problem with performance antipatterns (catalog summary)](https://medium.com/@dmosyan/lets-cause-scalability-problem-with-performance-antipatterns-1d163d8a6065)
- [The Retry Storm, by Anas Issath (backoff and jitter)](https://thebackendtechlead.substack.com/p/the-retry-storm)
- [The Time Retries Turned Into a Retry Storm (engineering case study)](https://builder.aws.com/content/3JWBPBGTJTylB7LHAOIgsNxjvM6/the-time-retries-turned-into-a-retry-storm)
- [Explained Simply #33: Timeouts, retries and backoff](https://medium.com/@thinktaught/explained-simply-33-8d9dd41c52b7)
