The microservices versus monolith debate, the stories of Amazon, Segment and Shopify, and how redb.Tsak changes the deployment shape with configuration instead of a rewrite.

redb.Tsak

Disclosure: I am the author of redb.Tsak and redb.Route. Both are free and open source under Apache 2.0, and this post contains no affiliate links.

How do you decide whether a module gets its own service or stays in a shared process? And how many times did you have to undo that decision later?

The "microservices or monolith" argument has been going on for more than ten years, and each side brings its own stories. Some teams cut a monolith into a hundred services and later glued them back together. Others have run a single process for years and cannot see why they would need Kubernetes. I think half of this argument is about something else: we settle a deployment question at the level of code, and then pay for it with a rewrite.

First, what people who went through it have to say. Both sides have their stories.

Who microservices helped

Amazon, early 2000s. The best known services legend is retold in Steve Yegge's 2011 "platform rant" (text). According to him, around 2002 Bezos required every team to expose its data and functions only through service interfaces, with no direct access to another team's database. The text of the mandate is known only from Yegge's retelling, but the outcome is visible: both Amazon's internal architecture and AWS grew out of that discipline.

Netflix, 2008 to 2016. In August 2008 a database corruption stopped DVD shipments to subscribers for three days. After that Netflix started moving out of its own data center into AWS and from a monolith to hundreds of services. The move took seven years and was finished in early 2016: Completing the Netflix Cloud Migration. Many tools that are now considered standard for microservices came out of that work.

Monzo, a bank. This British bank was built on microservices in Go and Kubernetes from day one. At QCon London its engineers talked about banking on 1,500 microservices, and in 2024 InfoQ was already writing about code migrations across 2,800 services. It works because they have a platform: shared libraries, uniform service templates, tooling for mass changes.

Uber, 2020. Uber grew to about 2,200 critical microservices and ran into the cost of that. They did not give up on microservices. They grouped them into domains, gave each domain a single entry point (a gateway), and arranged the domains in layers with rules about who may depend on whom. The approach is called DOMA and builds directly on DDD: Introducing Domain-Oriented Microservice Architecture. I will come back to this story.

What these stories share: microservices helped where there were many teams that needed to ship independently, and where the company could afford a platform to run them.

Who moved away from microservices

Amazon Prime Video, 2023. The team that monitors video stream quality built a service from AWS Step Functions and Lambda: every step separate, frames passed between steps through S3. The service hit a scaling limit at about 5% of the expected load and cost too much. The team merged everything into one process in one ECS task, data went through memory instead of the network, and infrastructure costs dropped by 90%. The team's blog post spread as "Amazon gives up on microservices", although it was about one internal monitoring tool and not the whole platform. A good write-up with that caveat: The Stack.

Segment, 2018. Every event destination lived in its own service with its own queue, so that a slow destination would not hold up the rest. There were more than a hundred services, each with its own load profile; a mass update of a shared library meant walking through every repository, and the team slowed down. The services were merged back into one. Alexandra Noonan's post says it in the title: Goodbye Microservices: From 100s of problem children to 1 superstar.

Shopify, 2019. A huge Rails monolith. Microservices were considered and rejected because of the complexity of a distributed system. They chose a modular monolith: components have boundaries, but everything lives and deploys in one place. Kirsten Westeinde, Deconstructing the Monolith.

What well-known engineers say

Martin Fowler, 2015. In MonolithFirst he writes that almost all successful microservice stories started with a monolith that grew and was split, and almost all systems built as microservices from scratch ended up in serious trouble. He calls the cost of splitting the Microservice Premium: monitoring, eventual consistency, deployment automation. On the same site sits the objection of his colleague Stefan Tilkov, Don't start with a monolith: boundaries that were not drawn at the start are almost impossible to draw later.

Kelsey Hightower, 2020. A man hard to suspect of disliking Kubernetes, on the Go Time #114 podcast, gave as his "unpopular opinion" that monoliths are the future: the problem people try to solve with microservices often is not the real problem.

And there is a common diagnosis everyone who has worked with badly cut services knows: the distributed monolith. The services are deployed separately, yet you cannot change one without the other. You got the network and the operational complexity, and you did not get independence.

Where the boundary really is

The most precise thing I have read on the subject came from Google. In Towards Modern Development of Cloud Applications (HotOS 2023), Sanjay Ghemawat and co-authors say that microservices conflate two different boundaries. The logical one, how the code is structured. And the physical one, how it is deployed. As long as the two coincide, any decision to "split" or "merge" becomes a code change.

Their proposal: write a logical monolith out of modules, and decide separately, at any time, how to place the modules across processes and machines. Google released the Service Weaver framework for Go to do this. In December 2024 the project was put into maintenance mode, and the team named the reason itself: adopting it meant rewriting large parts of existing applications.

The conclusion I drew for myself: the idea is right, the deployment shape should not be baked into the code. But if getting there requires rewriting the application for a new programming model, nobody will use it.

How we do it

We came to the same idea from another direction, from integration. In redb.Route the unit of code is a module: a plain .NET assembly with an InitRoute.main entry point that receives a route context and registers routes in it. The module does not know where it will run. redb.Tsak, the module runtime, decides that through configuration.

A few terms you need for the rest:

  • module: an assembly with a static InitRoute class and a main(IRouteContext) method;
  • package .tpkg: a zip with a manifest and assemblies; one package can hold several modules, and each package has its own isolated AssemblyLoadContext, so two packages can carry different versions of the same library;
  • context: the environment routes live in; by default each module gets its own context, and several modules can be gathered into one named context through Tsak:Contexts;
  • worker: the Tsak process that loads packages from the modules/ folder.

The worker itself can be deployed any way you like, and this is what settles the argument. One worker with all the packages is a monolith, a modular one. Ten workers with one package each are microservices. A cluster of workers over a shared database is microservices with failover. It ships in two forms:

  • container images in the GitHub Container Registry: redb-tsak-worker (the worker with the REST API and clustering), redb-tsak-web (a standalone web dashboard) and redb-tsak-stack (worker and dashboard in one container);
  • archives without Docker for Linux x64 and Windows x64 on the releases page: the worker, the dashboard, the CLI and start scripts inside, no .NET install needed on the machine.

You can try it with one command:

docker run -d --name tsak \ -p 9090:9090 -p 8085:8085 \ -e Tsak__Modules__AssemblyPaths__0=/app/worker/modules \ -v $PWD/modules:/app/worker/modules \ ghcr.io/redbase-app/redb-tsak-stack:latest # dashboard: http://localhost:8085, REST: http://localhost:9090 

The same module, without a single change to its code, can be deployed like this:

Shape What it looks like When it fits
Debug host A console app calls InitRoute.main itself, no Tsak Debugging under F5 with breakpoints
One worker, one package A microservice in the usual sense A separate zone, a separate load
One worker, many packages Modular monolith: packages isolated by dependencies, one process A small team, a shared release cycle
One package, several modules Each module in its own context or together in a named one Related modules of one product
Cluster of workers The leader assigns modules to live nodes Failover, growing load
No database, state in memory No PostgreSQL, no cluster, just the process Development, demos, embedded use

The container image is the same in every case; what changes is the mounted modules/ folder. Moving between shapes means moving a .tpkg file into another worker's folder and editing the context configuration. The routes stay the same.

The debug host looks like this (shortened, full version in EchoWorkerDemo; a ready-made host with a module is created by the dotnet new redb-worker template):

var services = new ServiceCollection(); services.AddLogging(b => b.AddSimpleConsole()); services.AddRedb(o => o.UseSqlite("Data Source=echo_demo.db")); var sp = services.BuildServiceProvider(); await sp.GetRequiredService<IRedbService>().InitializeAsync(ensureCreated: true); var ctx = new RouteContext(sp, contextId: "echo-worker"); EchoModule.InitRoute.main(ctx); // the same method the Tsak worker calls await ctx.Start(); 

The same module is packed into EchoModule.tpkg, dropped into the worker's folder and picked up by hot reload. Step by step this is covered in Two routes in one evening: from a debug worker to Tsak.

How modules talk to each other

Inside one process, modules from different contexts call each other through direct-vm:// (synchronous) or vm:// (asynchronous, through an in-memory queue), with no network and no serialization. When modules move into different processes, the address in the route changes: instead of vm://orders it becomes rabbitmq://orders, kafka://orders, http://... or gRPC. The address is a string, and it can come from the context configuration through {{key}} placeholders. Then moving a module into its own process does not touch even the route code:

From("{{orders.in}}") // vm://orders in one process, rabbitmq://orders over the network .Process(HandleOrder) .To("{{orders.out}}"); 

Changing the address does not repeal the laws of distributed systems, though. Inside a process direct-vm passes the message together with in-memory objects, while a broker needs a body that serializes. Network errors, retries, timeouts and message ordering appear, and request-reply depends on the transport. A call that was synchronous in one process will not be synchronous over the network.

So modules that may end up apart are better connected asynchronously from the start, through vm://, passing serializable messages from a shared contracts assembly. Then the move really comes down to configuration.

Where DDD fits in

Once deployment is taken out of the code, the main question remains: how to cut the code itself. DDD (Domain-Driven Design, Eric Evans) answered that long ago: along bounded contexts. Inside a bounded context words have one meaning and one model: an "order" in sales and an "order" in the warehouse are different models, even if they share a name. A service boundary drawn across such a context is exactly what produces a distributed monolith.

Uber arrived at the same place with DOMA: group domains, not individual services, and give each domain a single entry point.

In redb.Route these ideas map onto what already exists, with no extra framework:

DDD and DOMA In redb.Route and Tsak
Bounded context A module: its own routes, its own context, its own redb schemes
Domain of several services (Uber) Several modules in one package or in one named context
Domain entry point, gateway A direct-vm:// or vm:// route through which the module takes requests; nobody else reaches inside the module
Anti-corruption layer An integration module: accepts SAP or 1C formats and passes on messages in its own model
Published language The contracts assembly: the messages modules pass to each other
Layers Separate API, core and integration modules, connected only through the bus

We run three shapes in production.

One project is built as microservices: six packages on four workers. The API, the core with the business logic, the integrations with external systems and the audit each run separately; the API worker holds three packages, the other workers carry one each. Modules do not reference each other and talk only through RabbitMQ, shared types live in a library without an entry point, and a test enforces the rule: if someone adds a reference from one module to another, the test fails. Nothing stops you from putting all six packages into one worker: the code would not change.

Another project turned out as a monolith: one package with two modules in it, core and API, and one worker. Splitting it is easy too: the modules go into two packages, and each package moves to its own worker.

The third project runs as a Tsak cluster of three nodes. An HTTP facade sits behind the load balancer, and the cluster nodes exchange messages with the facade, with each other and with some external systems through RabbitMQ and Kafka.

The rule that follows: one bounded context is one module, and it is not cut across packages. How many contexts go into one package and how many packages into one worker is decided at deployment time and can change.

The same goes for data. redb lets you keep the schemes of all modules in one database, and for a small system that is convenient. But only the module that owns a scheme changes it and writes to it; the others get the data through its entry point. If a module takes its database by name from the start (context.GetRedbService("orders", exchange)), it can later move to a separate database with one connection string in the context configuration (Redb:orders), and nothing changes for its neighbours.

Operations are the same in any shape

The second half of the microservice price Fowler wrote about is operations: every service has to be rolled out, stopped, observed, rolled back. In Tsak that does not depend on whether you have one worker or twenty. It is covered in detail, with the configuration of a live project, in Microservices in .NET without building a platform. Briefly:

  • hot reload: drop a new .tpkg into the folder, and within a few seconds the worker brings up the new version, waits for the old one to finish the messages in flight, and only then stops it; other packages keep running; delete the file and the module is unloaded cleanly;
  • rollback: tsak module rollback brings back the previous version, the worker keeps several past packages;
  • graceful shutdown: on SIGTERM a node first leaves the cluster, then each context separately finishes the messages in flight within its own timeout;
  • Kubernetes probes: three separate endpoints for startup, liveness and readiness; liveness does not check modules, to avoid restart loops during a rollout, and readiness takes the pod out of load balancing if a context is down or a route has failed;
  • metrics and traces: a /metrics endpoint for Prometheus on the API port, OpenTelemetry traces over OTLP to Jaeger, Tempo or any collector; the repository has Kubernetes manifests, a Grafana dashboard and a docker compose file with Prometheus, Grafana and Jaeger;
  • logs: files through Serilog and an in-memory ring buffer readable through REST and in the dashboard;
  • watchdog: finds hung routes, which you can stop or restart from the dashboard;
  • cluster: nodes find each other through a shared database on PostgreSQL or SQL Server, elect a leader with protection against a stale leader, and the leader assigns modules to live nodes (round robin or least loaded) and reassigns them when a node disappears; a node can be taken out of assignment (cordon) and brought back;
  • management: a REST API, the tsak CLI and a Blazor web dashboard: contexts, routes, modules, logs, monitoring, the scheduler, cluster state, the dead-letter queue;
  • signed packages: the worker can be configured to refuse a package without a signature (ECDSA or RSA); images and archives are signed with cosign.

Sources, NuGet and your own worker

All of this is open source under Apache 2.0. The Tsak sources are in the redb-tsak repository, the routing sources in redb-route. The ready images and archives are there to get started quickly, but you do not have to build on them: everything is published on NuGet.

  • redb.Tsak.Core: the module runtime;
  • redb.Tsak.Core.Pro and redb.Tsak.Web.Pro: clustering and the web dashboard;
  • redb.Tsak.Contracts and redb.Tsak.Client: contracts and a typed REST API client;
  • redb.Tsak.CLI: the tsak command line as a dotnet tool;
  • redb.Tsak.Templates: project templates.

Your own worker comes from a template:

dotnet new install redb.Tsak.Templates dotnet new tsak-worker -n MyTsakHost 

Its Program.cs looks like this (shortened):

var builder = Host.CreateDefaultBuilder(args) .UseSerilog(/* ... */) .ConfigureServices((ctx, services) => { services.AddTsak(ctx.Configuration); services.AddTsakCluster(ctx.Configuration); // if you need a cluster }); await builder.Build().RunAsync(); 

From there you can add your own services to DI and your own health checks through IModuleHealthContributor. And to debug a module you do not need Tsak at all, as in the example above.

Where the limits are

  • Modules in one process are isolated by dependencies, not by failures. This is not a sandbox: a memory leak or an endless loop in one package affects its neighbours in the process. If a module needs failure isolation, it needs its own worker.
  • The cluster is coordinated through the redb database. Leader election, locks and the node registry sit behind interfaces, and you can register your own implementation in DI (for example, on the Kubernetes Lease API), but no alternatives ship in the box.
  • Packages are not copied between cluster nodes: each node needs the package in its own modules/ folder.
  • There is no staged rollout across nodes out of the box: nodes update a package independently. To roll out one by one, take a node out of assignment, update it and bring it back.
  • There is no Kubernetes operator, no CRDs of our own and no Helm chart yet: deployment uses plain manifests from the repository. They are planned for the next major version.

How I decide

For myself I reduced the question to a few signs. A module gets its own process if it has:

  • its own security zone. For example, in one of our projects the external customer-facing part runs in a separate cloud with its own brokers and database, and connections from it into the internal network are closed;
  • its own load profile that gets in the neighbours' way;
  • its own team and its own release cycle;
  • a need for failure isolation.

Everything else starts in one worker. When one of the signs appears, the module moves in half an hour, over a cup of tea: the configuration changes, the code stays as it was.

How do you decide?

I would like to hear how this works for you. Tell me in the comments:

  • What makes you carve out a service: team, load, security, domain?
  • Do you cut services along DDD bounded contexts, or did the boundaries grow on their own?
  • Did you start with a monolith and split it, or merge services back?
  • Is a database shared by several services acceptable for you, or forbidden?
  • How do you debug a chain of several services on your own machine?
  • Have you had a distributed monolith, and how did you get out of it?

  • Sources: redb.Tsak, redb.Route

  • Releases and archives: redb-tsak/releases

  • Images: all Tsak images on GHCR

  • NuGet packages: nuget.org/profiles/relikt

  • The ecosystem as a whole: redbase.app

If this was useful, a ⭐ on GitHub helps others find it.

More of my writing: redbase.app/articles, and on dev.to.