Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Speed up deployment on Heroku [duplicate]

Heroku is great. But every time I deploy, Heroku seems to like to redownload and rebuild all the packages. With socket.io and mailparser this is taking around 3 minutes.

Is there a way to speed up the deployment process? Is there a way to tell Heroku that it can cache these items? Or can I upload prebuilt node_modules?

like image 341
Alexis Avatar asked Jan 17 '13 02:01

Alexis


People also ask

How many requests per second can Heroku handle?

These may be conducted without any need for approval from Heroku, so long as they're limited to 10,000 requests/second for any given application. This applies to all regions for the Common Runtime.

How do I reduce Heroku slug size?

The easiest is to add a . slugignore file to your application to tell the slug compiler to ignore any unnecessary files in your application, such as static assets. This can be helpful in determining where large files are. You may also find that clearing the build cache helps reduce the size of the slug.

Why is Heroku so slow?

To preserve your dyno hours from burning out or wasting, Heroku puts your app to sleep after 30 minutes of inactivity. How generous! This is what makes your app is slow to load.

Can multiple people push to Heroku?

Heroku makes it easy to collaborate with others. You can permit collaborators to deploy changes to your apps, scale them, and access their data, among other operations.


2 Answers

I'm running into the same problem.

Some discussion here about caching the node_modules folder: https://github.com/heroku/heroku-buildpack-nodejs/pull/37

Another idea: https://github.com/heroku/heroku-buildpack-nodejs/issues/25


I'm thinking about a few solutions right now.

  1. Check in node_modules in a separate branch: The core Node.js maintainers actually recommend checking in the node_modules folder into source control (for apps, not libs). I don't like this. A way to get around it though might be to have a separate production branch with a different .gitignore file that doesn't ignore node_modules. When you want to deploy, just do a rebase from your master and node_modules will be checked in. At least this keeps your master branch free from dependencies.

  2. Add a preinstall script to package.json to download compressed dependency zip: You could also add a pre-push git hook to bundle up your dependencies and upload them to S3. This would probably be too slow though.

  3. Modify the heroku-buildpack-nodejs: Integrate the outstanding pull request with node_modules caching:

    heroku config:set BUILDPACK_URL=https://github.com/opdemand/buildpack-nodejs.git

like image 53
vaughan Avatar answered Sep 21 '22 21:09

vaughan


One thing I did to speed up process was to add .slugignore file to the main folder and add all the files and folders I did not want to run the app.

Sample content of .slugignore file:
working
mockups
*.psd
*.pdf

like image 33
Wasula Kankanamge Avatar answered Sep 22 '22 21:09

Wasula Kankanamge