0

Why do we use AWS Lambda function to invoke sagemaker model endpoint? I know we can use lambda and sagemaker endpoint independently but came across some usecases where both are used. Not sure how they work together and whats the benefit of using both of them. I know for sagemaker we need to specify count and size of instance which is stays always up and we can specif auto scale for it, and for lambda, being serverless, it is up only to serve the request.

1 Answer 1

2

I'm assuming you're asking about using Lambda functions to invoke SageMaker endpoint (rather than using Lambda to invoke a model). The most common use case where you'd use a Lambda function is to integrate your endpoint with your public facing application. SageMaker endpoints can only be accessed within the account using IAM policies, so if you were to set up a web app that needs to invoke the endpoint, you'd use API Gateway and Lambda to do so. See a sample post here - https://aws.amazon.com/blogs/machine-learning/creating-a-machine-learning-powered-rest-api-with-amazon-api-gateway-mapping-templates-and-amazon-sagemaker/

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the reply. In the given link, sagemaker endoint is accessed using api gateway directly . if we can do that then, my question is , why do we need to use aws lambda function in between api gateway and sagemaker endpoint? what are its benefits?
sagemaker endpoint is also auto scalable and we can also do input preprocessing in inference code. Then still in some cases lambda is used to invoke endpoint. Why?
I've seen Lambda function used in cases where you'd like to do some pre/post processing before invoking an endpoint. If that logic is already present in your endpoint (inference pipeline, for example) then you don't need a Lambda inbetween.
So lambda is useful for only pre/post processing and not for auto scaling as scale is taken care of by sagemaker also?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.