AWS Lambda 是否存储上次运行时间? [英] Does AWS Lambda Store Last Run Time?

查看:28
本文介绍了AWS Lambda 是否存储上次运行时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个 unix 时间戳作为参数传递到 API 获取请求中,作为另一个系统的参数来获取数据.该参数需要是 AWS Lambda 上次运行的时间.我需要以某种方式存储 AWS lambda 函数最后一次遇到可能的 s3 存储桶并恢复该时间戳.这样我就可以将该值传递到下一次运行中.

I am trying to pass a unix timestamp into API get request as a parameter to another system to grab data. The parameter needs to be the last time the AWS Lambda ran. I need to somehow store the last time the AWS lambda function has ran into maybe an s3 bucket and also recover that timestamp. So I can pass that value along into the next run.

有人对如何做这样的事情有任何想法吗?

Anyone have any ideas on how to do something like this?

推荐答案

Lambda 不会在调用之间存储任何上次运行时间(特别是因为它可能同时对您的 Lambda 进行并发调用).

Lambda does not store any last run time between invocations (especially as its possible there could be concurrent invocations of your Lambda at the same time).

根据用例,如果您希望 Lambda 读取和写入 DynamoDB成为您的最佳选择,但您应该注意以下几点:

Depending on the use case if you want your Lambda to both read and write DynamoDB will probably be your best choice, although you should be aware of the following:

  • 读写使用信用,如果如果您的负载变化,您需要考虑定价并启用自动缩放.
  • 默认情况下,读取最终是一致的,如果您的写入必须准确,您将需要使用强一致性读取.
  • Reads and writes use credits, if you're read and write heavy you will need to consider pricing and enable autoscaling if your load varies.
  • By default reads are eventually consistent, if your writes must be accurate you will want to use strongly consistent reads.

作为替代方案,您可以将该值存储为 参数存储值,有限每秒 1000 次操作 所以如果您不使用频繁的请求,这将提供一个非常简单的实现.

As an alternative you could store the value as a parameter store value, it is limited 1000 operations per second so if you are not using frequent requests this will provide a very simple implementation.

如果您不需要 Lambda 本身中的信息,您可以通过 过滤CloudWatch 日志 由您的 Lambda 生成.这在您的 Lambda 本身中是不可取的,因为持续时间会比上述任何一个选项都长.

If you do not need the information within the Lambda itself, you can get this information by filtering the CloudWatch logs that are produced by your Lambda. This would not be advisable in your Lambda itself as duration would span longer than either of the above options.

这篇关于AWS Lambda 是否存储上次运行时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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