在没有 cron 的情况下在 AWS 中运行计划任务 [英] run scheduled task in AWS without cron

查看:25
本文介绍了在没有 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.

亚马逊 (AWS) 是否提供了一些可以按预定时间间隔运行重复作业(真正称为网络服务)的服务?我真的希望能够在时间/日期规范方面保留 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 在其 2015 年 re:Invent 会议上宣布支持 Lambda 中的预定函数.借助此功能,用户可以使用类似 cron 的语法按计划执行 Lambda 函数.Lambda 文档展示了一个示例使用 Python 执行预定事件.

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.

目前,预定 lambda 可以运行的最小分辨率为 1 分钟(与 cron 相同,但不如 systemd 计时器细粒度).

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.

λ Gordon 的 cron 示例 可能是部署计划的最简单的界面lambda 函数.

λ Gordon's cron example has perhaps the simplest interface for deploying scheduled lambda functions.

原始答案,为后人保存.

正如 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天全站免登陆