Why use Zappa in lambda rather than API gateway?

345 views Asked by At

I'm currently working on a project in python. I have seen that there is to main way to create an API (with an SQL base and sqlaclhemy) on AWS :
1. Use zappa + flask and deploy everything inside one lambda. Zappa handle everything, the major cons is an overload lambda, I thought lambda had to be light as possible, so with this architecture why not use AWS fargate ?
2. Use api gateway, do one lambda per endpoint, and deploy everything with terrafom. Even if you do one lambda per endpoint, it makes smaller code with less packages and it is easier to maintain.

In both case you can use sqlAlchemy for sql part.

So, my question is simple, why would you chose zappa + flask to deploy an API on lambda ?

I have tried both way. I can't find why zappa+flask seems to be better. On every tuto they use this architecture why ?

1

There are 1 answers

0
Mark B On
  1. Use zappa + flask and deploy everything inside one lambda. Zappa handle everything, the major cons is an overload lambda, I thought lambda had to be light as possible, so with this architecture why not use AWS fargate ?

AWS Fargate is a completely different service with a completely different billing model. Lambda is billed per number of executions, with a free-tier that could make some smaller projects completely free. Fargate is billed for every second you have the service deployed and running, even if it is just waiting for connections to come in, and Fargate has no free-tier.

  1. Use api gateway, do one lambda per endpoint, and deploy everything with terrafom. Even if you do one lambda per endpoint, it makes smaller code with less packages and it is easier to maintain. In both case you can use sqlAlchemy for sql part.

If you have the expertise to do this, this is by far the best way to go. Zappa seems primarily designed for people that want to run Django on AWS Lambda, for the cost savings. I think the Flask support was added later, and as you have pointed out it really doesn't give you any benefit unless you want to simply think about coding in Flask and don't want to take the time to learn how to use AWS.