NextJS on Railway performance advice
benisenstein
PROOP

2 months ago

My NextJS app is built and ran in a Dockerfile with Bun. Durign local dev when running "next dev" everything works fine. But in the deployed environment, I'm seeing Link navigation and even fresh page loads stall for up to 30 seconds. Has anyone else encountered this running NextJS on Railway?

Link to source code: https://github.com/BenIsenstein/pgonrails/tree/main/site

0 Replies

crisog
PRO

2 months ago

I have a setup very similar to yours, except I'm using the Node runtime instead of Bun, and I haven't run into any issues.

I'm not saying you should switch, but if you haven't tried it, see if using the Node runtime improves things.


benisenstein
PROOP

2 months ago

Thanks, will do


benisenstein
PROOP

2 months ago

Have to run out until late, I'm a musician and play some gigs part time. But I'll report back tonight!


brody
EMPLOYEE

2 months ago

It sounds like you are running development mode when on Railway?


crisog
PRO

2 months ago

I checked his repo he does have a Dockerfile using the built standalone output


achaconm2001
PRO

2 months ago

I also tried in the past to deploy NextJS with Bun and ran into a lot of issues. Would also recommend to try with Node or use the new version of Bun (1.3)


brody
EMPLOYEE

2 months ago

Yes I noticed that too, but they could always be overwriting the start command in the service settings on Railway


crisog
PRO

2 months ago

True


benisenstein
PROOP

2 months ago

Gonna see how it does with bun 1.3, otherwise will move back to node and see how that goes. Then will look at more drastic measures, swapping all Next s for tags etc. It's my first time self-hosting a next app and disappointed to read so many have issues with Links, load times etc…


benisenstein
PROOP

2 months ago

The first GET has been hanging for over 30s 😭


benisenstein
PROOP

2 months ago

Went back to using node 22 and things are working. Thanks for your time everyone! I imagine the ins and outs of self-hosting NextJS will just take time… @CrisOG @Gary, el Pingüino Artefacto if you have any resources to read about prefetching, static-rendered routes, caching, I'd appreciate it 🙂


benisenstein
PROOP

2 months ago

Also still looking for help in my other thread, I'd really like to get my "PG On Rails" template to deploy successfully. Will try some things and then share an update there



Loading...