A network application must respond quickly to network requests, typically less than 1s, preferably dozens of microseconds, to provide a smooth experience for users sitting in front of the browser. This will not give the application too much time to handle the work. Sometimes there will be more work to do rather than have time to do it. <1.sometimes,there is much work-to-do than there are time to do it.> in this case, when the user waits for a response from the server, if the job takes a few seconds, a few minutes, a few hours instead of immediately, also total It's OK. But the user needs to have a job that will accomplish such a guarantee.
For this kind of work, the App Engine app uses the task queue. The task queue lets you indicate that the work is completed at some point outside the scope of the network request. The queue ensures that each task will eventually be completed. If a task fails, the queue retries the task until it succeeds.
There are two types of task queues: Push queue, pull queue. In the push queue, each task record represents an HTTP request to the request processor. APP engine makes these requests when it processes this push queue. You can configure how often the heap queue is executed to spread the load. In the pull queue, you provide a mechanism, such as a custom compute engine, to fetch records from the queue and perform the work. The queuing aspect of the APP engine management pull queue.
A push queue invokes a request handler to perform a task. It can contain the data payload provided by the code that created the task. The payload is passed to the task processor in the form of an HTTP request. The task processor is subject to the same limitations as other request processors, and an important exception is that a task processor can take up to 10 minutes to perform a task, rather than 60 seconds for a user request. By splitting tasks into small tasks to take advantage of parallel and queue throughput, a higher time limit makes tasks easier to write in simple ways.
A particularly powerful feature of the task queue is the datastore of a task into the queue (Enqueue) in a single transaction. This ensures that only the remainder of the datastore transaction succeeds before it is queued. You can use transactional tasks to perform additional datastore operations that must eventually be consistent with the transaction, but this does not require a strong consistency guarantee for datastore local transactions.
APP engine has other services to perform tasks at special points of the day, called Scheduled task services. The scheduled task is known as "cron Jobs". This is the name borrowed from the same features in the UNIX operating system. This scheduled task service can invoke a request processor at a particular point in the day, one weeks, and one months, based on the timetable you provide when uploading the app. Scheduled tasks are useful for general maintenance, notification messages for the sending cycle.
In the 16th chapter we will look at this task queue, timetables and some powerful uses.
Tasks Queues and Cron jobs (task queue and clock daemon)