简体   繁体   English

Google App Engine:排队任务与Cron作业

[英]Google App Engine: Queued Tasks vs Cron Jobs

I'm very confused about GAE's concepts of Tasks, Task Queues (both push and pull), Cron Jobs and how each of these relate to Frontend vs. Backend instances. 我对GAE的“任务”,“任务队列(推和拉)”,“ Cron Jobs”以及它们与前端实例和后端实例的关系如何感到非常困惑。

I'm trying to achieve a situation where some HTTP requests can be serviced immediately, whereas some get queued. 我正在尝试实现一种情况,其中一些HTTP请求可以立即得到服务,而有些却被排队。 Queued requests might ultimately end up triggering my own code to execute (once they are consumed) or they might hit one of the GAE service APIs ( LogQuery , etc.). 排队的请求最终可能最终触发我自己的代码执行(一旦被使用),或者它们可能命中GAE服务API之一( LogQuery等)。

I can't seem to wrap my head around how to design these two scenarios and let alone do the code up. 我似乎无法全神贯注于如何设计这两种方案,更不用说编写代码了。 To make things worse I've read literature that suggests there's certain task/queue-related coding you want to do differently depending on whether the code is executing on a Frontend or Backend instance. 更糟糕的是,我阅读过一些文献,这些文献暗示您需要根据在前端或后端实例上执行的代码来不同地执行某些与任务/队列相关的编码。 Thanks in advance for any help here! 在此先感谢您的任何帮助! Bonus points for some concrete examples! 一些具体例子的加分!

You write the code, Tasks and Cron execute it. 您编写代码,然后由Tasks和Cron执行。

Task is a wraper for a set of properties, the main one is Url that should execute. Task是一组属性的包装,主要的是应该执行的Url。 You code (handler, servlet) should reside on that url. 您的代码(处理程序,Servlet)应驻留在该URL上。 Task sit in the TaskQueues, which have certain default properties on how fast, how many in parallel, etc.. they execute the Tasks. 任务位于任务队列中,它们具有执行速度,执行并行操作的默认数量的某些默认属性。 So basically a To-Do list, that sequentially executes tasks with no guarantee when a task will start. 因此,基本上是一个待办事项列表,该列表不保证任务何时开始依次执行任务。

Cron is a service that periodically calls Url that you provided. Cron是一项服务,会定期调用您提供的网址。 In a sense its a scheduler. 从某种意义上说,它是一个调度程序。

Your Url (= your handler/servlet) can reside on frontend instance (default) or backend instance (must set special property on Task or in Cron settings). 您的网址(=处理程序/ Servlet)可以驻留在前端实例(默认)或后端实例(必须在Task或Cron设置中设置特殊属性)。 The main difference being that front requests must complete in 10min, while backend requests can take indefinitelly. 主要区别在于,前台请求必须在10分钟内完成,而后端请求可以无限期地处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM