Building Serverless Python Web Services with Zappa
上QQ阅读APP看书,第一时间看更新

What is Zappa?

Zappa is an open source tool that was developed and designed by Rich Jones, founder/CTO of Gun.io (https://www.gun.io/). Zappa was mainly designed to build and deploy serverless Python applications on AWS Lambda and API Gateway.  

Zappa is great for deploying serverless Python microservices with frameworks such as Flask and Bottle for hosting large web applications and CMSes with Django. You can also deploy any Python WSGI application as well.

In the previous chapter, we implemented the basic hello world microservice, using AWS Lambda and API Gateway. Zappa automates all these manual processes and gives us a handy tool to build and deploy Python applications.

It's as easy as this:

$ pip install zappa
$ zappa init
$ zappa deploy

As we described earlier, the tradition of web hosting is where the server needs to be always online, listening to HTTP requests and processing the requests one by one. If the queue of incoming HTTP requests grows, then a timeout error will occur as the server will have failed to serve that many requests per second.

API Gateway serves each request with a virtual HTTP server with auto scalability. That's the reason it can serve a single request to millions of requests without fail. Hence, we get the infinite scaling with zero downtime infraction of your current deployment cost.

Now, we are going to go through an app demonstration, but, before we do that, let's configure Zappa on your machine, which we will go through in the upcoming section.