Reputation: 7965
What are ways to trigger a worker process in Heroku? In particular, a process that is needed infrequently but quickly when needed, e.g. bluemoon.js
.
Polling every second to read a task queue (which can be stored in a database) is the approach I can think of.
Trigger makes more sense to me for this case. Is there a way to directly trigger a worker process when needed? Or is there no real downside to frequent polling?
Upvotes: 1
Views: 439
Reputation: 33854
What you really want is a message queueing service like Amazon SQS, RabbitMQ, or something similar.
What message queueing services do is this:
The reason the above pattern works so well is that these services are optimized for speed and cost -- they're VERY inexpensive to run (I'm a huge fan of Amazon SQS myself), have almost no overhead, and are incredibly fast.
The reason you DON'T want to poll a database (which is what most people think of when they imagine stuff like this) is because it's going to waste resources and cause problems later on:
In general, for problems like this, a messaging service is the perfect solution!
Upvotes: 2