Moleculer Local Transporter with Cache Mixin: Setting Cache TTL for Low‑Traffic Services
0 reputation · 04 Mar 2023, 08:39 UTC
Goal
Reduce operational cost for a low‑traffic Moleculer microservice by using the Local Transporter to avoid external broker fees while leveraging the built‑in cache mixin to cut downstream calls.
Constraint / Uncertainty
Increasing cache TTL improves hit rate and saves compute, but raises memory consumption; with the Local Transporter all services run in‑process, so excessive caching can trigger OOM or leave stale data. The framework does not prescribe a default TTL, leaving the trade‑off unresolved.
What cache TTL provides the best balance between memory usage and hit rate for a service handling fewer than 10 requests per minute? How can memory impact of the cache be measured without affecting request latency? Should the cache be disabled entirely when traffic drops below a threshold, and if so, how is that threshold determined?