You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello.
When using node-auth0 v4.3.1 and v3.7.2 in Lambda, there's a 1000ms difference in processing time during Lambda's cold start.
My Lambda function is developed using Node.js v20 + TypeScript + SAM. I've also added node-auth0 to a layer and imported it into my Lambda function.
Here are the Lambda function and layer codes for both v4.3.1 and v3.7.2.
Although it's simple code using node-auth0 and X-Ray (for measuring processing time), when executing the Lambda function, the processing time for the v4.3.1 function is 1000ms slower. Why is this?
I've managed to achieve the same processing time as v3.7.2 by increasing the Lambda's memory, but this incurs additional costs. If possible, I'd like to reduce the cost while maintaining the same processing time as v3.7.2.
Thanks.
v.4.3.1
lambda code
import{APIGatewayProxyEvent,APIGatewayProxyResult}from'aws-lambda';import{AWSXRay}from'/opt/nodejs/lib/x-ray';import{getUsersByEmail}from'/opt/nodejs/lib/auth0';exportconstlambdaHandler=async(event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult>=>{constsegment=AWSXRay.getSegment();if(!segment){consterror=newError('segment is undefined');console.error(error);throwerror;}constgetUserByEmailSegment=segment.addNewSubsegment('getUserByEmail');letusers;try{constemail=JSON.parse(event.body!).email;if(!email){consterror=newError('email is not found');console.error(error);throwerror;}users=awaitgetUsersByEmail(email);}catch(error: any){return{statusCode: 500,body: JSON.stringify(error),};}finally{getUserByEmailSegment.close();}segment.close();return{statusCode: 200,body: JSON.stringify(users),}};
import{APIGatewayProxyEvent,APIGatewayProxyResult}from'aws-lambda';import{AWSXRay}from'/opt/nodejs/lib/x-ray';import{getUsersByEmail}from'/opt/nodejs/lib/auth0';exportconstlambdaHandler=async(event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult>=>{constsegment=AWSXRay.getSegment();if(!segment){consterror=newError('segment is undefined');console.error(error);throwerror;}constgetUserByEmailSegment=segment.addNewSubsegment('getUserByEmail');letusers;try{constemail=JSON.parse(event.body!).email;if(!email){consterror=newError('email is not found');console.error(error);throwerror;}users=awaitgetUsersByEmail(email);}catch(error: any){return{statusCode: 500,body: JSON.stringify(error),};}finally{getUserByEmailSegment.close();}segment.close();return{statusCode: 200,body: JSON.stringify(users),}};
Checklist
Description
Hello.
When using node-auth0 v4.3.1 and v3.7.2 in Lambda, there's a 1000ms difference in processing time during Lambda's cold start.
My Lambda function is developed using Node.js v20 + TypeScript + SAM. I've also added node-auth0 to a layer and imported it into my Lambda function.
Here are the Lambda function and layer codes for both v4.3.1 and v3.7.2.
Although it's simple code using node-auth0 and X-Ray (for measuring processing time), when executing the Lambda function, the processing time for the v4.3.1 function is 1000ms slower. Why is this?
I've managed to achieve the same processing time as v3.7.2 by increasing the Lambda's memory, but this incurs additional costs. If possible, I'd like to reduce the cost while maintaining the same processing time as v3.7.2.
Thanks.
v.4.3.1
lambda code
layer code
v3.7.2
lambda code
layer code
Reproduction
Additional context
Processing time for v4.3.1 as measured by X-Ray
The getUserByEmail process takes 2040ms
Processing time for v3.7.2 as measured by X-Ray
The getUserByEmail process takes 1010ms
node-auth0 version
4.3.1 and 3.7.2
Node.js version
nodejs20.x(lambda)
The text was updated successfully, but these errors were encountered: