In November 2020, a customer asked for the trip report covering a full year for their 250-vehicle fleet. The report engine got to work, and for four minutes, because it lived inside the same monolith, it gnawed at the same PHP-FPM worker pool as the live map API. During those four minutes, live tracking for 5,000 vehicles rose to 8 seconds at p99. One person's annual report had taken everyone's live screen hostage. It wasn't the first time this had happened; but it was the incident that got the "we're splitting the report engine out of this body" decision signed.
The word "surgery" in the title isn't decoration. Carving a piece out of a five-year-old, 400,000-line PHP monolith where every corner touches every other is surgical work, and we did this operation with the patient awake, while the system was handling 40 million requests a day.
Why the Report Engine? Looking for the Dotted Lines
My first question to anyone caught up in the urge to break up a monolith is this: why that piece? Our reasons came down to three points, and none of them were ideological; all three were measurable. The resource profiles were incompatible: API requests were 15 ms, memory-light jobs, while reports were monsters that ran for minutes and ballooned to 500 MB; putting the two in the same FPM pool was like putting an ambulance and a garbage truck in the same lane. The scaling needs were different: report load jumped 10x at the end of each month, while API load stayed flat. And the rate of change was different: report templates changed several times a week, and every time, the whole monolith got deployed — and on top of that, at the time, every deploy required an FPM reload because of preloading.
There was one more reason that's hard to admit: the report code was the most neglected neighborhood in the monolith. The decision to split it out was a chance to rewrite that neighborhood. But here we set ourselves a rule: you don't migrate and rewrite at the same time. First migrate while preserving the behavior exactly, then improve it in place. Anyone who combines the two ends up floundering for months in the "the new system doesn't give the same result as the old one" dead end — we had lived through that with another module in 2018, and there would be no repeat.

The Strangler Subtlety: Move the Traffic, Not the Door
The split plan followed the strangler approach: the old door stays in place, the new service grows behind it, and traffic changes hands slice by slice. The first concrete step was to build a facade inside the monolith: we gathered every call that went to report generation — they came from 14 different controllers, two crons, and an email scheduler — behind a single ReportGateway class. It was a boring, three-week refactor that changed no behavior at all, and it was the most critical step of the surgery: the dotted line now physically existed in the code.
Then we taught the gateway a flag: based on the report type and customer ID, it routes the request either to the old internal code or over HTTP to the new service. The new service — PHP 7.4, its own FPM pool, its own machine; its processing model isn't synchronous but queue-based: the request creates a job, a worker produces it, the result is written to object storage, and the user gets a "your report is ready" notification. The first report we migrated was the simplest one (the daily mileage summary), and it ran in shadow mode for two weeks: every request was produced in both systems, and the outputs were compared automatically. Out of 40,000 comparisons, there were 6 mismatches; all six were a rounding inconsistency in the old code. It wasn't the customers who made the call; it was this diff report.

The Database: The Hardest Clause of the Separation
The textbook version of splitting out a service says "every service gets its own database." We didn't. The report engine couldn't own the location data — that data belongs to the telemetry pipeline — and copying a 1.9-billion-row table wasn't a solution either. Our pragmatic line was this: the new service connects to the main database only through a read replica and only with a user dedicated to it; that user's grants are limited to five tables. Everything it writes (report metadata, job queue state, finished files) lives in its own separate schema. Someone will call this a "distributed monolith"; and they'll be partly right. But drawing the boundary with grants is miles better than not drawing it at all, and it doesn't close off the path to evolving into a real API boundary later. Sure enough, within a year, two of those five tables were replaced by an internal API offered by the telemetry service. Using the replica brought a side benefit for free: even the heaviest report query can no longer put locks on the write path; at worst it increases replication lag — and that gives itself away by showing up in the freshness note on the report screen.

The Balance Sheet of the Split, and the Scars
By mid-December, six weeks after the decision, 80 percent of report traffic was on the new service. The measurements: API p99 held steady below 180 ms even during the end-of-month report downpour (it used to hit 8 seconds); report deployments could happen several times a day without touching the API; the report machine is scaled up vertically at the end of the month and scaled back down at the start of the next. And a gain we didn't expect: after moving to the queue-based model, 60 percent of reports shifted to nighttime hours on their own — users loved the "let me know when it's ready" button, and the system loved the idle capacity at night.
Let me describe the rollback plan too, because it was the real source of our courage. The routing flag in the gateway could be changed per customer and instantly; when a memory leak showed up in the new service in the first week (the PDF library holding 30 MB per page on large tables), we switched the affected report type back to the old path with a single line of configuration, fixed the leak with a calm head, and turned it back on two days later. Users noticed nothing. A migration without a rollback button isn't a migration; it's a gamble.
Let the scars go on the record too. One: we paid the distributed systems tax — in the old world a stack trace was a single piece, and now the story of a report is split across the logs of two services; because we didn't put in a correlation ID from day one, we went through two weeks of log archaeology. Two: a time zone bug — the new service's machine was set to UTC, while the monolith was set to Europe/Istanbul; shadow mode caught it, but if it hadn't, every daily report on the midnight boundary would have been shifted by three hours. Three: one of the 14 call sites we gathered into the facade class was a forgotten code path written for one customer's custom integration, and we only found it when the customer called. An inventory that's 93 percent complete is not 100 percent.
There was an unexpected effect on the team side as well. Once the report service had a separate repository and a separate deploy pipeline, a two-person "report team" effectively formed on its own; code ownership became clear, and review queues got shorter. We ended up running Conway's law in reverse: we split the architecture, and the organization aligned itself to it. Its value is rarely talked about in small companies — when "everyone was responsible" for all 400,000 lines, nobody really was.
I'm writing this at a time when the microservices craze is at its peak, so let me be frank: breaking up a monolith is not a virtue in itself. The rest of our monolith is still in place and serving us very well; the next split candidate (the notification infrastructure) will go into surgery only once it has piled up measurable reasons of its own. The price of carving out a piece is paid every time in networking, monitoring, deployment, and cognitive load; the only thing that justifies that price is concrete pressure, like incompatible resource profiles and different rates of change. If you'd like to discuss where to make the first cut in your own monolith, reach out here; where you won't put the scalpel is often the more important decision.