Search code examples
node.jsmongodbherokumeteor

DB migration on multiple Heroku Dynos


I have a simple migration script for a Meteor app. On startup, it runs some code to modify all Documents in a Collection. I have 5 dynos running on Heroku and noticed in the logs that my console.logs got called 5x (1 per each dyno).

Does this mean that my DB is getting updated 5x too?

Thanks!


Solution

  • You should use something like https://atmospherejs.com/percolate/migrations to ensure that only one process can obtain the database lock at a time.

    That way only one node will run the code for migrations.