ram usage local vs production

ghostorder28HOBBY

a year ago

Hello, I realized the memory consumption of my nextjs app differs between local and prod, when I run it locally pm2 shows 68mb on memory consumption whereas in production the same app consumes 370mb more or less on average.

Is it normal that an app consumes more memory in production than in local?

1 Replies

ghostorder28HOBBY

a year ago

93ff8b35-df80-4f04-9f54-b6e4fa647fbf


a year ago

are you running it with pm2 when on railway?


ghostorder28HOBBY

a year ago

oh, no


a year ago

okay that's a good thing


a year ago

how are you having railway run your app


ghostorder28HOBBY

a year ago

I use the default scripts from create-next-app , so "next build" "next start", railway runs those after I update my github repo


a year ago

@MantisInABox is 370mb bad for a next app?


ghostorder28HOBBY

a year ago

next version is 14


Does it keep increasing? That's sort of expected as Next caches stuff in memory. It'd also be more pronounced on images (next/image)


ghostorder28HOBBY

a year ago

mmm, it does after I redeploy the instance (because of repo updates) but after some days it becomes stable I would say


ghostorder28HOBBY

a year ago

this is the graph for the last 30 days

1219811302092836900


ghostorder28HOBBY

a year ago

I know memory usage at the end of the day comes down to the quality of my code or packages I use in my project, but my concern is about the difference between the usage in local vs production


a year ago

A default next app will use roughly 100MB, so, depending on complexity, this could be extremely normal


ghostorder28HOBBY

a year ago

I see, and is it expected that ram consumption differs between local development and production? it's 65mb when running locally on my pc vs 370mb when running in production


a year ago

It will vary yes, but I don't believe it should be that much. But then again, locally, you are using dev which doesn't cache things. In memory cache is what would eat that up


ghostorder28HOBBY

a year ago

I see, I'm using dev in local yes, but also I run next start to test the app before deploying it to production


ghostorder28HOBBY

a year ago

I'll check the cache then, thank you for the help guys


ram usage local vs production - Railway Help Station