<p>I have nodejs application running on Kubernetes with limits:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
..
spec:
  ..
  template:
    ..
    spec:
      containers:
      - name: mynodejsapp
        ..
        resources:
          requests:
            memory: "1000Mi"
            cpu: "500m"
          limits:
            memory: "2000Mi"
            cpu: "1000m"
        ..
</code></pre>

<p>And my Dockerfile for my nodejs application is based on <code>node:10-slim</code>:</p>

<pre><code>FROM node:10-slim
..    
COPY . .
RUN npm run build
EXPOSE 3000
ENTRYPOINT ["dumb-init", "--"]
CMD [ "node", "./build/index.js" ]
</code></pre>

<p>I find some older posts that <code>--max_old_space_size</code> <a href="https://stackoverflow.com/questions/47704440/does-nodejs-respect-docker-virtualization-and-resource-limits">should be set</a>. Is that correct? Or will nodejs process automatically find existing memory limitations?</p>

<p>With Nodejs 10 it's bad, because on 64bits OS it could exceed your limit value. It should be fine with Nodejs 12, however If you want scale pods using CPU activity, setting max old memory is a good idea. The GC will try to stay under this value, (so under your k8s request memory) and the CPU activity will grow up. I've write a post <a href="https://loadteststories.com/nodejs-kubernetes-an-oom-serial-killer-story/" rel="nofollow noreferrer">here</a> on this subject.</p>
