I have an EKS cluster with a nodejs application ru...
# kubernetes
i
I have an EKS cluster with a nodejs application running in the pods. I have noticed that if the memory of the nodejs application increases beyond 512MB it just crashes. I have increased the pod memory but how do I increase the nodejs memory as well.
s
Do you have limits set on the containers and pod?
i
What kind of limits are you talking about?
t
We've been able to run NodeJS apps with more memory with the
--max-old-space-size=<size in MB>
flag in a
NODE_OPTIONS
env var for the pod. Then set the pod memory request and limit at a slightly higher value. We keep pod's memory request and limit at the same value, which is a conservative approach, depending on your workload you might have the memory request a bit lower than the limit, to optimize for the scenario that not all pods actually use memory up to their limit.
l
Node.js has a default memory limit of 512MB. This limit can be increased using the
--max-old-space-size
flag. The value for this flag is specified in megabytes. Also, you will need to update your Kubernetes deployment YAML file to include the
--max-old-space-size
flag in the command or args section of your container definition. Once you have updated the deployment YAML file, apply the changes using kubectl and monitor the application
m
On the other hand, one should optimize the app itself, as a memory leak would happen sooner or later, increasing the memory has just shifted it away.