Skip to content

ADR: Memory follows traffic

ADR: Memory follows traffic

Status
accepted
Date
2026-10-18

An Admin card, Memory against traffic, plots the process's processor and memory against requests a minute over the tab's window, and reads red when memory keeps climbing while traffic is flat: a leak or a cache with no bound. Run over the readings the site kept, it reads red the week the hundred thousand vehicles moved into each process, ten days before the plan card found them.

Reading list

For Steve, when he is fresh, in this order:

  1. The card itself, Memory against traffic, on the 30-day window.
  2. ADR: The store does the work: the incident this card would have caught, and what fixed it.
  3. Memory, held by the build, rule b: every cache bounded, because an unbounded one is the shape this card looks for.
  4. Microsoft Learn, Fundamentals of garbage collection: why a working set rises and falls under load and a leak only rises.

In plain words

A web server's processor should be busier when more people use it and quieter when fewer do. Its memory should mostly stay put: a server that needs more memory every hour, whether or not anyone is visiting, is keeping something it should have let go. This card draws both against the traffic, so the healthy shape and the broken one can be told apart at a glance, and it says so in words when the broken one shows.

What that is worth: the catalogue held in memory passed every test for weeks, because tests check what code was asked to do, not what it keeps. This card checks what it keeps.

Context

Steve asked on 18 October for a card plotting processor and memory against requests a minute, an alert when memory keeps climbing while traffic is flat, and the note that it would have flagged the catalogue issue. The readings already existed: every site folds each finished minute into the machines history, with its working set, its processor and the requests it answered (ADR: What the machines are doing), kept 31 days in Cosmos DB and read back a day, a week or a month at a time. Nothing new is measured for this card.

The kept readings show both shapes. From 24 to 26 September a load test lifted the traffic forty times; the working set went from about 110 MB to about 340 and came back to about 140 when it stopped, and the processor followed the requests with a correlation of 0.75. From 6 to 11 October the working set went from about 400 MB to about 650 on the 8th and stayed there, while the traffic fell back to a few hundred requests in four hours. That second shape is the catalogue in memory.

Decision

The rule, in the server. MemoryTraffic.Judge in Application splits the window in two by time. Memory is climbing when the second half's middle working set is at least 50 MB, or 5 per cent of the memory limit, whichever is more, above the first half's, and the least-squares line through every point slopes up. Traffic is flat when the second half's middle requests a minute is no more than a quarter above the first half's, plus one. Both at once is red. Middles rather than averages, so one busy minute or one collection does not decide a window. Memory that rose as traffic rose is green and says it is worth watching. Fewer than six readings is not judged.

/// <summary>
/// The window split in two by time. Memory is climbing when the second half's middle working
/// set is at least the threshold above the first half's and the line through every point
/// slopes up; traffic is flat when the second half's middle requests a minute is at most a
/// quarter above the first half's, plus one request. Both at once is red. Middles rather than
/// averages, so one busy minute or one collection does not decide the window.
/// </summary>
public static MemoryTrafficVerdict Judge(IReadOnlyList<TrafficPoint> points, double memoryLimitMb)
{
    double threshold = Math.Max(50, memoryLimitMb * 0.05);
    var ordered = points.OrderBy(point => point.At).ToList();
    if (ordered.Count < FewestPoints)
    {
        return new MemoryTrafficVerdict(PlanTone.Info, $"Not judged yet: {ordered.Count} of the {FewestPoints} readings a window needs.", 0, 0, 0, 0, threshold, null, null);
    }

    var first = ordered.Take(ordered.Count / 2).ToList();
    var second = ordered.Skip(ordered.Count / 2).ToList();
    double memoryFrom = Middle(first.Select(point => point.WorkingSetMb));
    double memoryTo = Middle(second.Select(point => point.WorkingSetMb));
    double requestsFrom = Middle(first.Select(point => point.RequestsPerMinute));
    double requestsTo = Middle(second.Select(point => point.RequestsPerMinute));
    bool climbing = memoryTo - memoryFrom >= threshold && Slope(ordered) > 0;
    bool flat = requestsTo <= requestsFrom * (1 + FlatTrafficRise) + 1;

    var withCpu = ordered.Where(point => point.CpuPercent is not null).ToList();
    double? cpu = Correlation(withCpu.Select(point => point.RequestsPerMinute).ToList(), withCpu.Select(point => point.CpuPercent!.Value).ToList());
    double? memory = Correlation(ordered.Select(point => point.RequestsPerMinute).ToList(), ordered.Select(point => point.WorkingSetMb).ToList());

    string from = $"{memoryFrom:N0} MB", to = $"{memoryTo:N0} MB";
    string traffic = $"{requestsFrom:N1} to {requestsTo:N1} requests a minute";
    var (tone, words) = (climbing, flat) switch
    {
        (true, true) => (PlanTone.Alarm, $"Memory climbed from {from} to {to} while traffic stayed flat ({traffic}): a leak or a cache with no bound."),
        (true, false) => (PlanTone.Good, $"Memory rose from {from} to {to} as traffic rose ({traffic}), and is worth watching if it does not come down with it."),
        _ => (PlanTone.Good, $"Memory held at about {to} ({from} in the first half) while traffic went {traffic}."),
    };
    return new MemoryTrafficVerdict(tone, words, Math.Round(memoryFrom, 1), Math.Round(memoryTo, 1), Math.Round(requestsFrom, 2), Math.Round(requestsTo, 2), threshold, Round(cpu), Round(memory));
}

Live from api/TheYard.Application/Features/Admin/Operations/MemoryTraffic.cs, region rule, read from this build at 99df7a8.

Deploys are not leaks. The last hour is this process's own, a minute at a time, and leaves out its first fifteen minutes, when the runtime, the caches and a fill grow memory for reasons that are not a leak. Steve's rule for the plan's alerts holds here too: a deployment moves the numbers, so a reading has to hold before it means anything. A wider window is the kept buckets, judged on middles, so a roll's dip and climb does not decide it.

One route, one card. GET /api/admin/follows?window= answers the window's points and the verdict; the card under Cloud infrastructure, after the machines, draws the two scatter plots and the straight line through each, with the finding in one sentence on the tone every Cloud card uses. The alert is the card's red for now; the email the observability lane adds reads the same rule.

Held to the real readings. MemoryTrafficTests carries both weeks above as the site kept them and holds the rule to red on the catalogue week and green on the busy one, with the processor following the traffic.

/// <summary>The card would have flagged the catalogue in each process (ADR-101) the week it arrived: memory climbed while traffic fell.</summary>
[Fact]
public void The_week_the_catalogue_moved_into_the_process_reads_red()
{
    var verdict = MemoryTraffic.Judge(Points(CatalogueWeek), LimitThen);

    Assert.Equal(PlanTone.Alarm, verdict.Tone);
    Assert.True(verdict.MemoryToMb - verdict.MemoryFromMb >= verdict.ClimbThresholdMb);
    Assert.True(verdict.RequestsTo <= verdict.RequestsFrom);
    Assert.Contains("a leak or a cache with no bound", verdict.Words, StringComparison.Ordinal);
}

Live from api/TheYard.Tests/MemoryTrafficTests.cs, region catalogue-week, read from this build at 99df7a8.

Consequences

  • The catalogue incident is now a test: a change that brought back a process-held copy of the store would read red on this card within the window it climbed in.
  • The rule reads the process's working set, which the runtime grows ahead of need and gives back late; a climb of under 50 MB is not called a climb, so ordinary collector behaviour is not an alarm.
  • A slow leak inside a busy day, where traffic also rose, reads green and "worth watching". That is the cost of not calling every busy afternoon a leak; the 30-day window, where the busy days average out, is the one to read for a slow one.

Where it sits

The rule in TheYard.Application, pure arithmetic over points with no clock and no store. The route in the host's admin endpoints, reading the machines sampler, the request ring and the kept history the machines card already reads. The card in src/components/admin/FollowsCard, its placing of points in src/lib/follows.ts.

Files

Addendum, 2026-10-28 (1.0.4.112): the card draws in the shell's shape

The card drew one column: the words, the window buttons, the verdict, the two plots and the readout's lines under them. From this version it draws in the shape every card under Cloud infrastructure shares (ADR: One frame for every resource, the addendum of 1.0.4.109), from the one shared sheet src/components/admin/shared/cardAreas.module.css (ADR: One plan, two sites, the addendum of 1.0.4.110, which says why a shared sheet): the words and the window buttons in the lead, the verdict with its tone and the five readout lines, the memory limit among them, in a readout beside it, and the two plots at the card's full width below, side by side where the width allows. The card has no dials: the wire gives points and a verdict, and a dial it drew for itself would be a figure the server did not give. Nothing the card reads or says changes: GET /api/admin/follows answers the same JSON, the verdict is the server's rule as before, every test id stays, and src/lib/follows.ts with its follows.test.ts is untouched. cloud.spec.ts holds the verdict beside the title at a desk's width, the plots at least as wide as the lead and the readout together, and no sideways scroll at a phone's; red on the prior card, where the verdict sat under the title.

Addendum, 2026-11-19 (1.0.5.106): the month that was read whole

In plain words: the memory card was right to go red. The site's own month reads were drawing a sawtooth in its memory, and the fix is in the code, not in the card.

At 06:09 Central on 19 November the card read red: 556 to 685 MB in an hour at no traffic. The process was then seven hours old (it started with the roll at 05:26 UTC; there was no morning restart), so this was not warm-up. Read a minute at a time, memory went from 545 MB to as much as 1,039 MB about every five minutes, and the managed heap reached 799 MB of its 986 MB hard limit. Cosmos DB charged 7,900 to 9,500 RU a minute on the plan container at the same minutes.

The cause: every card's thirty-day month was the store's five-minute GROUP BY over the whole month, read whole every ten minutes and once more for each window being kept that minute (eight at once for the plan card at 12:22 UTC). Each read built and dropped 150 to 450 MB.

From this version the month is kept in memory (MonthKeep). The first read takes the month. Every later read takes only the buckets from the newest one held, which is read again whole because it may have been partial. The month is trimmed at thirty days, and callers that arrive during a read wait on that one read. The card's rule is unchanged: it measured the right thing. The proof is two idle hours after the roll with the five-minute peaks gone. MonthKeepTests holds the month, the shared read, a caller that gives up and a read that fails.

Enforced by

2 rules in the rulebook cite this record, each held by a test on every release.

The rule What holds it In the last gate
Memory that climbs while traffic is flat reads red on the Admin tab, and the week the catalogue moved into each process reads red on the readings the site kept MemoryTrafficTests 16 of 16 passed
Every Cloud card's thirty-day month is read whole once, then only from its newest bucket, trimmed at thirty days, with one read shared by every caller that arrives during it MonthKeepTests 8 of 8 passed
Store

The Yard, home

Steven StoutStaff .NET engineerRemote

Production .NET that stays up. Built with AI, measured on every version.

Steven Stout

Hi, I'm Steve. I build the systems that make delivery boring in the best way, then coach people inside them.

  • 200+

    production releases, none took the platform down

    Conway Investment Research, 2019 to 2024. Sole engineer for the first three years on a live financial advisory platform.

    See how
  • 50%

    shorter release cycle

    Storee Construction, 2024 to 2026. Four ASP.NET applications onto one .NET 10 platform on Azure, with a four-person team I hired and mentored.

    See how

01Verified

Steven Stout

A real person, and the work is mine.

  • Identity

    Checked by LinkedIn, not by me.

    LinkedIn verified my government ID.

  • Running system

    You are looking at it.

    Version 1.0.5.273 is live. Nothing ships unless it passes the automated gates first.

That's who I am. Here's how I work.

02Strengths

Ten strengths, each with the proof beside it. The numbers match my resume and LinkedIn, and the live ones are read from this site as you look.

  • 01

    Keeps production alive

    200+ releases on a live financial platform, and none took it down. Sole engineer for the first three years.

    See the Conway work

  • 02

    Simplifies messy systems

    Four ASP.NET applications onto one .NET 10 platform on Azure, and a release cycle 50% shorter.

    See the Storee work

  • 03

    Marries dev and infrastructure

    Blue-green releases at Storee that flipped in about 5 seconds with nobody signed out, and Azure Front Door at two employers.

    See this site's cloud

  • 04

    Designs data that holds up

    White-label clients on one shared database, the isolation built into the data, and no cross-client issues.

    See the Conway work

  • 05

    Keeps AI-written code honest

    15 quality numbers that may only improve: 273 releases in a row with none worse.

    See the quality numbers

  • 06

    Resourceful

    $30,000+ cut from Azure and vendor spend at Conway. This site's Azure bill is public, resource by resource.

    See the bill

  • 07

    Builds people up

    Hired and mentored a four-person team. 13 colleagues recommend me by name.

    Read the recommendations

  • 08

    Takes ideas to production

    This site: designed, built and run solo, with 352 versions measured through one gate.

    How it was built

  • 09

    Writes clearly

    Posts on real engineering problems, in plain words.

    Read the blog

  • 10

    Owns decisions

    153 decision records, each with its tradeoff and the call I made.

    See the decision records

Built with AI. Gated so quality never slides.

Steven Stout’s showcase: a used-vehicle auction on .NET and React, built and run by one engineer, live on Azure, with its decisions written down.

No quality number has gotten worse at any release since 1.0.5.1 on 10 November: 273 releases in a row.

One engineer, an AI agent and a gate that checks 15 quality numbers on every release. 352 versions measured, with every result public, the worst days included.

82 releases in the last 7 days, each through the same gate.

Async methods with no CancellationToken, may only fall

11091.0.3.1391.0.5.2731.0.4.115, the ratchet
Every number, on the Quality page

TheYard, right nowLive

Answering in

unread

02505007501,000

server time at p95, the usual five minutes of the last day.

Azure this month

unread

the bill, by resource, read from Azure. The Admin tab shows every line.

Since the last roll

unread

 

rolled in place by the pipeline, behind one gate.

People who have visited

unread

30 days agotoday

Scanners, my own tools' and my own reads left out.

03Start here

04Where teams are heading

How I see engineering with AI, and the setup on this site that backs it.

AI-augmented teams · Architecture and ownership

AI writes more of the code. Someone still has to own what ships.

Teams are going to be heavily AI-augmented. That moves the senior job toward architecture and technical ownership: deciding what to build in pieces small enough to verify, and owning what ships.

  • Task tracking will get automated too. Judgment stays human: seeing a design fail at scale before it does.
  • On this site the AI's first design held the whole catalogue in memory. I caught it when the App Service plan hit 82 per cent and moved the work to the store.

What the AI wrote, what I decided

07Tech stack

  •    
  •    
  •    

Read from the build, never typed by hand

What TheYard runs on

What we use, where it runs, its AWS twin, the version as built, and the file that proves it.

Cloud patterns, not one vendor: every Azure piece in this stack has a named AWS twin. Mapped, not yet run on AWS.

  • .NET 1114 projects
  • React 19.3TypeScript 7.0
  • Azure9 Bicep files
  • 11GitHub Actions workflows
The whole stack, with the file that proves each line

The last release the gate stopped was 1.0.5.258 on 2 December, at its browser 1 of 2 job.

08How it is built

09How it is run

10Who and why

Next step

11What has to work, where is it today, and what does success look like?

Book 20 minutes opens an email to me with those three questions in it, and I answer with a time.

Book 20 minutes

Your email app should have opened with this message. If it did not, copy it and send it from any mailbox.

Or message me on LinkedIn