Recent Posts
Archives

Posts Tagged ‘ModularMonolith’

PostHeaderIcon [VoxxedDaysAmsterdam2026] Taming Microservice Overload: The Journey to Modular Monoliths at the Port of Rotterdam

Lecturer
Mario Klaver is a solution architect at the Port of Rotterdam, responsible for digital systems supporting Harbour Master operations. With a background as a developer, he remains actively involved in programming and puzzle-solving.

Abstract
Mario Klaver recounts the evolution of the Port of Rotterdam’s mission-critical harbor management system from a monolithic application through an explosion of microservices to a more sustainable modular monolith architecture. Using Domain-Driven Design (DDD) techniques such as EventStorming and bounded contexts, combined with Spring Modulith, the team consolidated over 90 microservices into fewer, well-bounded services aligned with business domains. The presentation details the motivations, challenges, implementation approach, migration strategy, and lessons learned, offering practical insights for organizations facing similar architectural fatigue.

From Monolith to Microservices: The Growth of Complexity

In 2010, the Port of Rotterdam initiated a new 24/7 mission-critical system for the Harbour Master division using then-contemporary technologies like Java and Swing (with offline requirements precluding full HTML5 adoption). By 2015, a single backend had become unmaintainable spaghetti code with lengthy manual regression tests.

Following conventional wisdom, the team adopted microservices in 2016, starting with 10 services. By 2018 this grew to 50, and eventually exceeded 90. Every new feature or subject—vessel visits, inspections, dangerous goods, waste handling—spawned additional services, sometimes multiple per domain. Rather than reducing complexity, microservices distributed it, creating tight coupling, high cloud costs (exacerbated by multiple environments and ports), extensive update overhead, and paradoxically slower delivery despite supposed team autonomy.

Anonymized architecture diagrams revealed that services appeared logically separated by responsibility (vessel visits, conflict signaling, clearance) yet events and synchronous calls created a web of dependencies where boundaries were unclear or misplaced. The realization emerged: microservices had not fixed the architecture; they had merely distributed the mess.

Rediscovering Domain Boundaries with EventStorming and DDD

The turning point involved shifting focus from technical partitioning to domain alignment. EventStorming workshops proved instrumental—a collaborative, chaotic yet powerful technique using brown paper, stickies, and domain events to map complex business processes. Participants from business, development, architecture, UX, and operations contributed partial knowledge to build a shared understanding.

Pivotal events, parallel flows, and heuristics helped surface natural subdomains (e.g., Visit, Clearance) and bounded contexts within them. Digitized results clarified responsibilities that differed markedly from existing service implementations. Good boundaries were defined by low coupling (changes mostly contained within a module or service) and high cohesion (modules focused on a clear purpose).

The decision was made to move toward one (larger) service per subdomain, implemented as modular monoliths to prevent internal spaghetti while preserving clear interfaces.

Implementing Modular Monoliths with Spring Modulith

Spring Modulith aligns perfectly with DDD bounded contexts. After adding the dependency, packages directly under the application entry point become modules by convention. Public APIs (Spring beans or events) are exposed in designated packages or via @NamedInterface annotations, while other packages remain private and inaccessible across modules.

IntelliJ provides excellent visual support with green/red indicators for public/private elements. The @ApplicationModule annotation enforces allowed dependencies and prevents cycles. An open/closed mode facilitates gradual migration. Crucially, architecture tests (using @ApplicationModuleTest) verify module boundaries, API usage, and absence of cycles—failing builds if violated.

Inter-module communication prefers Spring’s event publishing and consumption mechanisms. Synchronous listeners use @TransactionalEventListener, while asynchronous ones leverage Modulith’s @ApplicationModuleListener, which persists events for reliability across restarts and decouples transactions. This design eases future extraction of modules into separate services if needed.

Module-specific tests spin up isolated Spring contexts, enabling verification of event flows (e.g., publishing a security clearance event and asserting a downstream vessel movement decision).

Migration Strategy and Architectural Trade-offs

A full green-field rebuild was deemed impractical given a roughly five-year horizon. Instead, the team adopted an incremental “heart surgery while the patient lives” approach: create walking skeletons for new modular services, migrate relevant legacy services as modules, reroute connections, and decommission old instances using feature flags to avoid duplicate processing. Databases initially remain shared before eventual per-module schema separation and a broader Oracle-to-PostgreSQL migration.

Takeaways include faster development and simpler debugging within a single service, reduced infrastructure, but larger deployables requiring broader regression testing, reduced independent scalability, and greater impact during outages.

Lessons Learned and Broader Implications

Key lessons encompass inclusive EventStorming participation to avoid blind spots, ongoing domain exploration and validation with real scenarios, and persistence with clean architectures (e.g., onion/hexagonal) despite mapping overhead—which AI may eventually alleviate. Boundaries matter more than the number of services. A modular monolith often serves as the ideal starting point or interim step before microservices, as correcting boundaries post-split is far costlier.

Mario concludes that microservices distribute complexity, whereas well-designed boundaries control it. The Port of Rotterdam’s journey illustrates a pragmatic path for organizations overwhelmed by service proliferation.

Code Sample: Spring Modulith Module Configuration

@ApplicationModule(
    allowedDependencies = {"securityClearance", "vesselVisit"},
    type = ApplicationModule.Type.OPEN  // during migration
)
public class PortClearanceApplication { ... }

Code Sample: Event Consumption

@TransactionalEventListener
public void onSecurityClearanceCompleted(SecurityClearanceCompletedEvent event) {
    // process within transaction
}

@ApplicationModuleListener
public void onAsyncEvent(AnotherEvent event) {
    // decoupled, persisted for reliability
}

These patterns enforce architectural integrity while leveraging familiar Spring mechanisms.

In reflecting on the Port of Rotterdam’s experience, Mario Klaver delivers a compelling case study in architectural modernization. By realigning services with domain realities through DDD and enforcing modularity with Spring Modulith, the organization has regained clarity, ownership, and sustainable evolution capacity without sacrificing the benefits of service-oriented thinking.

Links:

PostHeaderIcon [DevoxxBE2025] Live Coding The Hive: Building a Microservices-Ready Modular Monolith

Lecturer

Thomas Pierrain is Vice President of Engineering at Agicap, a financial management platform, where he applies domain-driven design to build scalable systems. Julien Topcu is Vice President of Technology at SHODO Group, a consultancy focused on socio-technical coaching and architecture, with expertise in helping teams implement domain-driven practices.

Abstract

This analysis investigates the Hive pattern, an architectural approach for creating modular monoliths that support easy evolution to microservices. It identifies key ideas like vertical slicing and port-adapter boundaries, set against the backdrop of microservices pitfalls. Highlighting a live-refactored time-travel system, it details methods for domain alignment, encapsulation, and simulated distributed communication. Consequences for system flexibility, debt management, and scalability are evaluated, providing insights into resilient designs for existing and new developments.

Emergence from Microservices Challenges

Over a decade, the shift to microservices has often resulted in distributed messes, worse than the monoliths they replaced due to added complexity in coordination and deployment. The modular monolith concept arises as a remedy, but risks tight coupling if not properly segmented. The Hive addresses this by separating design from deployment, following “construct once, deploy flexibly.”

In the live example, a time-machine’s control system—handling energy, navigation, and diagnostics—crashes due to fragility, landing in the 1980s. Diagnostics reveal a muddled structure with high resource use, mirroring legacy systems burdened by modeling debt—the buildup of imprecise domain models hindering change.

The pattern’s innovation lies in fractal composability: modules as hexagons can nest or extract as services. This enables scaling in (sub-modules) or out (microservices), adapting to needs like independent deployment for high-load components.

Essential Tenets of the Hive

Vertical slicing packs modules with all necessities—logic, storage, interfaces—for self-sufficiency, avoiding shared layers’ dependencies. In the demo, the energy module includes its database, isolating it from navigation.

Port-adapter encapsulation defines interaction points: inbound for incoming, outbound for outgoing. Adapters translate, eliminating direct links. The navigation’s energy request port uses an adapter to call the energy’s provision port, preventing tangles.

Inter-module talks mimic microservices sans networks, using in-process events. This readies for distribution: swapping adapters for remote calls extracts modules seamlessly. The example routes via a bus, allowing monolith operation with distributed readiness.

These tenets create a supple framework, resilient to evolution. The fractal aspect allows infinite composition, as shown by nesting diagnostics within navigation.

Refactoring Methodology and Practical Steps

The session starts with a monolithic system showing instability: overused resources cause anomalies. AI schemas expose entanglements, guiding domain identification—energy, time circuits, AI.

Modules reorganize: each hexagon sliced vertically with dedicated storage. Code moves via IDE tools, databases split to prevent sharing. Energy gains PostgreSQL, queried through adapters.

Communication restructures: ports define contracts, adapters implement. Navigation’s outbound energy port adapts to energy’s inbound, using events for asynchrony.

Extraction demonstrates: energy becomes a microservice by changing adapters to network-based, deploying separately without core changes. Tests modularize similarly, using mocks for isolation.

This step-by-step approach handles brownfields incrementally, using tools for safe restructuring.

Resilience, Scalability, and Debt Mitigation

Hive’s boundaries enhance resilience: changes localize, as energy tweaks affect only its hexagon. This curbs debt, allowing independent domain refinement.

Scalability is fractal: inward nesting subdivides, outward extraction distributes. Networkless talks ease transitions, minimizing rewrites.

Versus monoliths’ coupling or microservices’ prematurity, Hive balances, domain-focused for “right-sized” architectures. Challenges: upfront refactoring, boundary discipline.

Development Ramifications and Adoption

Hive promotes adaptive designs for changing businesses. Starting modular prevents debt in new projects; modernizes legacies via paths shown.

Wider effects: better sustainment, lower costs through contained modules. As hype fades, Hive provides hybrids, emphasizing appropriate sizing.

Future: broader use in frameworks, tools for pattern enforcement.

In overview, Hive exemplifies composable resilience, merging monolith unity with microservices adaptability.

Links:

  • Lecture video: https://www.youtube.com/watch?v=VKcRNtj0tzc
  • Thomas Pierrain on LinkedIn: https://fr.linkedin.com/in/thomas-p-0664769
  • Thomas Pierrain on Twitter/X: https://twitter.com/tpierrain
  • Julien Topcu on LinkedIn: https://fr.linkedin.com/in/julien-top%25C3%25A7u
  • Agicap website: https://agicap.com/
  • SHODO Group website: https://shodo.io/