Minimum memory usage required for a simple Node.js express server

Hi, just curious how much memory your Node.js applications require? Mine requires to scale to 2 GB otherwise it won’t even build.

I’m seeing 85 MB in the dashboard with the following application:

app.js:

const express = require('express')
const app = express()
const port = 8080

app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})

Dockerfile:

FROM node:lts

WORKDIR /app

COPY . .

RUN npm install

CMD [ "node", "app.js" ]

Hi,

You will likely see very different numbers between the one-time memory usage at build-time, and the ongoing usage at run-time. You may well need 2GB to build the image, however that should be fine as either you build locally (most computers will have at least that much), or use a remote builder provided by Fly. Not sure what spec the latest ones have but they should be pretty big e.g

Once your app has a built image, then the question is how much RAM it uses to run. As @rubys says, a basic Nodejs app will run on even the smallest instance (comes with 256MB). You can monitor your usage in the metrics.

1 Like