Skip to content

Moving from Node to Bun spikes container CPU and memory usage until it crashes #17723

@rbilgil

Description

@rbilgil

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.

Image

Image

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 separately. No difference.
  • bun version used: 1.2.2 (I also tried 1.2.4 but I get a segfault on startup)

At this point this is the only reason we can't fully migrate to bun, so any insight would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions