Clean Markdown mirror for AI agents:
/case-studies/module-extraction.md · /llms.txt
Case Study

When Does Extracting a Module Into a Microservice Earn Its Cost?

Extracting a bounded context into its own deployable service changes failure isolation, acknowledgement semantics, and operational cost—not domain invariants. Here is what changes when fulfillment stops mid-workload in one host vs. behind an external broker.

1. Two deployment topologies, one identical workload

In Orbit’s single-host topology, HTTP endpoints, ModuleOutboxProcessor, and Orbit.Common.EventBus share one ASP.NET Core 11 process backed by isolated PostgreSQL schemas. Pausing background fulfillment processing leaves pending cancellations staged safely inside the producer’s outbox_messages table.

In the extracted topology, fulfillment runs in a separate process with its own database and receives events over a durable broker stream (NATS JetStream / RabbitMQ). Stopping fulfillment leaves the order API online while messages accumulate in the broker’s durable consumer.

2. Observed operational behavior across 24 reservations & 12 cancellations

ObservationSingle .NET 11 HostExtracted Service + Broker
Order API reachable while fulfillment worker is stoppedNo (shared host)Yes (separate process)
Where 12 in-flight cancellations wait during outage12 in module PostgreSQL outbox12 in external broker stream
Active shipments / pickups after recovery1212
Distinct completed idempotent inbox receipts3636
Healthy event-to-projection p50387.8 ms105.4 ms
Healthy event-to-projection p95412.9 ms137.2 ms
Process restart and backlog catch-up500 ms587 ms

3. The two-stage acknowledgement gap

Once a broker sits between Orders and Shipments, zero pending rows in orders.outbox_messages only proves that the broker accepted the message—not that warehouse fulfillment projected it. Operators now own broker retention, consumer lag alerts, cross-service W3C trace propagation, and backward-compatible contract evolution.

Because Orbit already enforces strict schema-per-module isolation (verified in SchemaPerModuleTests.cs) and routes events through IEventBus, your team can ship fast in one host today and extract a single module later without rewriting domain or application code.

Inspect IEventBus seam·Read the Channels & Outbox specification·Verify schema autonomy guardrails

Frequently asked questions

Does extracting a module into a microservice automatically improve latency?

No. In-process System.Threading.Channels with OutboxWakeupSignal avoids network serialization and broker hops. Extraction trades local simplicity for independent process restarts and deployment autonomy.

What prepares an Orbit module for clean extraction later?

Strict schema-per-module ownership (zero cross-schema SQL joins) and narrow IntegrationEvents mean extracting Shipments only swaps the IEventBus transport adapter and database connection string.

Summary

Keep bounded contexts inside one modular monolith until independent deployment cadence, asymmetric compute scaling, or hard fault-isolation SLOs clearly outweigh distributed broker and operational complexity. Read Milan’s complete extraction decision guide or explore the Modular Monolith Architecture Course.