aws / aws/aws-sdk-cpp

cURL error on concurrent Lambda invocations

Aperta
#2,991 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
feature-request p3
Lingua principale
C++
Stelle
2.2k
Fork
1.2k
Merge medio
4g 11h
PR unite (30g)
13

Descrizione

### 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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start with the reported Aws::Client::ClientConfiguration maxConnections setting and the LambdaClient::InvokeAsync path, then reproduce the handler's curlCode 6 under concurrent requests. Done means the client handles the reported 256- and 512-invocation workloads without hostname-resolution errors or the described performance degradation.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, cpp
Ambito
api, cloud, networking, performance
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
32/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.