Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have three basic options:</p> <ol> <li>Do background work as part of a worker dyno. This is the easiest, most straightforward option because it's the thing that's most appropriate. Your web processes handle incoming HTTP requests, and your worker process handles the SQS messages. Done.</li> <li>Do background work as part of your web dyno. This might mean spinning up another thread (and dealing with the issues that can cause in Rails), or it might mean <code>fork</code>ing a subprocess to do background processing. Whatever happens, bear in mind the 512 MB limit of RAM consumed by a dyno, and since I'm assuming you have only one web dyno, be aware that <a href="https://devcenter.heroku.com/articles/dynos#dyno-idling" rel="nofollow">dyno idling</a> means your app likely isn't running 24x7. Also, this option smells bad because it's generally against the spirit of the <a href="http://www.12factor.net/" rel="nofollow">12-factor app</a>.</li> <li>Do background work as one-off processes. Make e.g. a <code>rake handle_sqs</code> task that processes the queue and exits once it's empty. <a href="https://devcenter.heroku.com/articles/scheduler" rel="nofollow">Heroku Scheduler</a> is ideal: have it run once every 20 minutes or something. You'll pay for the one-off dyno for as long as it runs, but since that's only a few seconds if the queue is empty, it costs less than an always-on worker. Alternately, your web app could use the Heroku API to launch a one-off process, programmatically running the equivalent <code>heroku run rake handle_sqs</code>.</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload