5

SAE与Cron

 3 years ago
source link: https://yuguo.us/weblog/sae-and-cron/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

SAE与Cron

余果 2012-09-26 back-end

Cron服务是SAE为开发者提供的分布式定时服务,用来定时触发开发者的特定动作,满足比如定时计算排行榜等需求。Cron的设置是通过App的config.yaml来实现的,只要用户在App目录下的config.yaml里按照我们的提供的语法格式进行配置,部署后就能生效。Cron的执行是以HTTP方式触发的,触发后真正执行的是用户在App中的PHP代码。Cron服务是分布式环境部署的,具有高可靠性,多点之间相互隔离且同时触发,并且通过分布式锁进行选举并最终由一个健康节点执行。

Cron服务主要提供两类的定时需求:

A. 每隔一定时间执行,如每隔2个小时执行1次。

B. 在某个特定时间点执行,如每周二晚上9:10执行。

针对A应用场景,Cron提供偏移offset功能,也就是用户可以显式指定偏移时间,否则,默认针对间隔时间做随机偏移。 Cron服务支持http basic auth,用户可以设置用户名和密码来控制访问。

我写字的地方迁移到公众号啦~欢迎关注我的公众号:余果专栏

user

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK