Google App Engine - 使用任务队列或延期作业 [英] Google App Engine - Use Task Queues or Deferred Jobs

查看:102
本文介绍了Google App Engine - 使用任务队列或延期作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在稍后的时间点,Google App Engine有两种运行作业的方法,任务队列延迟的jops



据我所知,它们支持所有相同的功能(例如,可以将延期作业放在特定任务队列中,这样可以抑制执行) - 但延期作业看起来更容易实现,而且更多灵活。

任何人都知道pro的每种方法的con?任何情况下,你想使用任务队列延期工作?

解决方案

我不确定你是否注意到它,但延期的文档最后有这个部分:


您可能想知道什么时候使用ext.deferred,以及何时坚持使用内置的任务队列API。以下是我们的建议:



如果符合以下条件,您可能需要使用延迟库:




  • 您只能轻松使用任务队列。

  • 您希望重构现有代码以便在任务队列上以最少的更改运行。

  • 您正在编写一次性维护任务,例如模式迁移。

  • 您的应用程序有许多不同类型的后台任务,并且为每个应用程序编写单独的处理程序会很麻烦。 >
  • 您的任务需要复杂的参数,如果不使用Pickle就不会轻松进行序列化。 您正在为其他需要做后台工作的应用程序编写一个库。 / li>


您可能想要使用Task Queue API: $ b 您需要完全控制任务如何排队和执行。

  • 您需要比延迟提供的更好的队列管理或监控。你有很高的吞吐量,而且还有
  • 您正在构建更大的抽象,并需要对任务进行直接控制。

  • 您比web模式更适合RPC模式。 / li>


    当然,如果您的应用程序具有适合的要求,您可以并排使用Task Queue API和延迟库两组。



  • Google App Engine has two methods for running jobs at some later point, Task Queues and Deferred jops

    They support all the same features as far as I can tell (e.g. a deferred job can be placed on a particular task queue so you can throttle execution) - but the deferred jobs look much easier to implement and more flexible.

    Anyone know of the pro's con's of each method? Any circumstances where you would want to use task queues over deferred jobs?

    解决方案

    I'm not sure if you noticed it, but the documentation for deferreds has this section in the end:

    You may be wondering when to use ext.deferred, and when to stick with the built-in task queue API. Here are our suggestions.

    You may want to use the deferred library if:

    • You only use the task queue lightly.
    • You want to refactor existing code to run on the Task Queue with a minimum of changes.
    • You're writing a one off maintenance task, such as schema migration.
    • Your app has many different types of background task, and writing a separate handler for each would be burdensome.
    • Your task requires complex arguments that aren't easily serialized without using Pickle.
    • You are writing a library for other apps that needs to do background work.

    You may want to use the Task Queue API if:

    • You need complete control over how tasks are queued and executed.
    • You need better queue management or monitoring than deferred provides.
    • You have high throughput, and overhead is important.
    • You are building larger abstractions and need direct control over tasks.
    • You like the webhook model better than the RPC model.

    Naturally, you can use both the Task Queue API and the deferred library side-by-side, if your app has requirements that fit into both groups.

    这篇关于Google App Engine - 使用任务队列或延期作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆