Microservice trade-offs
Prerequisite: node-modular-monolith-boundaries. Objective: Model failure and latency. Tested locally on Node.js 22.16.0 Linux. Each example is independent. Use a fresh disposable working directory, save as main.mjs, then run node main.mjs. The harness uses a five-second timeout and synthetic environment. These are static code blocks, not ByteMind interactive execution.
How it works
Compare both designs using the same workload and consistency requirements. Serial remote calls add dependency latency; parallel calls may reduce the critical path only when independent and within resource limits. A request can time out after the remote operation already completed. Do not blindly retry mutations; define idempotency keys and a bounded retry policy. Service discovery selects an endpoint, not an authorization decision. A failure budget and independent health signals help determine whether to degrade, fail or queue a request. The examples below are deterministic models, not measured network latency or distributed reliability.
Estimate serial and parallel critical paths
const calls=[25,40,15];console.log(calls.reduce((a,b)=>a+b,0),Math.max(...calls));Expected output:
80 40The model omits transport overhead and resource contention. Parallel execution requires independence.
Model graceful degradation for optional data
function response(catalog,reviews){if(!catalog.ok)return {status:503,body:'unavailable'};return {status:200,body:{name:catalog.name,reviews:reviews.ok?reviews.items:null}};}console.log(JSON.stringify(response({ok:true,name:'tea'},{ok:false})));console.log(response({ok:false},{ok:true,items:[]}).status);Expected output:
{"status":200,"body":{"name":"tea","reviews":null}}503Optional reviews may degrade to null; the essential catalog cannot. This is a policy model.
Common mistakes
Do not treat a timeout as proof a mutation failed, or a retry as harmless without an idempotency contract.
Practice
Compare a small bookstore monolith and a separately scaled review service; name the failure mode, deadline and ownership of each call.
Reference candidate: node-microservice-trade-offs-lookup (route unverified). Original application architecture reasoning and deterministic model; no external implementation claimed.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Microservice trade-offs — knowledge check
Apply the lesson to a fresh scenario and explain the evidence boundary.
Three independent calls have modeled durations 25, 40 and 15 ms. Ideal parallel critical path?
A mutation times out. What can the caller conclude?
What is an appropriate optional dependency failure policy?