Monoliths to Microservices: Improving Code Quality with Graph Technology

The Challenge

Financial services companies require cutting-edge computing infrastructure. Refactoring Vanguard’s existing monolithic Java-based systems into myriad microservices required visibility into all components and their dependencies. Some of Vanguard’s legacy Java archives (jars) have 3 to 4 million lines of code.

Further, Vanguard faced technical debt. Dead code needed to be pruned and impact assessments were difficult.

“Managing code is critical,” said John Lavin, Software Architect, Vanguard. “Often the focus is on feature delivery, time to market and getting things out the door. But if you don’t make it easy to manage code, none of that gets done.”

The team first tried to visualize jar dependencies in a desktop tool. Attempts to load all the jars crashed the tool, which wasn’t designed for Vanguard’s scale.

Refactoring jars with a million lines of code into microservices requires managing a lot of moving parts. To tackle this, the team started by managing services in a spreadsheet, compiled over the course of a year.

“We had a lot of different services in a lot of different states. We tried to group things and document dependencies as best we could in the spreadsheet. But it really just wasn’t going to work out long-term,” said Lavin.

Vanguard needed to model all their services and dependencies in the graph for impact analyses that show how many other services will be impacted if a given service is down. API gateways that use the runtime to capture dependencies would not work for Vanguard, because key services called only at certain times of the year and would be omitted.

The Solution

The team needed a flexible solution that could scale to unprecedented levels. “We realized that the management of our modules and services was really a graph problem,” said Lavin. Vanguard adopted Neo4j for its scale and flexibility.

The team started with a simple graph data model, adding in jar dependencies automatically when they ran a build. They then added all their existing code artifacts into the graph, along with their dependencies.

Using graph analytics, the team began evaluating their code against best practices and deriving metrics. Next they added in information from their architecture spreadsheet to enrich their schema.

The team built out tools to visualize relationships and enforce best practices such as constraining the number of service-to-service calls to reduce risk. Based on metrics derived from the graph, a code quality scorecard enables collaboration across the business, from management to developers.

Download Case Study