Skip to content

HM Land Registry

Application Management: the concerns that cut across a government organisation’s many Scrum teams.

HM Land Registry runs on a large estate of microservices, built and evolved by many Scrum teams. The Application Management team owns what cuts across them: the shared concerns no single feature team is responsible for. This is four of those concerns, tackled across a Python and Java 21 microservice estate on Kafka, to GOV.UK standards.

Java 21Spring BootKafkaPythonMicroservices

The remit: cross-cutting concerns

Feature teams own their slice of the product. The cross-cutting concerns fall between the slices: the event flow that spans services, the observability that is only useful if it is consistent, the data-consistency guarantees that break only where two systems meet, the performance of endpoints that many teams depend on. Application Management is where those live, so working across team and service boundaries is the normal case, not the exception.

Title search is one of the busiest paths on the estate, and under concurrent load it was slow. The cause was an N+1 query pattern: one query listed a page of titles, then each title fetched its entries in a separate query, so a page of results became dozens of round-trips to the database. Under many searches at once, those round-trips swamped it.

Before: an N+1 query pattern

// One query for the page of titles…
List<Title> titles = titleRepository.searchByArea(area, pageable);

// …then a query per title for its entries. N titles means N+1 round-trips,
// and under concurrent search load they swamp the database.
for (Title title : titles) {
    title.setEntries(entryRepository.findByTitleId(title.getId()));
}

After: batch the children, index the access path

List<Title> titles = titleRepository.searchByArea(area, pageable);
List<Long> ids = titles.stream().map(Title::getId).toList();

// One query for every entry on the page, grouped in memory. N+1 becomes 2.
Map<Long, List<Entry>> byTitle = entryRepository.findByTitleIdIn(ids)
        .stream().collect(groupingBy(Entry::getTitleId));
titles.forEach(t -> t.setEntries(byTitle.getOrDefault(t.getId(), List.of())));

Backed by an index matching the new access pattern: create index idx_entry_title_id on entry (title_id). A page of results went from N+1 queries to two, and response times came back down under load.

The bug that only showed under load

Some data-consistency issues appeared only under concurrent transaction load, the hardest kind to pin down. No single team sees them, because the failure lives between services rather than inside one: a second transaction reads shared state in the window between two writes that span a service boundary, and sees a half-updated world.

Timeline of a data-consistency race between two concurrent transactionsTransaction one writes A in one service, then, after a network hop, writes B in a second service. In the window between the two writes, a concurrent transaction two reads the shared state and sees write A but not write B, an inconsistent view. A single correlation id threads both transactions, which is what made the race followable in the logs.time →T1T2write A · svc-1latency between serviceswrite B · svc-2inconsistency windowreadsees A, not Bcorr-id req-7f3a… threads T1 and T2; the telemetry that made the race followable.
A consistency race of this kind only appears under interleaving: a reader can land in the window between two writes that span a service boundary, seeing write A but not write B. One correlation id threads both transactions, which is what made such races followable in the logs.

Root-cause analysis traced those failures across service boundaries to their source, and targeted fixes drove measurable improvements in processing reliability. The tracing was only possible because the telemetry had been made consistent first.

Making the mesh debuggable

A distributed system is only debuggable if its telemetry is. Structured logging patterns were introduced across the microservice mesh so a single request could be followed as it crosses services, making distributed tracing tractable and raising the observability standard for every team that has to follow a request through the estate.

Going event-driven

Underneath those fixes, the event flow itself was modernised.

  • From RabbitMQ to Kafka. The messaging backbone was upgraded from RabbitMQ to Kafka, for the throughput and durability a national event flow needs, and application-processing pipelines were decoupled onto it, so downstream registration services no longer waited on the steps ahead of them.
  • Fault tolerance across the flow. Decoupling the land-transaction event flow meant a slow or failing downstream service no longer stalled the whole pipeline, raising resilience across the estate rather than in one team.
Land Registry: decoupling the land-transaction flow onto KafkaBefore, land-transaction processing ran as a synchronous chain over RabbitMQ, so a slow or failing step stalled everything behind it. After, land-transaction events publish to a Kafka backbone and downstream services (registration, notifications and others) consume independently, so a slow or failing downstream no longer stalls the flow.Before: RabbitMQ, a synchronous chainLand-transactionstepstepRegistrationa slow or failing step stalls the whole chainAfter: Kafka, decoupledLand-transactioneventsKafkaRegistrationNotificationsOther downstream serviceseach consumes independently: a slow or failing downstream no longer stalls the flow
The messaging backbone was upgraded from RabbitMQ to Kafka and the land-transaction pipeline decoupled onto it. Before, a synchronous chain meant a slow or failing step stalled everything behind it; after, downstream registration services consume independently, so one slow consumer no longer stalls the flow.

Rigor and the team

  • Regression across the surface. Postman collections covering the full API surface made regression testing across service boundaries reliable, and lifted the test-engineering practice on the team.
  • Working across teams. Cross-team mentoring, code reviews and Agile ceremony leadership, with raised standards in documentation, architecture and Jira practice throughout.
  • To government standards. Delivered to GOV.UK service standards and GDS expectations, as public-facing government digital services require.

The thread

The thread through all of it is the craft of a senior engineer on shared infrastructure: not a headline system, but a large estate made faster on its hot paths, correct under concurrency, and debuggable across its seams. The hardest problems here live between the teams, which is exactly where Application Management works.