ram usage local vs production
ghostorder28
HOBBYOP

2 years 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

ghostorder28
HOBBYOP

2 years ago

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


brody
EMPLOYEE

2 years ago

are you running it with pm2 when on railway?


ghostorder28
HOBBYOP

2 years ago

oh, no


brody
EMPLOYEE

2 years ago

okay that's a good thing


brody
EMPLOYEE

2 years ago

how are you having railway run your app


ghostorder28
HOBBYOP

2 years ago

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


brody
EMPLOYEE

2 years ago

@MantisInABox is 370mb bad for a next app?


ghostorder28
HOBBYOP

2 years ago

next version is 14


ray-chen
EMPLOYEE

2 years ago

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)


ghostorder28
HOBBYOP

2 years ago

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


ghostorder28
HOBBYOP

2 years ago

this is the graph for the last 30 days

1219811302092836900


ghostorder28
HOBBYOP

2 years 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


vin
PRO

2 years ago

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


ghostorder28
HOBBYOP

2 years 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


vin
PRO

2 years 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


ghostorder28
HOBBYOP

2 years 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


ghostorder28
HOBBYOP

2 years ago

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


Loading...