|
45 | 45 | <div class="row"> |
46 | 46 | <div class="col-md-8"> |
47 | 47 | <h1>Task queues</h1> |
48 | | -<p>Task queues handle background work that need to be processed outside the |
49 | | -usual HTTP request-response cycle. These tasks are handled asynchronously |
50 | | -because HTTP requests must be responded back to by the server as fast as |
51 | | -possible otherwise the user experience in the web browser will suffer. The |
52 | | -most common types of jobs for task queues include</p> |
| 48 | +<p>Task queues handle background work processed outside the usual HTTP |
| 49 | +request-response cycle. </p> |
| 50 | +<h2>Why are tasks queues necessary?</h2> |
| 51 | +<p>Some tasks are handled asynchronously either because they are not initiated by |
| 52 | +an HTTP request or because they are long-running jobs that take longer than |
| 53 | +a few milliseconds. </p> |
| 54 | +<p>For example, a web application could poll the GitHub API every 10 minutes to |
| 55 | +find out what are the top 100 starred repositories. A task queue would be set |
| 56 | +up to automatically call the GitHub API, process the results and store them |
| 57 | +in a persistent database for later use.</p> |
| 58 | +<p>Another example is when a database query would take too long during the HTTP |
| 59 | +request-response cycle. The query could be performed in the background on a |
| 60 | +fixed interval with the results stored in the database. Then when the |
| 61 | +HTTP request comes in it could fetch the calculated results from the database |
| 62 | +instead of re-executing the query. This is a form of <a href="/caching.html">caching</a> |
| 63 | +enabled by task queues.</p> |
| 64 | +<p>Other types of jobs for task queues include</p> |
53 | 65 | <ul> |
54 | 66 | <li> |
55 | 67 | <p>calculating computationally expensive data analytics</p> |
|
0 commit comments