question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

slow deployment on heroku

See original GitHub issue

Our 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:open
  • Created 7 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

2reactions
kengoldfarbcommented, May 19, 2016

@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 and postinstall methods so heroku will compile everything prior to boot

  • Use babel-cli to compile into the dist/ directory.

  • New bin/server-prod.js using pre-compiled files instead of runtime transpilation

  • Update .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)

    • On a related note, I had to alias the redux/ directory to “myredux” to prevent confusion with the “redux” node module and then import like so:
    import {isLoaded, load as loadWidgets} from 'myredux/modules/widgets';
    
  • When requiring styles, check that they’re defined and/or set a default

    • This feels a little hacky to me. There’s probably a better way to do this. I’m using more traditional styles (not component-specific) in my project so I didn’t spend much time on this part
const styles = require('./App.scss') || {};
0reactions
Dattayacommented, May 20, 2016

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 with require('./App.scss') || {};? Tangentially related to #889

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found