aws / aws/aws-sdk-cpp

cURL error on concurrent Lambda invocations

Open
#2,991 1 comment 0 reactions 0 assignees View on GitHub
feature-request p3
Dominant language
C++
Stars
2.2k
Forks
1.2k
Avg merge
3d 14h
Merged PRs (30d)
12

Description

### Describe the bug

I wrote a client that uses the Lambda component to invoke functions asynchronously. I created my own callback, and it seemed to work pretty well. However, when I scaled up to 512 functions, the performance dropped quite quickly - I expected behavior close to linear scaling. I investigated it further, and I found out that there's a default configuration limit of a maximum of 25 TCP connections. So, I changed this parameter to the value of 520, and it started scaling again, although performance became very unpredictable. Unfortunately, for 256 concurrent invocations, we now get an error inside the SDK.

I do not believe this is an issue with Lambda. Our custom implementation of Lambda invoker, based on an HTTP2 client, can scale up much higher concurrent invocations without any issues.

### Expected Behavior

The Lambda client from SDK should scale up to the limit of concurrent connections without (a) errors and (b) performance degradation. With the default limit of 25 connections, the SDK can handle even 512 concurrent invocations - it's just very slow.

### Current Behavior

I observed the following error on the client. I don't see any failed Lambda invocations in AWS metrics.

```
Error with Lambda::InvokeRequest. curlCode: 6, Couldn't resolve host name
```

### Reproduction Steps

This is the main invocation code. `np` is equal to the number of invocations, which in this case is equal to `256`. `lambda_name` refers to the name of my function.

```cpp
Aws::SDKOptions options;
Aws::InitAPI(options);

Aws::Client::ClientConfiguration clientConfig;
clientConfig.maxConnections = 520;
Aws::Lambda::LambdaClient client(clientConfig);
int id = 0;
for (int i = 0; i < np; i++) {

Aws::Lambda::Model::InvokeRequest request;
request.SetFunctionName(lambda_name);
Aws::Utils::Json::JsonValue jsonPayload;
jsonPayload.WithInt64("iterations", n / np);

std::shared_ptr context =
Aws::MakeShared("tag");
context->SetUUID(std::to_string(id++).c_str());

std::shared_ptr payload = Aws::MakeShared(
"FunctionTest");
*payload << jsonPayload.View().WriteReadable();
request.SetBody(payload);
request.SetContentType("application/json");

client.InvokeAsync(request, handler, context);
}
```

The `handler` function fails immediately at this step:

```cpp
void handler(
const Aws::Lambda::LambdaClient*, const Aws::Lambda::Model::InvokeRequest&,
Aws::Lambda::Model::InvokeOutcome outcome, const std::shared_ptr& ctx
)
{
if (!outcome.IsSuccess()) {
std::cerr << "Error with Lambda::InvokeRequest. "
<< outcome.GetError().GetMessage()
<< std::endl;
exit(1);
}
```

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### AWS CPP SDK version used

Current git master, commit f067d450a8689f3ae05fbcd96039cdd9f2d0276c

### Compiler and Version used

Clang 15 (custom fork)

### Operating System and version

Ubuntu 22.04

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.