The ultimate (getting started) guide to serverless
Tags: serverless, awslambda
Published: 2019-09-16 11:42:10

---
title: The ultimate (getting started) guide to serverless
published: true
description: Getting started with serverless can be an issue due to the exceedingly large number of guides, tutorials, how-to's out there. This is a summary of those.
tags: serverless,aws lambda
---

For the past couple of years, I’ve been working with an awesome bunch of people over at Dashbird, where we wake up every day and make serverless technology a bit better by creating solutions for the current problems the serverless community is facing. I’ve written dozens of articles about the benefits, the problems and different reasons why you should pick up serverless and how to make it work better. This article will be a summary of everything you need to know to get started with serverless.

Let’s start with the very beginning:
<h2>What is serverless</h2>
In terms of definitions, serverless is often assumed to be Function as a Service (FaaS). That's not entirely true. Serverless is so much more. It should be viewed as an event-based system for running code. Meaning, you use various services to create business logic without caring about any servers. You're abstracting away the infrastructure altogether. Perfect examples can be hosting static websites on S3, using serverless databases like DynamoDB or Aurora Serverless, and of course, running code without managing servers with Lambda.

Serverless is great if you have sudden traffic spikes that need to be detected and handled instantly. The application is even completely shut down if there's no traffic at all. You only pay for the resources you use. No usage, no costs, quite simple!

<img src="https://www.cleveroad.com/images/article-previews/how-works-3.png">
<span>Image Courtasy of <a href=”https://www.cleveroad.com/”>Cleveroad.com</a></span>

<h2>Serverless service providers</h2>
Here are the most popular serverless platforms out there to help shed some light on the current options available to developers

<h2><a href="https://aws.amazon.com/lambda/">1. AWS Lambda</a></h2>
<h2><a href="https://azure.microsoft.com/en-us/">2. Microsoft Azure</a></h2>
<h2><a href="https://cloud.google.com/appengine/">3. Google App Engine</a></h2>
<h2><a href="https://cloud.google.com/functions/">4. Google Cloud Functions</a></h2>
<h2><a href="https://console.bluemix.net/openwhisk/">5. IBM OpenWhisk</a></h2>

To learn more about each individual platform check out <a href=”https://dashbird.io/blog/serverless-platforms-2018/”>this</a> post.

<h2>Get started with serverless</h2>
To begin working on serverless takes very little effort. While there are a number of services provides to chose from, I’m going to talk about AWS and AWS Lambda to keep things easier for both of us. I’ll start by describing the limitations that you have with AWS Lambda, this way you’ll know exactly how much you can push your system.

Function memory allocation: 128 MB to 3,008 MB, in 64 MB increments.
Function timeout: 900 seconds (15 minutes)
Function environment variables: 4 KB
Function resource-based policy: 20 KB
Function layers: 5 layers
Function burst concurrency: 500 - 3000 (varies per region)
Invocation payload: 6 MB (synchronous)/ 256 KB (asynchronous)
Deployment package size: 50 MB (zipped) or 250 MB (unzipped)
/tmp directory storage: 512 MB
Execution processes/threads: 1,024

Now that we got this out of the way let’s move on to the next part.

<h2>How to create a simple Lambda function</h2>
There are two ways to do so, one would be to upload your code directly through the AWS interface which is not a bad way to go but let’s face it, you won’t be able to do this for a big project with multiple microservices that have a lot of small functions.
So while doing uploading functions one by one is ok-ish what you need is a platform that allows you to connect to AWS (or any other service provider) and leverage that to get the most out of everything that serverless technology has to offer.

<h2>Serverless platform</h2>
While the name is confusing, the Serverless platform is an awesome way to build, develop and scale serverless applications. It’s free to use and the community support that revolves around it is truly incredible.

There are lots of different ways to go when picking a serverless framework to work with and besides having over 25000 github stars and being the number one tool for deploying serverless apps, I’d recommend serverless technology because of its cloud-agnostic approach. While I don’t necessarily suffer from the vendor lock-in syndrome everyone is complaining I like the idea of being able to deploy on a number of different services without having to jumps through hurdles, hoops and everything in between.

Setting up the project is straight forward, once serverless is installed on your system you initialize the serverless framework by using:

```
serverless login
```

This will get you set up and logged into AWS and then you can start publishing your Lambdas. From this point forward you can start building your application either from scratch or by using any one of their boilerplate.

```
serverless create --template aws-nodejs --path sls-express-mongodb
```
This installs and pre-configures almost everything you need to get a head start on a powerful API that can support efficiently your entire application.

Here are a list of a few great tutorials to get you started with serverless in no time:

<h3>1. <a href=”https://dashbird.io/blog/building-a-serverless-contact-form-with-aws-lambda-and-aws-ses/”>Building a serverless contact form with AWS Lambda and AWS SES</a></h3>

<h3><a href=”https://dashbird.io/blog/a-crash-course-on-serverless-with-aws-image-resize-on-the-fly-with-lambda-and-s3/”>2. Serverless with AWS - Image resize on-the-fly with Lambda and S3</a></h3>

<h3><a href=”https://dashbird.io/blog/a-crash-course-on-serverless-apis-with-express-and-mongodb/”>3. A crash course on Serverless APIs with Express and MongoDB</a></h3>

<h3><a href=”https://dashbird.io/blog/create-your-first-website-in-15-minutes/
”>4. Create your first website with serverless in 15 minutes</a></h3>

<h3><a href=”https://dashbird.io/blog/a-crash-course-on-serverless-with-aws-triggering-lambda-with-sns-messaging/”>5. Serverless with AWS - Triggering Lambda with SNS Messaging</a>
</h3>


Alright, that’s all I’ve got on the subject but since there are so many updates I’ll try to keep it updated. If there are any resources you think are missing please give me a heads-up on twitter @johndemian.