Dynamic V8 Heap Resizing for Kubernetes In-Place Scaling (--max-old-space-size-percentage)
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
What is the problem this feature will solve?
Node.js supports percentage-based heap configuration via --max-old-space-size-percentage. However, this flag currently calculates V8's maximum old space size only once at process startup based on initial system or cgroup memory limits.
Kubernetes supports in-place resource resizing (InPlacePodVerticalScaling), which alters container memory limits dynamically at runtime without restarting the container. Because --max-old-space-size-percentage evaluates only at startup, it cannot react to runtime cgroup changes:
- Memory Upscaling: If Kubernetes increases a running container's memory limit, Node.js remains restricted to the initial V8 heap limit calculated at startup, failing to utilize the newly available RAM.
- Memory Downscaling: If Kubernetes decreases the container's memory limit below the initial V8 heap allocation, the container risks being terminated by the Linux Out-Of-Memory (OOM) killer before V8 triggers garbage collection or lowers its heap boundary.
To fully support zero-downtime Kubernetes in-place resizing, --max-old-space-size-percentage needs to dynamically recalculate and apply heap limits when cgroup memory parameters change at runtime.
What is the feature you are proposing to solve the problem?
Extend --max-old-space-size-percentage to actively monitor cgroup memory limit changes and adjust the V8 heap size dynamically during process execution.
Example Workflow
# Enable percentage-based allocation
node --max-old-space-size-percentage=80 app.js
- Initialization: Container starts with a 2 GiB memory limit. Node.js evaluates
--max-old-space-size-percentage=80and sets V8 max old space to~1.6 GiB. - Kubernetes Event: Kubernetes resizes the running pod in-place from 2 GiB to 4 GiB memory limit.
- Event Detection: Node.js detects the cgroup change event.
- Runtime Update: Node.js recalculates 80% of 4 GiB (
~3.2 GiB) and adjusts V8's isolate limits dynamically while the application continues processing traffic.
What alternatives have you considered?
No response
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Implementierung von --max-old-space-size-percentage und den cgroup-Speicherparametern, die es liest, und untersuche anschließend, wie die Limits von V8-Isolates zur Laufzeit aktualisiert werden können. Validiere das Design anhand von Kubernetes InPlacePodVerticalScaling sowie sowohl einer Erhöhung als auch einer Verringerung des Speicherlimits; abgeschlossen ist die Arbeit, wenn der Prozentsatz nach Änderungen des Laufzeitlimits ohne Neustart erneut angewendet wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, kubernetes, nodejs
- Bereich
- backend, cloud, operating-systems, performance
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100