【发布时间】:2019-06-13 01:27:40
【问题描述】:
我目前正在评估可以处理单个文档的 AWS 状态机。状态机处理单个文档需要 5-10 分钟。
{
"Comment":"Process document",
"StartAt": "InitialState",
"States": {
//the document goes through multiple states here
}
}
C# 代码通过为每个文档传递一些 json 来调用状态机。像
// max 100 documents
public Task Process(IEnumerable<Document> documents)
{
var amazonStepFunctionsConfig = new AmazonStepFunctionsConfig { RegionEndpoint = RegionEndpoint.USWest2 };
using (var amazonStepFunctionsClient = new AmazonStepFunctionsClient(awsAccessKeyId, awsSecretAccessKey, amazonStepFunctionsConfig))
{
foreach(var document in documents)
{
var jsonData1 = JsonConvert.SerializeObject(document);
var startExecutionRequest = new StartExecutionRequest
{
Input = jsonData1,
Name = document.Id,
StateMachineArn = "arn:aws:states:us-west-2:<SomeNumber>:stateMachine:ProcessDocument"
};
var taskStartExecutionResponse = await amazonStepFunctionsClient.StartExecutionAsync(startExecutionRequest);
}
}
}
我们批量处理100 的文档。所以在上面的循环中,最大文档数将是100。但是,我们每周处理数千份文档(25000+)。
根据AWS documentation Maximum execution history size is 25,000 events. If the execution history reaches this limit the execution will fail。
这是否意味着我们不能执行单个状态机超过 25000 次? 为什么状态机的执行应该依赖于它的历史,为什么 AWS 不能只清除历史?
我知道有一种方法可以continue as new execution,但我只是想了解历史限制及其与状态机执行的关系,我的理解是否正确?
更新 1
我不认为这是重复的问题。我正在尝试查找我对历史限制的理解是否正确?为什么历史与状态机可以执行的次数有关?当状态机执行时,它会创建历史记录,如果历史记录超过 25000+,则清除它们或归档它们。为什么 AWS 会停止执行状态机。这没有意义。
所以问题,单状态机(唯一的 arn)可以循环执行超过 25000 次吗? 如果我必须创建新的状态机(执行 25000 次后),该状态机不会有不同的 arn 吗?
另外,如果我必须关注linked SO post,我在哪里可以获得当前的执行次数?他也在逐步函数中循环,而我在循环中调用逐步函数
更新 2
所以只是为了测试我创建了以下状态机
{
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Pass",
"Result": "Hello World!",
"End": true
}
}
}
并执行了 26000 次,没有失败
public static async Task Main(string[] args)
{
AmazonStepFunctionsClient client = new AmazonStepFunctionsClient("my key", "my secret key", Amazon.RegionEndpoint.USWest2);
for (int i = 1; i <= 26000; i++)
{
var startExecutionRequest = new StartExecutionRequest
{
Input = JsonConvert.SerializeObject(new { }),
Name = i.ToString(),
StateMachineArn = "arn:aws:states:us-west-2:xxxxx:stateMachine:MySimpleStateMachine"
};
var response = await client.StartExecutionAsync(startExecutionRequest);
}
Console.WriteLine("Press any key to continue");
Console.ReadKey();
}
在 AWS 控制台上,我可以提取所有 26000 次执行的历史记录
所以我不确定Maximum execution history size is 25,000 events 到底是什么意思
【问题讨论】:
-
@bwest 查看我的更新 1
-
你能找到解决办法吗?
标签: amazon-web-services aws-lambda aws-sdk aws-step-functions