What a distributed system is, the eight fallacies of distributed computing, and how each shows up as a concrete bug in .NET services that call each other over the network.
A system is distributed when its parts run on different machines and coordinate only by sending messages over a network: there is no shared memory and no shared clock. That changes everything, because a remote call can be slow, fail, or succeed without you finding out. The fallacies of distributed computing are eight assumptions developers make that are false: the network is reliable, latency is zero, bandwidth is infinite, the network is secure, topology doesn't change, there is one administrator, transport cost is zero and the network is homogeneous. In .NET they show up as an HttpClient call with no sensible timeout, a downstream call inside a foreach, or a cached IP address that goes stale. The trade-off: distribution buys independent scaling and deployment, and you pay for it by handling failure in every call.
"A distributed system is a set of components on different machines that cooperate only by passing messages over a network. There's no shared memory, so one node can't just read another's state, and there's no shared clock, so they can't even agree exactly on when something happened. Everything a node knows about the others comes from messages that may arrive late, out of order, twice or never.
The fallacies of distributed computing, from Peter Deutsch and James Gosling at Sun, list the assumptions that make code look fine on a laptop and fail in production: the network is reliable, latency is zero, bandwidth is infinite, the network is secure, topology doesn't change, there is one administrator, transport cost is zero, and the network is homogeneous. In .NET the classic one is treating
await client.GetAsync(...)as if it were a local method call.HttpClienthas a default timeout of 100 seconds, so a slow dependency holds a request open for 100 seconds unless you set a real timeout. Another is calling a pricing service once per basket line in a loop: 40 lines at 20 ms each is 800 ms of pure waiting.The mistake I see is people adding microservices and then writing calls between them as if they were in-process. My rule is simple: every remote call gets a timeout, a decision about retries, and a plan for what the user sees when it fails."
| Fallacy | What really happens | Typical .NET bug | What you do instead |
|---|---|---|---|
| The network is reliable | Packets drop, connections reset, services restart | No retry, or a retry on a non-idempotent POST | Timeouts, retries with backoff, idempotency keys |
| Latency is zero | 0.5β2 ms inside an Azure region, 10β15 ms SydneyβMelbourne, ~150 ms to the US | Calls in a loop (N+1 over HTTP) | Batch endpoints, parallel calls with a limit |
| Bandwidth is infinite | Payloads cost time, especially on mobile | Returning the whole entity graph | Projection, pagination, compression |
| The network is secure | Internal traffic can be sniffed or spoofed | Plain HTTP between services, no auth | TLS everywhere, managed identities, zero trust |
| Topology doesn't change | Pods move, IPs change, DNS changes | A singleton HttpClient that never refreshes DNS |
PooledConnectionLifetime, service discovery |
| There is one administrator | Different teams and providers change things | Assuming you control the firewall or the gateway | Contracts, runbooks, observability across teams |
| Transport cost is zero | Serialisation, TLS and egress cost CPU and money | JSON serialising huge objects per call | Smaller contracts, gRPC where it fits |
| The network is homogeneous | Different OSes, proxies, MTUs, protocols | Assuming HTTP/2 everywhere | Negotiate protocols, test through real proxies |
| Local method call | Remote call | |
|---|---|---|
| Latency | Nanoseconds | Milliseconds to seconds |
| Failure | Exception, or it worked | Worked, failed, or unknown |
| Partial results | No | Yes (the other side may have done the work) |
| Ordering | Program order | Messages can reorder or duplicate |
A checkout API called a pricing service once per basket line. In Australia East this cost about 2 ms per call, so nobody noticed until a promotion pushed baskets to 60 lines and the pricing service slowed to 50 ms per call: checkout p95 went from 300 ms to over 3 seconds. Replacing the loop with one batch call and setting a 2-second per-attempt timeout brought p95 back to 350 ms.
Checks whether the candidate understands that remote calls are fundamentally different from local ones and can turn the fallacies into concrete engineering habits.
Green flags
Red flags
Inside one process, a method call either returns or throws, and memory is shared. Across machines you only have messages:
Service A Service B
| ---- request ----------> |
| (may be lost) | does the work (or not)
| <--- response ---------- |
| (may be lost) |
If A sees no response, it can't tell whether the request was lost, B crashed before doing the work, B did the work and crashed, or the response was lost. That ambiguity is the root of almost every distributed systems technique: timeouts, retries, idempotency, consensus.
Every machine has its own clock, kept roughly in sync by NTP or the cloud host. Clocks drift and can jump. So "event X happened before event Y" can't be decided reliably from timestamps written on different machines. This is why distributed systems use sequence numbers, versions and logical clocks for ordering.
HttpClient + IHttpClientFactory manage connection pools; SocketsHttpHandler.PooledConnectionLifetime recycles connections so DNS changes are picked up.Microsoft.Extensions.Http.Resilience (AddStandardResilienceHandler) adds total and per-attempt timeouts, retries with jitter and a circuit breaker on top of Polly v8.CancellationToken lets you stop work when the caller has gone.Distribution buys independent deployment, independent scaling, fault isolation and team autonomy. You pay with latency, partial failure and harder debugging. A modular monolith avoids most of the fallacies until you really need to split.
https://httpbin.org/delay/10 with the default HttpClient and time it, then set Timeout = TimeSpan.FromSeconds(2) and catch the TaskCanceledException.Stopwatch.tc (Linux) or a tool like Toxiproxy in Docker to add 50 ms latency and 5% packet loss between two containers, and watch what your service does.nslookup on a Kubernetes service before and after a rollout and note the changing pod IPs behind a headless service.A remote call that respects the fallacies: a typed client with a timeout and the standard resilience handler, compared with the naive version.
// Program.cs
using Microsoft.Extensions.Http.Resilience;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHttpClient<PricingClient>(c =>
{
c.BaseAddress = new Uri("https://pricing.internal"); // TLS even inside the network
})
// Total timeout, per-attempt timeout, retries with jitter, circuit breaker
.AddStandardResilienceHandler(o =>
{
o.AttemptTimeout.Timeout = TimeSpan.FromSeconds(2);
o.TotalRequestTimeout.Timeout = TimeSpan.FromSeconds(6);
});
var app = builder.Build();
app.MapPost("/basket/price", async (BasketDto basket, PricingClient pricing, CancellationToken ct) =>
Results.Ok(await pricing.PriceAsync(basket.Skus, ct)));
app.Run();
public sealed record BasketDto(IReadOnlyList<string> Skus);
namespace Checkout;
public sealed record Price(string Sku, decimal Amount);
public sealed class PricingClient(HttpClient http)
{
// Naive: one network round trip per SKU ("latency is zero")
public async Task<List<Price>> PriceOneByOneAsync(IEnumerable<string> skus, CancellationToken ct)
{
var prices = new List<Price>();
foreach (var sku in skus)
prices.Add((await http.GetFromJsonAsync<Price>($"/prices/{sku}", ct))!);
return prices;
}
// Better: one round trip for the whole basket
public async Task<IReadOnlyList<Price>> PriceAsync(IReadOnlyList<string> skus, CancellationToken ct)
{
using var response = await http.PostAsJsonAsync("/prices/batch", skus, ct);
response.EnsureSuccessStatusCode();
return (await response.Content.ReadFromJsonAsync<List<Price>>(ct))!;
}
}
HttpClient's default 100-second timeout. Why it is wrong: one slow dependency holds requests and threads open far longer than any user will wait. Instead: set per-attempt and total timeouts that fit your latency budget.HttpClient with default settings and keeping connections forever. Why it is wrong: it never re-resolves DNS, so it keeps talking to old addresses after topology changes. Instead: use IHttpClientFactory or set PooledConnectionLifetime.The fallacies aren't trivia; they're a checklist for code review. Every time a design adds a network hop, I ask four questions: what is the timeout, is it safe to retry, what happens to the user when it fails, and how much latency does it add to the critical path. If nobody can answer, the hop is not ready.
Cloud-native architectures make the fallacies more relevant, not less. A request that touched one monolith now crosses an API gateway, three microservices, a service mesh sidecar and a managed database, each a place where latency, failure and security assumptions break. The senior response is architectural, not just a retry policy:
PooledConnectionLifetime.The other senior move is knowing when not to distribute. A lot of pain comes from splitting a system before the team needs independent deployment or scaling.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| In-process call (modular monolith) | One team, shared release cadence | Coupled deployment | Parts need very different scaling or ownership |
| Synchronous remote call (HTTP/gRPC) | Caller needs the answer now | Latency, partial failure, cascading outages | Long chains of calls on the request path |
| Asynchronous message (Service Bus) | Work can finish later | Eventual consistency, duplicate handling | User needs an immediate, consistent answer |
For most APIs, latency Γ number of round trips dominates, not bandwidth. A request that makes 50 sequential database calls at 2 ms RTT spends 100 ms on the network; move the database to another region at 30 ms RTT and it spends 1.5 s. Fix it by reducing round trips (batching, joins, fewer chatty calls), moving compute near data, caching, and parallelising independent calls.
Partial failure means part of a distributed system fails while the rest keeps running, and no single node can see the whole picture. The sharpest example is a timeout: when your call to the payments service times out, the request might have been lost, the service might have crashed before or after charging the card, the response might have been lost, or it might still be running. A timeout means the outcome is unknown, not that it failed. So calling code must be written for the unknown: make the operation idempotent (or send an idempotency key) so a retry can't do the work twice, or look up the outcome by a client-generated id before retrying, and run reconciliation for anything left in doubt. The trade-off is extra design work on every write that crosses the network.
Retry handles transient faults: a network blip, 503, 429 or a timeout that will probably succeed if you try again shortly.
Retry-After), connection errors and timeouts. Never retry 400, 401, 403, 404, 409 or validation failures.The danger is amplification: retries at the API, service and client layers multiply, which creates a retry storm against a recovering dependency. Retry at one layer and pair it with a circuit breaker.
In .NET 10 it's Polly v8 (AddRetry) or AddStandardResilienceHandler (3 retries, exponential, jitter, 2 s base). The trade-off is higher success rates against extra load and latency.
Last updated 23 Nov 2026.