Questions and discussions about using the Shopify CLI and Shopify-built libraries.
Hello. Recently I've been exploring deployment options for the base node/react app generated by the Shopify CLI and I've noticed something odd:
No matter which option I choose for deployment (Heroku, Google App Engine, and Google Cloud Run are the three I've tested), the initial load time is extremely high (typically between 11 and 21 seconds!). Subsequent load times are much more reasonable, anywhere from a few hundred milliseconds, to 2 seconds on the slow side.
Through my research I've discovered that part of the problem is "Cold Boot Times" for the different deployment options listed above. This makes some sense of course, since the hosting server needs to spin up an instance to serve the initial request. However the added startup time due to the cold boot of an initial instance doesn't appear to be the only problem here, since deploying a similar next/koa app without the shopify-api (v1.2.1) and koa-shopify-auth (v4.1.2) modules produces cold boot times that are between 1 and 3 seconds.
This issue is quite a large one, as apps are rejected during the review process for slow load times, a reasonable cause for rejection to be sure. However, it seems as though the Shopify provided example app wouldn't pass the shopify review process either.
My questions are:
Thank you all for your help!
Jonathan.
It sounds like the development version is being deployed, which includes just-in-time compilation of assets, etc. You'll need to build a production version
$ npm run build # which runs `next build`
then run/deploy the application using
$ npm run start # which runs `NODE_ENV=production node server.js`
To learn more visit the Shopify Help Center or the Community Blog.
@mkevinosullivan, thank you so much for the prompt reply. Unfortunately, this is not the case.
Specifically in App Engine (my preferred hosting solution at the moment) the deployment knows to start the app using the specified script in package.json:
"start": "cross-env NODE_ENV=production node ./server/index.js"
Do you have any other suggestions for this issue?
Thank you again!
JM.
Bump...
Is anyone else experiencing this issue?
Thanks!
JM.
Hi Jonathan, I have the same problem, did you manage to solve it?
Experiencing same issue. How it is possible that official sample is so bad???