Nextjs app not being compressed and slower than expected
joncoronel
TRIALOP

a year ago

Looking for options to move away from hosting nextjs on vercel.
Was able to deploy my nextjs app to railway without any errors but it seems to be much slower than when deployed on vercel or cloudflare. When I run pagespeed on it, it flags text compression as an issue on railway but not on the other deployments. Also tested out deploying the same app on Render and that does not have this issue.

I also noticed that pagespeed insights also indicate that the unused javascript is much larger on the railway deployment than any of the others. 700mb vs 130mb.

Not sure what the issue is.
In the images, railway is the one with the text compression flag and larger unused javascript. The other image is of the Render deployment.

14 Replies

joncoronel
TRIALOP

a year ago

23257359-c206-42e7-8add-b74bf5caac64


brody
EMPLOYEE

a year ago

railway is only ever going to run your code / app as-is, so any issues in this regard would be due to missconfigurations on your part.

for example, maybe you are having railway run next in development mode


joncoronel
TRIALOP

a year ago

Hmm, I did follow the guide for nextjs in the railways docs. I simply pointed at the github repo for my app and it was pretty simple to deploy. I did the exact same thing on Render and Vercel. Just pointed to the exact same github repo. All have the same env variables as well and running on the same node version.


joncoronel
TRIALOP

a year ago

and based on logs, it is running in production mode through next build -> next start


brody
EMPLOYEE

a year ago

yep as mentioned, railway will only ever run your code as-is, vercel and render do a lot of hand holding in this regard


joncoronel
TRIALOP

a year ago

I looked through the logs and I don't see anything out of the normal for the deployment. I did see other posts in regards to railway not compressing but I thought next automatically compressed during the build process?


brody
EMPLOYEE

a year ago

nothing to do with railway here, the user would be responsible for setting up the next project with the correct build settings


brody
EMPLOYEE

a year ago

I would recommend to read next's docs for improvements you could make to your config


joncoronel
TRIALOP

a year ago

Okay yeah that was on me. Seems its a vercel specific thing where nextjs is automatically compressed. Does not apply to other hosts.
Resolved this by setting up a cloudflare proxy which automatically compresses.


joncoronel
TRIALOP

a year ago

Sidenote: Deploying nextjs on railway was very easy. Might actually switch over now that I resolved this.


brody
EMPLOYEE

a year ago

glad to hear that, deploying next on railway is easy as long as you are aware oh how railway works (or doesn't work)


joncoronel
TRIALOP

a year ago

Unrelated but quick question: I wouldn't be able to set a custom domain for both a [www.[website.com](website.com)](www.[website.com](website.com)) and [website.com](website.com) unless I upgrade to a paid tier right?


brody
EMPLOYEE

a year ago

correct, 2 custom domains is a hobby plan thing


brody
EMPLOYEE

a year ago

but on the bright side, you'd eventually need to upgrade anyway


Loading...