slow deployment on heroku
See original GitHub issueOur deploys on heroku are taking quite a long time (30+ seconds) which incurs quite a bit of downtime during deployment. A second or two is acceptable, but 30 seconds is not. Any idea on how I can improve the speed of npm start
? Locally it runs significantly faster…
From logs:
2016-05-18T17:39:01.756601+00:00 heroku[web.1]: Starting process with command `npm start`
2016-05-18T17:39:05.413614+00:00 app[web.1]:
2016-05-18T17:39:05.413630+00:00 app[web.1]: > react-redux-universal-hot-example@0.9.0 start /app
2016-05-18T17:39:05.413631+00:00 app[web.1]: > concurrent --kill-others "npm run start-prod"
2016-05-18T17:39:05.413632+00:00 app[web.1]:
2016-05-18T17:39:07.267232+00:00 app[web.1]: [0]
2016-05-18T17:39:07.267242+00:00 app[web.1]: [0] > react-redux-universal-hot-example@0.9.0 start-prod /app
2016-05-18T17:39:07.267243+00:00 app[web.1]: [0] > better-npm-run start-prod
2016-05-18T17:39:07.267243+00:00 app[web.1]: [0]
2016-05-18T17:39:07.465188+00:00 app[web.1]: [0] Executing script: start-prod
2016-05-18T17:39:07.431925+00:00 app[web.1]: [0] running better-npm-run in /app
2016-05-18T17:39:07.465198+00:00 app[web.1]: [0]
2016-05-18T17:39:07.465198+00:00 app[web.1]: [0] to be executed: node ./bin/server.js
2016-05-18T17:39:38.524212+00:00 app[web.1]: [0] ----
2016-05-18T17:39:38.524224+00:00 app[web.1]: [0] ==> ✅ React Redux Example is running, talking to API server on 3000.
2016-05-18T17:39:38.524843+00:00 app[web.1]: [0] ==> 💻 Open http://localhost:20037 in a browser to view the app.1
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:5
Top Results From Across the Web
Your Heroku App Is Slow to Load Because Of This.
Click the + Monitor button · In the monitor type field select HTTP(s) · Fill the other fields with a name for your...
Read more >Speed up deployment on Heroku - node.js - Stack Overflow
It seems like as of today Heroku is finally caching the node_modules folder! -----> Deleting 6 files matching .slugignore patterns.
Read more >Tip: Debugging slow Heroku builds - Boring Rails
It's always best to follow a systematic approach when trying to speed up slow code. First, measure the current performance.
Read more >Heroku deployment is too slow · Issue #561 - GitHub
Heroku ignores devDependencies in the package.json file. Should you decide to save all packages into the primary dependencies group, the build ...
Read more >Limits | Heroku Dev Center
If your application requires more time to boot, you may use the boot timeout tool to increase the limit. However, in general, slow...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jtmarmon - Here’s an example you can check out that solves the heroku boot time issue: https://github.com/kengoldfarb/react-redux-universal-hot-example/pull/1/files
I’ve got a project based on this framework with a large codebase and have also seen the heroku build times become increasingly problematic…to the point that my app is failing to boot and I get the
R10 Boot Timeout
error.@Dattaya is spot-on that pre-building w/ babel-cli will fix this issue.
You’ll still have a few seconds of downtime on deploy (using free/hobby tier), but it’s nowhere near what it is with runtime transpilation.
@erikras - Is this something you’d want to incorporate back into the heroku branch?
Hope this helps!
Changes of note:
package.json changes to the
build-prod
andpostinstall
methods so heroku will compile everything prior to bootUse babel-cli to compile into the
dist/
directory.New
bin/server-prod.js
using pre-compiled files instead of runtime transpilationUpdate
.babelrc
to set aliases for some of the directories since this project doesn’t use absolute paths (otherwise node can’t find the modules after transpiling)redux/
directory to “myredux” to prevent confusion with the “redux” node module and then import like so:When requiring styles, check that they’re defined and/or set a default
I also had to change the entry point in
webpack.prod.config.js
to point to'./build/client.js'
instead of'./src/client.js'
(ofc babel loader is no longer necessary in prod.config), otherwise there was some mistake with styles. I guess alternatively it could be solved withrequire('./App.scss') || {};
? Tangentially related to #889