Processing Millions of Transactions a Day on a Quarter of the Hardware

Sanjay Kumar Singh remembers the shape of the old system in hardware terms. Forty Windows virtual machines, each one carrying both the component that handed out work and the component that did the work. If the queue grew, you added machines. That was the only lever.

“The architectural issue was work producer and processor being tightly coupled and being on each machine,” he says. “So in order to increase the capacity you need to add machines.”

Singh has spent more than twenty years writing software, the last ten of them inside an insurance company’s billing and payments group, working across personal and commercial lines. The transaction system he inherited there was the sort of thing most engineers politely leave alone. It worked. It just worked expensively.

He rewrote it in about three months.

The design turned on two decisions, both small to say and hard to execute. First, split the producer from the processor so each could scale on its own. Second, make the service that actually does the work stateless, so it could be called as often as the system could safely call it. “The component that needs to distribute the work needs to be separate from the component that needs to process the work,” Singh says. In the old world, every machine carried the whole shape of the problem. In the new one, each piece has one job.

The topology ended up looking like this. Eight servers run the stateless service. Three more run the claimer and the processor: one component claims work that needs to be done and dispatches it to a message broker, and the other runs as many competing consumers, each pulling from the broker and calling the stateless service. Eleven machines in total, doing what forty used to do.

That is a seventy-five percent cut in hardware, and throughput went up, not down.

Singh is careful about how he describes the result. The load testing told the team roughly what to expect, but he knew production would behave differently. “We had the hints for what it will look in Production,” he says. “It was for sure a pleasant surprise.” The team built concurrency knobs into the new system from day one, specifically because load tests cannot reproduce every stateful quirk of a live environment. If something ran too hot or too cold, an operator could turn a dial.

Four months after the first design meeting, the new architecture was carrying full production traffic. The team spent the last few weeks of that window on stabilization and bug fixes.

Ask Singh what most engineers miss when they try to scale a transaction system and he gives an answer that sounds almost unhelpful until you sit with it. “Take a step back and try to look at big picture rather than just trying to solve the problem exactly as given.” The old system was not slow because the code inside each machine was bad. It was slow because the shape of the problem had been frozen into the shape of the hardware. Nothing inside the forty machines was going to fix that.

This is the way he tends to work. He talks about first principles the way other engineers talk about frameworks, as a daily habit rather than a philosophy. He also mentions, almost as an aside, that years earlier he had built what amounted to a GraphQL-style protocol for billing APIs before GraphQL was a known name. “When I came to know about GraphQL I was surprised to visualize the coincidence,” he says. The same instinct is at work: look at what the caller actually needs, and let the shape of the interface follow from that, not from whatever the previous team happened to ship.

His path to the rewrite was long. He started as a C and Visual Basic developer at a small company making ID and barcode printing products. A software services firm came next, with projects across IoT, banking, finance, marketing, and retail. He moved to the United States in 2009, spent a few years at an IoT company, then landed in insurance billing and payments, where he has been ever since. Along the way he has migrated large billing and payment systems off the mainframe and onto the cloud, and rewritten a billing and payment system to replace a vendor product.

The transaction rewrite is the one he returns to. Partly because the numbers are clean. Mostly, you suspect, because it is the clearest example of what he means when he talks about alignment, the idea that a fix should solve the problem in front of you and the one you have not been handed yet.

The forty machines are gone. The eleven that replaced them are still running, concurrency knobs and all, waiting for whatever the next load profile asks of them.

Author:
Written byTom Allen

Founder of The AI Journal. I like to write about AI and emerging technologies to inform people how they are changing our world for the better.

Follow Tom Allen