简体   繁体   English

aws-lambda 实例的唯一标识?

[英]Unique id of aws-lambda instance?

Because lambdas are stateless and multiple instances can run at the same time it might be a bad idea to generate ids based on timestamps.因为 lambda 是无状态的并且多个实例可以同时运行,所以基于时间戳生成 id 可能不是一个好主意。 I am currently using UUIDv1.我目前正在使用 UUIDv1。 I know the chance of generating the same IDs with the same timestamp already literally impossible.我知道用相同的时间戳生成相同的 ID 的机会已经几乎不可能了。 It's also enough unique enough for my application.对于我的应用程序来说,它也足够独特。 Out of curiosity I'm thinking of ways to generate truly mathematically unique ids on aws lambda.出于好奇,我正在考虑如何在 aws lambda 上生成真正数学上唯一的 id。

UUID v1 uses a node to distinct ids generated with the same timestamp. UUID v1 使用节点来区分使用相同时间戳生成的 ID。 Random numbers or MAC-Adresses (bad idea for virtual instances) are used to create node ids.随机数或 MAC 地址(虚拟实例的坏主意)用于创建节点 ID。

If I had a unique id for my active lambda instance I would be able to generate truly unique ids.如果我的活动 lambda 实例有一个唯一 ID,我将能够生成真正唯一的 ID。 There is a awsRequestId inside the context object but it just seems like another timestamp based UUID.上下文 object 中有一个 awsRequestId,但它看起来像是另一个基于时间戳的 UUID。

Maybe you guys have more ideas?也许你们有更多的想法?

Unique within su.net在 su.net 中独一无二

String executableId = ManagementFactory.getRuntimeMXBean().getName();

AWS lambda: AWS lambda:

System.getenv("AWS_LAMBDA_LOG_STREAM_NAME").replaceFirst(".*?(?=\\w+$)", EMPTY)

Defined runtime environment variables 定义的运行时环境变量

AWS EC2: AWS EC2:

httpGet http://169.254.169.254/latest/meta-data/instance-id

Instance metadata and user data 实例元数据和用户数据

AWS ECS:亚马逊云服务器:

httpGet http://localhost:51678/v1/metadata

How to get Task ID from within ECS container? 如何从 ECS 容器中获取任务 ID?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法授予 aws-lambda 对 aws-appsync API 的访问权限 - Cannot give aws-lambda access to aws-appsync API aws-lambda中使用APIGatewayProxyRequestEvent时如何获取日志的Context - How to get Context for logging when using APIGatewayProxyRequestEvent in aws-lambda Aws-Lambda 导出默认功能不起作用 - Aws-Lambda export default function does not work spring 中的自定义异常消息 云 function 部署在 aws-lambda - custom exception message in spring cloud function deployed in aws-lambda 如何在'Id'下添加两个或多个目标ID:AWS中的实例ID lambda function和python - How to add two or more Target id under 'Id' : instance id in aws lambda function with python 在 AWS-Lambda 中处理来自 FIFO 队列的 SQSEvent 时,应将哪些 messageIds 添加到 BatchItemFailures - What messageIds should be added to the BatchItemFailures when processing SQSEvent from a FIFO-queue in an AWS-Lambda 如何在 AWS-lambda 中使用 nodeJS 对 dynamo DB 中的数据进行排序 - How to sort data from dynamo DB using nodeJS in AWS-lambda AWS Lambda SSH 到非 AWS 实例 - AWS Lambda SSH to Non-AWS Instance AWS 笔记本实例正在运行,但 Lambda 不接受输入 - AWS Notebook Instance is working but Lambda is not accepting the input 如何在资源组中列出 AWS 实例 ID - How to list the AWS instance id in Resource group
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM