Background jobs that run on every request on Heroku and node.js -


i have app needs run long process (takes 30-60 seconds each request). after processing, result returned request response. works fine locally, crashes heroku instance.

what i'd happen instead is:

  • user comes on site, request sent backend
  • backend returns immediately, , kicks off process/task/job processing
  • when processing ends, response returned correct user.

i not sure need this. based on hour-long research, seems can use redis queue , worker can poll every x minutes. can't understand how figure out request send response after processing ends.

is there sample express/node.js this? pointers helpful.

like found in research, setting worker queue using redis approach long running processes. nice library kue (https://github.com/learnboost/kue).

when comes responding request results of job, having outanding requesting hanging waiting response not way go (and may not work, heroku kills requests have been idle period of time).

what when request made start background job , respond request right away job id. client can poll server status of job, when job complete can fetch needed result.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -