Google App Engine - 工作伫列与Cron工作 [英] Google App Engine - Task Queues vs Cron Jobs

查看:139
本文介绍了Google App Engine - 工作伫列与Cron工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最新的Google App Engine版本支持新的任务队列API 。我正在比较此API的功能与已有的 Cron服务< a>。对于非用户启动的后台作业,例如抓取RSS源并在每天的时间间隔进行解析。

The latest Google App Engine release supports a new Task Queue API in Python. I was comparing the capabilities of this API vs the already existing Cron service. For background jobs that are not user-initiated, such as grabbing an RSS feed and parsing it on a daily interval. Can and should the Task Queue API be used for non-user initiated requests such as this?

推荐答案

我会说排序的。要记住的任务队列的事情是:

I'd say "sort of". The things to remember about task queues are:

1)每分钟/小时/天的操作限制不等于定期重复的东西。即使令牌桶大小设置为1,我不认为你保证那些重复将均匀间隔。它取决于它们是多么严重,当他们说队列实现为令牌桶,以及该语句是否应该是接口的保证部分。这是实验室,什么也没有保证。

1) a limit of operations per minute/hour/day is not the same as repeating something at regular intervals. Even with the token bucket size set to 1, I don't think you're guaranteed that those repetitions will be evenly spaced. It depends how serious they are when they say the queue is implemented as a token bucket, and whether that statement is supposed to be a guaranteed part of the interface. This being labs, nothing is guaranteed yet.

2)如果任务失败,那么它是重新排队。如果cron作业失败,那么它将被记录并且不会重试,直到它再次到期。因此,cron作业的行为不同于添加自身副本,然后刷新您的Feed的任务,或者作为刷新您的Feed,然后添加自己的副本的任务。

2) if a task fails then it's requeued. If a cron job fails, then it's logged and not retried until it's due again. So a cron job doesn't behave the same way either as a task which adds a copy of itself and then refreshes your feed, or as a task which refreshes your feed and then adds a copy of itself.

这可能是使用任务模拟cron作业,但我怀疑这是值得的。如果你想解决运行超过30秒(或者点击任何其他请求限制)的cron作业,那么你可以将工作拆分为多个部分,并有一个cron作业,将所有的部分添加到任务队列。有一些关于异步urlfetch的讨论(在GAE博客中),这可能是更新RSS源的最佳最佳方式。

It may well be possible to mock up cron jobs using tasks, but I doubt it's worth it. If you're trying to work around a cron job which takes more than 30 seconds to run (or hits any other request limit), then you can split the work up into pieces, and have a cron job which adds all the pieces to a task queue. There was some talk (in the GAE blog?) about asynchronous urlfetch, which might be the ultimate best way of updating RSS feeds.

这篇关于Google App Engine - 工作伫列与Cron工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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