Is it possibile to deploy sanic app to aws lambda using zappa?


#1

Is it possibile to deploy sanic app to aws lambda using zappa? If so, is there any performance issue using lambda rather than ec2??


#2

I do not have any experience with AWS lambdas. But, it sounds like a worthwhile attempt to do some benchmarks across them.

It is certainly possible as far as I know. There should be no reason why not. However (and this is my ignorance on AWS lambdas), I thought part of the point was that AWS does all of the work of providing the routing, load balancing, HTTP parsing, etc and you just provide the business logic. Assuming this is the case, I am not sure that Sanic is the best tool for the job.

Part of the concern I have had with the serverless pattern is the concept of cold startup. There is an inherent latency required to start an instance of your application. Part of the benefit of a framework like Sanic is that it takes a single existing process and squeezes as much Response/Request cycle efficiency out of it as it can. While your application is off querying the DB, the application can start working on another Request. This is not really needed when your application is constantly being spun up and down.

Personally, I think the concept of Lambdas are cool, and I can see how it would work for some tasks. But to power an API, I want a field of dedicated workers processing my requests. I find Kubernetes deployment to be a much more compelling alternative.

Perhaps someone with more Lambda experience than I has a better answer.


#3

Thank you for your quick and nice answer : )
I was considering AWS lambdas because it is really cheap.
When it comes to cold startup, i can control the time to minimize performance issues because of it.
I’ll try lambdas and share the experience in this community later.
Thanks again.


#4

I look forward to it. :sunglasses:

One of these days I’ll get around to trying it.


#5

It’s theoretically possible but lambda is used for short running function-type jobs, and will automatically kill your process after a specific timeout which would mean you’d need to either a) have a job to monitor and kickoff a new lambda job every 15 minutes or so or b) write your app in such a way that after a job dies and a new lambda kicks off through something like API gateway, you account for the start time.

Personally - and professionally - I would not use AWS lambda for long running jobs.