Moving from Node to Bun spikes container CPU and memory usage until it crashes
I'm working on a branch to move from node to bun as our runtime. The docker container builds successfully, and on the surface the service seems to run without any errors. However, we're seeing very high memory & CPU usage after deploying the service onto GKE, which quickly leads to a service restart. No errors are being emitted, and the service seems responsive when it's running. Services use about ~500MB of memory when running on node, but the memory quickly spikes to the container limit of ~1.2GB when running on bun. **Note:** We have been using `bun` to run these same services locally on MacOS for over a year without any issues. I've attached a screenshot of our CPU / Memory usage during the bun deployment. The only thing that changed in that time is two lines in the Dockerfile, image also attached.   Note that the image shows us running `CMD [ "bun", "--max-old-space-size=4096", "--enable-source-maps", "./index.js"]`, I removed the source maps and `max-old-space-size` args in one test and it didn't fix the issue. ## More context about our setup - We build a single JS file using `ncc` for each service - Service is built as a docker container and deployed onto GKE - I tried the deployment both with the `oven/bun:alpine` image and also our usual `node:alpine` image with bun installed separat
Posted by rbilgil on Feb 26, 2025, 4:34 PM
Tags
Related issues
Raise real-world problems, find people facing the same issue, and discuss solutions.2,000 issues0 comments
onboarding (Marketing)
Moving from Node to Bun spikes container CPU and memory usage until it crashes
I'm working on a branch to move from node to bun as our runtime. The docker container builds successfully, and on the surface the service seems to run without any errors. However, we're seeing very high memory & CPU usage after deploying the service onto GKE, which quickly leads to a service restart. No errors are being emitted, and the service seems responsive when it's running. Services use about ~500MB of memory when running on node, but the memory quickly spikes to the container limit of ~1.2GB when running on bun. **Note:** We have been using `bun` to run these same services locally on MacOS for over a year without any issues. I've attached a screenshot of our CPU / Memory usage during the bun deployment. The only thing that changed in that time is two lines in the Dockerfile, image also attached.   Note that the image shows us running `CMD [ "bun", "--max-old-space-size=4096", "--enable-source-maps", "./index.js"]`, I removed the source maps and `max-old-space-size` args in one test and it didn't fix the issue. ## More context about our setup - We build a single JS file using `ncc` for each service - Service is built as a docker container and deployed onto GKE - I tried the deployment both with the `oven/bun:alpine` image and also our usual `node:alpine` image with bun installed separat
Comments (0)
No comments yet. Start the discussion.