Next.js Discord

Discord Forum

Production build x20 high server time responses than dev mode

Unanswered
Harez posted this in #help-forum
Open in Discord
Hello everyone! I've developed a straightforward engineering tool designed to perform calculations on various engineering parameters. Essentially, the application receives inputs that are then transmitted to the server through a server action. The server handles the calculations and subsequently sends back the results. If you're interested, you can check out the app here: https://k-factor.vercel.app/

Now, onto the issue: During development, I noticed that the client's waiting time for the server response was minimal, around 40ms. However, upon deploying the app on Vercel, I observed a decrease in performance. The client was now waiting for the server response for approximately 1000ms.

Why is this happening. One would expect that the production build, along with minifications, should enhance the app's performance. Any insights into why this disparity exists would be greatly appreciated

17 Replies

Could you share a code or minimal reprodution with us?

From my experience, most often it's caused by mapping and looping, as serverless functions are executed on nodes with 1 core, but dev env is using all cores on your PC 😉
Im trying to share the code but get a "text is to long" warning, here are the screenshots:
its not really a heavy code
cold start i think?
Yes, cool start penalizes the initial connection with the server; nevertheless, why does the response time still exceed that of the development mode, with 200 ms versus 40 ms? The code on the server side isn't complex, and my intention is to build an even larger web app without compromising performance
Is that difference between production and dev expected?
Best if you will dig into edge runtime and openTelemetry if cutting-edge performance is your no.1 target.

If you will require node runtime - from solutions which I call petting "twine-solution", you can prime every endpoint from outside of application to make cold-boot calls not be called by users (in high-traffic apps often users are such bots 💀 as it's a really small % of low performance calls at all)
Ok, will dig into edge runtime and/or endpoints from outside and see how it works. Thanks guys for the info!!
Hope it helps, If you will run into any trouble - feel free to get back to us 🙂

Also - consider monitoring you Real-World performance (I'm using free sentry.io for that)
Blue whiting
@Harez i am facing the same issue at the moment +2 sec server time response. Do you mind sharing what your solution was ?