Blog

The dream monolith with an escape hatch

2 min read

Build one program, deploy one binary, and when one part gets busy, give it copies of its own, without changing a line. The escape hatch is a flag, not a rewrite.

Every team knows the trade. A monolith is fast to build, simple to deploy and easy to reason about, until one part of it needs ten times the capacity of the rest. Microservices let that part scale alone, and cost a network boundary in every call, a deployment per service, and a rewrite to get there.

The dream is a monolith you never have to rewrite: one program while it is small, and copies of its heavy part when it is not, with the same code throughout.

One program

// app.qweservice /shop = "shop.qwe"service /risk = "risk.qwe"// shop.qweservice risk = "risk.qwe"route POST /checkout {    let verdict = risk.assess(request.form.order)?    verdict.ok ? <p>Thank you</p> : reply 402 "Payment refused"}

risk.assess calls a server fn in risk.qwe. Run as one process, it is a function call.

The escape hatch: a flag

quillo run app.qwe --split --scale risk=3

Now risk runs as three processes of its own, called in turn, and shop.qwe has not changed. The calls are signed, retried at the next copy when one does not answer, and run once: copies that share a database share the calls they have answered, so a retry never charges twice.

Growing while it runs

quillo run risk.qwe --as-service --port 8081 --join http://app:8080

A copy started on another machine joins the running app. The app calls the joined copies first and falls back to its own. A monolith that takes on help as it gets busy, and lets it go when the copies stop, again without a line of either changed.

Knowing it is ready

The decision between monolith and services moves from the first week to whenever it is needed, and it is made with a flag.

Read more: Microservices in the docs.

The Quillo newsletterNew posts, components and plugins, about once a week. No tracking.

Thread
6Useful? Like it, or add to its thread below.

Thread 0 posts

On The dream monolith with an escape hatch: questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.