Everyone Said 'Just Go Serverless.' I Ran a Long-Lived Node Process — Here's What That Bought
[ EXECUTIVE TEARDOWN // TL;DR ] A real-time product is defined by the connection that stays open, and the economics of serverless assume nothing stays open. In-process state turns per-message Redis round trips into memory reads, and fan-out into a loop rather than thousands of billable invocations. The honest cost: draining deploys, scaling decisions and memory discipline become mine — roughly a…
The serverless trend is popular, with the mantra "just go serverless" often cited. However, the example provided illustrates why this advice isn't always perfect. A real-time product, defined by maintaining open connections, presents a different set of challenges and costs compared to traditional request-response workloads. When the product involves keeping thousands of connections open and pushing telemetry as it happens, a long-lived Node process might be more suitable.
This approach avoids the costs associated with serverless, such as per-message Redis round trips and fan-out that turns into a loop with billable invocations. Instead, it allows for state that survives between messages, fan-out as a loop rather than separate invocations, and the ability to apply backpressure. While serverless shines for request-response tasks, it falls short for real-time products where maintaining connections is paramount.
The decision to run a long-lived Node process is significant, as it involves draining deploys, making scaling decisions, and managing memory discipline. This decision comes with its own set of costs, such as deployment without dropping connections, scaling decisions, and managing memory discipline.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.