在不带cron的AWS中运行计划任务 [英] run scheduled task in AWS without cron

查看:173
本文介绍了在不带cron的AWS中运行计划任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我有一个单一的服务器在亚马逊,我把所有的cronjobs。我想消除这个单点故障,并公开我的所有任务作为Web服务。我想将VPC ELB后面的服务暴露给几个服务器,这些服务器在调用时将运行这些任务。

Currently I have a single server in amazon where I put all my cronjobs. I want to eliminate this single point of failure, and expose all my tasks as web services. I'd like to expose the services behind a VPC ELB to a few servers that will run the tasks when called.

有一些服务,亚马逊可以按计划的时间间隔运行重复的工作(真正调用Web服务)?我真的很想能够保持cron功能的时间/日规范,但在驱动程序的HA(在正确的时间调用端点的东西)到AWS。

Is there some service that Amazon (AWS) offers that can run a reoccurring job (really call a webservice) at scheduled intervals? I'd really like to be able to keep the cron functionality in terms of time/day specification, but farm out the HA of the driver (thing that calls endpoints at the right time) to AWS.

我喜欢SQS提供Web端点,但是从我可以告诉你不能安排它们。 SWF似乎不太适合。

I like how SQS offers web endpoint(s), but from what I can tell you cant schedule them. SWF doesn't seem to be a good fit either.

推荐答案

AWS 宣布在Lambda的预定功能支持。使用此功能,用户可以使用类似cron的语法按计划执行Lambda函数。 Lambda文档显示了使用Python执行计划的示例事件。截至2016年2月,Lambda函数可以访问VPC内的资源。

AWS announced support for scheduled functions in Lambda at its 2015 re:Invent conference. With this feature users can execute Lambda functions on a scheduled basis using a cron-like syntax. The Lambda docs show an example of using Python to perform scheduled events. As of Feb 2016 Lambda functions can access resources within VPCs.

目前,计划lambda可以运行的最小分辨率为1分钟(与cron相同,但不是作为系统定时器的细粒度)。

Currently, the minimum resolution that a scheduled lambda can run at is 1 minute (the same as cron, but not as fine grained as systemd timers).

Lambder 项目有助于简化Lambda上预定功能的使用。

The Lambder project helps to simplify the use of scheduled functions on Lambda.

原始答案, >

Original answer, saved for posterity.

正如Eric Hammond和其他人所说,没有用于计划任务的本地AWS服务。只有其他答案中提到的解决方案和一半的解决方案。

As Eric Hammond and others have stated, there is no native AWS service for scheduled tasks. There are only workarounds and half solutions as mentioned in other answers.

要重现当前选项:

  • The single-instance autoscale group that starts and stops on a schedule, as described by Eric Hammond.
  • Using a Simple Workflow Service timer, which is not at all intuitive. This case study mentions that JPL used SWF to build a distributed cron, but there are no implementation details. There is also a reference to a code example buried in the SWF code samples.
  • Run it yourself using something like cronlock.
  • Use something like the Unreliable Town Clock (UTC) to run Lambda functions on a schedule. Remember that Lambda cannot currently access resources within a VPC

希望更好的解决方案很快就会出现。

Hopefully a better solution will come along soon.

这篇关于在不带cron的AWS中运行计划任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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