I spent about a year at Invsto, a US fintech, as a full stack engineer. Two pieces of work there taught me more about performance than anything else I've done. The order management system got 5x more throughput, and the strategy engine got 15x faster.
I no longer have access to that code, so this stays at the level of design, and the numbers are the ones I took away from the work. Both results have the same moral: the slow part wasn't the part anyone was looking at.
The two systems
They sit next to each other. The strategy engine reads real-time market data and decides what to trade. The order management system (OMS) takes those decisions off a RabbitMQ queue and executes them across multiple brokerages.
They have opposite performance profiles, which is why they needed opposite fixes. The OMS spends its life waiting on other people's APIs. The strategy engine spends its life crunching data it keeps fetching.
5x on the OMS: stop waiting in line
An OMS's work is mostly waiting: send an order to a brokerage, wait for it to respond, then handle the result. If processing is effectively serial, one slow brokerage response holds up every order behind it, including orders for a completely different brokerage.
The redesign kept RabbitMQ as the entry point and used Celery with multithreaded workers to consume from it. That combination fits this workload for two reasons:
- Threads suit waiting. Python's GIL limits CPU-bound parallelism, but it's released during network I/O. For a workload that mostly waits on brokerages, threads give real concurrency cheaply.
- The queue is a buffer with a memory. A burst of orders becomes a backlog rather than a failure, and scaling becomes a matter of adding consumers.
15x on the strategy engine: stop fetching what you already have
The strategy engine's problem wasn't that its calculations were slow. It was how often it went back to get data, and what it did with that data once it arrived.
The fix had two parts.
Three layers of caching, each one faster and smaller than the last:
| Layer | Role | Trade-off |
|---|---|---|
| In-memory buffer | The freshest data a running strategy needs right now | Fastest, but per-process and limited in size |
| Redis | Shared across processes | A network hop, but one fetch serves everyone |
| Postgres | The durable record | The slowest, and it should be the last resort |
With market data, this works because of the data's shape: most of it is historical, and history doesn't change. Only the newest bars are moving. So most reads can be served by a layer that never needs invalidating, and you can spend your care on the small part that's live.
Polars for the data work. Strategy calculations are operations over columns, and Polars runs them in parallel on a columnar engine. Moving to it meant the time saved by not fetching wasn't lost again in processing.
The 15x came from both together. Neither would have got there alone.
What carried over
Three things have stayed with me:
- Find out what the time is actually spent on before you touch anything. Both of these systems looked like they needed faster code. Neither did.
- Waiting and computing are different problems. Threads and queues help the first, caching and columnar processing help the second, and using the wrong one gets you nothing.
- Performance work is usually architecture. The big multiples came from changing where data lives and who waits for whom, not from tightening a loop.
Around the same time I also moved 10+ production services from AWS to Azure with Terraform, which is a very different kind of careful, and I built the frontend for SharkSigma, Invsto's strategy-building environment. It was a good year for learning how much one engineer can own.