Unbounded Node.js In-Memory Cache Pushes Memory From 3.4 MB to 200 MB Under Load
A developer ran a Node.js service that cached HTTP responses in a plain Map with no size limit. Load testing with 4,000 requests, each using a unique URL, drove resident memory from 3.4 MB to 200.1 MB with no plateau, since the Map kept every entry reachable. The developer fixed the problem by capping the cache size and evicting the oldest entries, which kept memory flat at 13.6 MB under the same traffic and throughput. The write-up argues that unbounded in-memory caches are a memory leak that often only surfaces in production. It recommends a hard size limit with an eviction policy such as LRU, a TTL for stale data, and load testing with unique keys before shipping.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in