Skip to content

Lambda extensions blocking rust lambdas? #997

Description

@xorxsan

So I started my first lambda (function url) in Rust and wanted to add the Newrelic Lambda Extension (arn:aws:lambda:eu-west-1:451483290750:layer:NewRelicLambdaExtension:51) to send logs and telemetry to Newrelic.

I used a fairly simple code (very much like the ones in the examples):

pub async fn function_handler(
    request: lambda_http::Request,
) -> Result<lambda_http::Response<lambda_http::Body>, lambda_runtime::Error> {
    Ok(lambda_http::Response::builder()
        .status(200)
        .header("Content-Type", "application/json")
        .body(lambda_http::Body::from("A Test"))?)
}

#[tokio::main]
async fn main() -> Result<(), lambda_runtime::Error> {
    tracing_subscriber::fmt()
        .with_max_level(tracing::Level::INFO)
        .without_time()
        .with_ansi(false)
        .json()
        .init();

    tracing::info!("Handler execution started.");

    lambda_http::run(lambda_http::service_fn(
        function_handler,
    ))
    .await
}

The lambda is configured with 2 minutes timeout and a reserved concurrency of 2.

When I call the lambda url I can only call it twice. However if I remove the extension layer, then I can call the lambda as many times as I want.

If I unset the reserved concurrency and make five requests I get the below pattern 5 times:

INIT_START Runtime Version: provided:al2023.v93 Runtime Version ARN: arn:aws:lambda:eu-west-1::runtime:520452c01f1d6aaabcad19c6c2986c22188b1d50daeb583ec6dee8adf883fb62
REPORT RequestId: idx Duration: 119824.00 ms Billed Duration: 120086 ms Memory Size: 128 MB Max Memory Used: 42 MB Init Duration: 261.35 ms
END RequestId: idx
[NR_EXT] Extension shutdown after 468591ms

It is not clear to me why it always takes 2 minutes when the layer is configured. I'm probably missing something, but I don't know what.

Thanks for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions