a year ago
My Next.js app, which contains a GraphQL API running with it, is using a lot of memory. I tested it locally in production mode and after each request, the RAM usage goes down, but it stays very high in the deployed version.
While I was testing this, suddenly the Postgres instance started throwing out-of-space errors:
2024-03-13 17:09:55.891 UTC [36] ERROR: could not extend file "base/16384/40967": No space left on device
2024-03-13 17:09:55.891 UTC [36] HINT: Check free disk space.
I just migrated from trial to hobby. Isn't it supposed to have 100GB of disk space?
13 Replies
a year ago
Project ID: 0d312ae0-c766-47e1-aad9-4d1ce4c968c7
a year ago
Also, I couldn't find anywhere the disk usage information.
Where can I find this data?
a year ago
I'm still investigating this and trying to understand what's happening.
The disk space issue seems to have gone away… No idea what happened.
It would be really nice to be able to see what the disk usage of the project is.
Now, for the memory issue, again, this doesn't happen locally.
When I send heavy requests to my server I get a memory spike up to 1.5GB and it goes down to somewhere between 200MB to 500MB just a few seconds later.
Now, when running in Railway, it just stays up there from 900MB to 1.5GB.
I added memory logs to my app and here's what I see:
rss 966.4375
heapTotal 59.71484375
heapUsed 56.559288024902344
external 4.268109321594238
arrayBuffers 0.08364677429199219
Is this an OS thing? How the image is configured?
Is it configured to not free up memory?
My app itself is clearly not using a lot of memory and there's no memory leak, otherwise, it would be replicable locally too.
It's really annoying to be charged by the MB and see my server retaining memory like that.
a year ago
I just migrated from trial to hobby. Isn't it supposed to have 100GB of disk space?
hobby users get 5gb volumes, but if you created that volume while on the trial plan you would still have it set to 500mb, you can grow it to 5gb from within the volumes settings.
I couldn't find anywhere the disk usage information. Where can I find this data?
you can see the used disk space, click on the volume and there will be metrics.
as for the sticky memory, railway is not keeping your memory around so they can charge you more, my best advice for this would be to first get the environment railway runs your app in as close to the environment that you run your app in locally, same node version, etc etc.
a year ago
Hey Brody, thanks for the reply.
I just saw I can add a volume to my project, but I never did.
Is it currently using some implicit volume then?
Also, under my account settings, I see 100GB of shared disk space, as the attached screenshot shows.
As for the memory, I started using a Dockerfile with the node-alpine image.
It got better now, but still not ideal.
I'm testing the exact same image locally and in Railway.
With the exact same request, locally the memory goes up to ~500MB and goes back down to ~220MB.
In Railway it stays at around 500… How is that possible? How can the same image behave differently?
Also, it's very disappointing that the default image behaves as it does when memory is charged by the minute.
The default images should be properly configured to have a memory allocator that keeps the usage down.
Attachments
a year ago
that would be 100 GB of empherial container storage, not the same as a volume, though any of the databases do come with volumes when you deploy them.
for the sticky memory, I'm going to escalate this to the team, and for the team member who sees this, do you think you could look at the containers raw statistics to see if the app is actually not freeing that memory?
andrehil, can you make that request and leave the service untouched at the higher memory usage so the team can look for any discrepancies.
a year ago
This thread has been escalated to the Railway team.
Status changed to Awaiting Railway Response brody • about 1 year ago
a year ago
Hi Brody, while inspecting all the details I found that I still had an env var in Railway setting the max old space size.
I removed that to see if anything would change and it did.
The RAM is now dropping to ~200MB just like my local docker container.
Still, as feedback, please consider tweaking the default images or using different ones (like the alpine image for node).
Without changing anything in my app, it's now running with 200MB when idle, while it was hogging more than 1GB before.
As for the storage space, I didn't realize the volume shows up underneath the database service, I see now how much space is being used.
I'll try to create a new volume and transfer the data from the old volume to the new one. As you said, it is limited to 500MB right now.
a year ago
Oh, I actually just saw there's a Grow
option under the volume settings.
Thank you for the help and please take into consideration my feedback!
a year ago
Yes, sorry, I missed that.
a year ago
I am facing the same RAM issue. On high usage on my local environment ram peaks and goes down to around 180 MB but on railway my node app stays around 500 MB. Did you kept the railway image or change the image to alpine ?
a year ago
I ended up creating my own Dockerfile with the Node Alpine image.
FROM node:21.7.1-alpine3.19
WORKDIR /app
COPY ./ /app
RUN npm install
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]
a year ago
Thank you