3 ms·
If you're talking about having periodic jobs to run you can use heroku's scheduler plugin and start a job. It will use a different dyno from the one running you
by jokethrowaway 6y ago
If you're talking about having periodic jobs to run you can use heroku's scheduler plugin and start a job.
It will use a different dyno from the one running your api.
You will end up paying more, but you won't have problems with resources sharing.
In a traditional VPS environment you would have needed to have a machine beefy enough to run both api and jobs or spin up a new machine.
Cron, Jenkins or another task runner could have achieved the same.
If you're talking about having long running requests initiated by users, a common pattern is to have a queue:
- User send a request
- API add request to a queue
- n workers wait for a queue message and process it once it arrives
Another simpler approach is to just spin another instance of the API and just forward long running requests to the new instance. Depending on the type of job, its dependencies, its frequency you may run into some problems that you wouldn't have with the queue based approach