Why Serverless?

Let's explore what Serverless is and isn't

Its important to understand what it means to run in a serverless environment. Let's compare the 'old-school' or traditional way of using a server versus the 'new-school' or serverless environment.

To clarify, a serverless environment actually uses servers! But those servers are managed and maintained by Amazon on your behalf - so there's no overhead or extra steps you need to do.

Old-school: using a server#

Here's a typical web server stack for a Django application, showing the top of the stack and moving down toward the bottom:

Old School Stack

New-school: simplify serverless#

In a serverless Django project, some things are very different:

New School Stack

It's important to note that everything below Zappa is handled by Zappa. For solo developers or folks who don't have access to an infrastructure team, Zappa is your personal infrastructure team. It allows you to focus on the application software, not the supporting layers. AWS provides the robust web hosting without a lot of overhead maintenance.

What about scaling?#

Another benefit of this model is the ability to handle great variations in load. In an old-school setup you would be limited by the CPU of a single server, but with serverless you can harness the power of AWS Lambda.

What is Zappa and how does it work?#

The Zappa utility is an open-source tool that enables a Django or Flask application to operate in the AWS Lambda serverless environment. This probably sounds like a lot of buzzwords so, let's break it down into more understandable parts.

In short, Zappa creates and configures a compatible AWS environment for your Django or Flask project. This means your Django project runs in the cloud without having to worry about setting, configuring or maintaining your own web server. The AWS Lambda environment handles all that while you focus on writing your application code.

Zappa is flexible and powerful#

Unlike some other minimal serverless deployment tools, Zappa comes with built-in support for WSGI requests routing to Django or Flask projects, but you can also:

  • Run periodic jobs such as database maintenance, calculation jobs, or send messages. Similar to Celery without the overhead.

  • Easily map a custom domain name to your project

  • Respond to many AWS events such as S3 uploads, DynamoDB entries, Kinesis streams, SNS messages, and SQS queues

Zappa is all you need#

A key benefit of Zappa is that once you have it in your project, there are no external dependencies to use Zappa. That means you don't have to create a Zappa account or any foolishness like that. It's free to download and use for everyone. Naturally, your project will have package dependencies that you specify and Amazon Web Services needs to be running.

Can I use serverless for everything?#

No! It's important to realize that not all applications should be serverless. Serverless applications are generally best for event-driven models like web servers, chat bots, or smart speaker apps. Since you're only paying for CPU cycles that your app uses, apps that are idle for long periods are ideal for serverless migration.

If your applications perform heavy calculations or are CPU-intensive (rendering, modeling, or bitcoin mining) then look for non-serverless solutions. You'll probably find that AWS Lambda will not be cost-effective for these scenarios.

But, if you're a solo developer or a small team of developers, and you want to focus on getting your website up and running in a robust environment without a lot of overhead, then Zappa is for you!

Start a new discussion. All notification go to the author.