The first version of my trading platform was a monolith, one Python process doing everything: reading the price feed, running three trading strategies, calling an AI model for analysis and deciding how much money each strategy got to work with. A model made every trading decision, and each call took three to five seconds. So a stop-loss, the order that sells a position once its price falls past a set line, could sit waiting behind a model call that hadn't come back yet. My notes on that version say two things about it: too slow, and the model hallucinated. It also ran on my laptop, and a trading system that stops when the lid closes isn't much of one.

Both problems came from the same place. The slowest, least predictable part of the system sat in front of the one action that most needed to be fast and certain. I split the platform into services in February, rebuilt it on a different design in April, and it stopped running in July; the project is on hold now. The boundary I drew in February made it through both rebuilds, even though almost everything about how I first enforced it didn't. It's the boundary I now look for in any system that mixes code with a model, a support bot included: work that has to happen on time and come out the same way every time runs in plain code, and the model works on a slower track beside it, where a late or wrong answer can't hold up anything urgent.

The first split gave each speed its own service

In February I broke the monolith into Docker containers on a rented server, so it ran around the clock instead of whenever my laptop was open. Three strategy services ran on fast loops and decided when to buy and sell using fixed rules. Three AI services ran on slower cycles, adjusted those strategies' settings and published the changes over Redis, which took the model out of the trade path entirely. The price feed got its own service and its own WebSocket connection, and capital allocation, market analysis, benchmarks and alerts got one each. The rebuild deleted about 5,700 lines of backend code, including the old single process and the code that asked a model about every trade, and rewiring the frontend afterward deleted another 5,554.

I looked at keeping one process and managing the timing inside it with asyncio (Python's way of interleaving tasks that spend most of their time waiting), a task queue or careful coroutine scheduling. What decided it was the pairing that looked most natural. A strategy and the AI service tuning it worked on the same data, the same assets and the same logic, and every usual test of what belongs together said to keep them in one place. One had to answer in under a second, though, and the other spent three to five seconds on every model call, so I grouped the system by how fast each part had to respond instead of by what it was about. The container count followed from that: 13 when the rebuild landed, 15 by the end of that day, 17 by early March. The first time I restarted one service without touching the rest, the count stopped bothering me.

The same rule turned up again one level down, inside a single service, on the day of the split. The price feed started dropping its connection about every 90 seconds. It made three round trips to a cloud-hosted Redis on every price tick, about 150 milliseconds of waiting, and those waits starved the same loop that had to answer the connection's keepalive pings. That was the monolith's problem at a smaller scale, slow I/O inside a loop that had to stay fast, and the fix took the slow work back out: the duplicate writes went, the rest were batched every two seconds, and the connection got more time to answer.

Every boundary was one more thing to keep in sync

A line between two services is an agreement about data, and those agreements drifted. The split itself needed eight follow-up commits to fix calls between services that didn't match and crashed, along with dead code and tests for code that no longer existed. The day after, five services turned out never to have written the heartbeat the health checks read, and the backend and frontend disagreed about the shape of the trading signals. By March 3 an audit script written for the stack still assumed 15 containers when there were 17, and its database queries named columns and tables that had been renamed or dropped. None of it was hard to fix, but it was all work the monolith had never needed, and on a system one person runs, every new service adds more of it.

The rebuild kept the boundary and dropped most of the containers

In April I rebuilt the platform on a different design, and it ran in two containers where the first split had ended with at least 17. The boundary didn't move. One container stayed on all the time: it watched prices over a WebSocket and fired the stop-losses, trailing stops and take-profit orders that were set up when each position opened, so the exits that protected a position never waited on a model. The other started on a schedule to refresh the AI's read of the market, and a full decision run started whenever the always-on process saw an event worth one, such as a sharp price move. The AI's job changed as well. Instead of tuning a rule-based strategy's settings, it proposed trades itself, and each proposal went through a risk manager written in plain code with no model in it. By May that risk manager ran 21 checks, and any one of them could refuse a trade.

That design also corrected something I wrote when I first described the split: that fast and slow work can't share a process. In the April version, a triggered decision run happened inside the always-on process, as a separate background task on the same kind of asyncio event loop I'd ruled out in February. It could live there because its model calls were asynchronous, so while a run waited on the model, the loop was free to keep handling prices and firing stops. What I'd defend now is narrower: fast and slow work can share a process as long as nothing slow sits in the fast path. Separate processes are the blunt way to guarantee that, because a blocking call in the slow code can't stall stops that run somewhere else. I'd still start with them anywhere a stalled stop is expensive and nobody has checked that every slow call gives the loop back while it waits.

One process, then 17 containers, then two. The boundary didn't move.

MY TRADING PLATFORM: FIRST VERSION, FEBRUARY SPLIT, APRIL REBUILD

Three versions of my trading platform's fast path, price in and stop-loss out. First version, one process: the price feed, then a model call, marked 3 to 5 seconds, then the stop-loss waiting behind it. February split, 17 containers by early March: the price feed on its own WebSocket into strategy services with fixed rules and fast loops; AI services on slower cycles adjust the strategies' settings over Redis, out of the trade path. April rebuild, 2 containers: always on, prices over a WebSocket into stop-losses, trailing stops and take-profits set at entry, which never waited on a model; a triggered decision run is a separate background task whose model calls are asynchronous, so the loop keeps firing stops while it waits; the second container starts on a schedule and refreshes the AI's read of the market.

Rules that have to hold went into code

The second thing I sort by is whether a decision has to come out the same way every time. A model's output is probabilistic: usually right, sometimes not, and never guaranteed to match the answer it gave yesterday to the same question. A limit is that kind of decision, and in May I found one that code wasn't enforcing. Until then, the code's rule for days with a major economic release, like the monthly inflation report or a Fed rate decision, was to halve the size of any new position, and the timing around the release was left to the model. The model would write in its own reasoning that a position should be out before the report, while new entries kept arriving inside the same window. After that, a check in code refused every new entry in the 36 hours before one of those releases, whatever the model wrote.

The same month, more checks went in front of the model. Before a decision run paid for a single model call, four cheap checks in code asked whether a trade was even allowed, such as whether there was any cash available to buy with, and unless the trigger was an emergency, a no from any of them ended the run there. A $15 daily cap on AI spend was added at the same time, and it leaked the next day: spend kept climbing for another 81 cents after the cap tripped. An older cycle that ran every 30 minutes had been written before the cap existed and never checked it, so its five model calls at about 16 cents each went straight through. The fix moved the check into one function that every path calls. When I add a limit now, the first thing I look for is every path that can reach what it guards, not only the one I had in mind when I wrote it.

Four checks in code before the model, 21 after it

MY TRADING PLATFORM'S DECISION RUN, MAY

One decision run. A trigger, an event worth a run such as a sharp price move, goes through 4 cheap checks in code, marked, such as any cash to buy with; a no ends the run. In an emergency a no doesn't end the run. Then the model proposes a trade, the only step that is the model's. Then 21 checks in the risk manager, plain code with no model, any one of which can refuse: trade, or refused.

The same split outside trading

Any system that mixes code and a model has the same two kinds of work: actions that have to happen on time and identically for everyone, and work that can wait and live with an answer that's usually right. The support bot I rebuilt for World App at Tools for Humanity sent every conversation through a fraud check first. Machine-learning rules had already scored the account and set flags on it, the bot read those flags and routed the person by fixed rules, and the model's part was the help-center answers. The same choice comes up in how a model reaches other systems. MCP is probabilistic and generally very helpful, but when I want a clear, well-defined tool, I build it on the API directly with a fixed schema, which is how the trading platform's AI read market data and submitted its trade proposals. The model still decides when to call a tool, and what the tool does once it's called stays fixed.

When one process is enough

Not every system needs the split. If nothing in it is time-critical and a person catches wrong answers before they matter, as with a tool that drafts replies someone approves before they go out, one process with the model in the loop is fine, and splitting it only buys the kind of upkeep I had in February and March. For one person, I'd start with the fewest processes that keep slow work out of the fast path, which for the trading platform turned out to be two, and add a service only when something specific needs to restart, scale or fail on its own. Before building anything with a model in it, I list each action the system will take and mark two things: how fast it has to happen, and whether it has to come out the same way every time. A yes to either keeps the model off that path.

Services

Is your company paying for AI that hasn't changed how the work gets done?

Tell me what's stuck. Thirty minutes, no pitch deck.