Explain Serverless Like I'm Five

Gift Egwuenu on December 17, 2017

I'll like to know the logic behind the serverless framework and how it works.

markdown guide
 

Basically, however obscure it sounds, Serverless still uses servers. Shocker right!? Anyhow, Serverless Architecture is when you use cloud services to run your code without managing servers. In the case of AWS, you use Lambda as the compute service to run the code and API Gateway to create API endpoints to point at the Lambda functions. Under the hood, once a Lambda is invoked through the event trigger which is the API Gateway endpoint, a Docker container is spun up to run the code you deployed into the cloud.

What the Serverless framework does is that it automates the process of creating all the necessary services on the cloud provider. Once you run sls deploy the config file, which is called serverless.yml is transformed into a CloudFormation template. Okay, CloudFormation template? CloudFormation is a special language AWS uses to spin up AWS services by running commands from a file. Pretty cool. Okay, once the serverless.yml has been transformed into a CloudFormation template it gets sent to AWS to create the services you specified, all API Gateway routes, all Lambdas, and anything else you specified. Apart from that, the Serverless framework also packages up all the code you have written and sends it to AWS S3, in the process, creating a bucket to keep the code. This bucket will have all the versions of the code you have ever deployed. Effectively, the Serverless framework grabs the latest version from the bucket and sends it to the Lambda it created.

That's a quick rundown. :)

Here's a course I just recently published on the topic.

 

It's worth nothing that the serverless framework is one of many ways to use serverless architectures. Alteratives include:

  • Managing lambdas yourself in AWS's console (or equivalent for other platforms like Azure, etc)
  • Building & deploying your application with chalice AWS Lambda & Python ONLY
  • deploying your aplication with apex (AWS ONLY)
  • deploy a traditional Python WSGI app to AWS using Zappa
  • lots of other options.

The main advantage of the serverless framework is that it has the biggest userbase currently and works with many service providers (AWS, Azure, Google, OpenWhisk, OpenFAAS, Kubeless, just to name a few)

 
 

Serverless sometimes refers to something specific and sometimes it's more of an idea or ideology. And that idea is that the server can be completely abstracted away. You don't have to worry about compute capacity, memory management, uptime, cost to some extent.

Calling it serverless would be like calling a higher level programming language like JavaScript or Python "memoryless". Yes, you don't manually manage pointers and memory in some of these programming languages, but it's there.

Serverless sometimes refers to the concept of "functions as a service", basically taking the microservices pattern and realizing "hey, because we're doing things this way, we basically can forget about the server". Somebody is still doing the heavy lifting (AWS, Google Cloud, etc.) but it's now an abstraction and you have limited ability to configure it, and this is fine if you're using it for the right use cases.

It's good to know that folks are starting to solve problems in this way so you can stay in the loop, but avoid going this route to solve problems you don't have.

 

Thanks, Ben :).Your explanation really came in handy. Serverless is more like No servers but meanwhile, there are actual servers but I'm not dealing with it.

 

The server concept is like

If you want to make bread you have to buy wheat flour , water ,eggs all by your self in different shops and you have to mix in a certain proportion and bake it all by yourself to make a single unit of bread .

This is how conventional websites work.

Now coming to serverless

But now a days you can outsource your bread making to a 3rd party guy .

What he does is he will take your recipe right from scratch and he will make your bread and you can label it and sell it as your own brand .

The advantage is if someone orders a million units , all you have to do is just give the contractor a call and he will take care of the rest .

Recepie(your backend code) is yours and serverless contractor will help you take care of the job better .You don't have to worry about how he does the job or whether he finishes it or not . He will do the rest

You only have to pay for number of units of the bread you ordered.

That is the concept of serverless

You write your code , upload it to a site(aws , google , azure etc..) , but unlike conventional methods you don't have to worry about constant maintenance or minimum fees to keep the serverspace online . They will take care about the scaling and running the code . All you have to do is write good code

 

Wow, Thank you, Aswath I like how you used the bread analogy simplified everything. I now know what serverless means even without thinking about it. :)

 
 

Say you want to make a fresh homemade loaf of bread. You can get all the ingredients together and you can definitely eat your bread, but you're a wee little five year old and can't use the oven because it's unfortunately it's too complicated and dangerous even for a smart kid like you. Good thing though, you're not alone. You ask your parent for some help to take your bread bowl and put it in the over for you. And when it's done they take it out and give it to you to eat and enjoy. 🍞😊

Say you want to make a hip new web application. You can get all the functions together make a nice UI and you can definitely test and use your app, but you're a wee little front end developer and don't want to worry about running your own server because it's unfortunately it's too complicated and dangerous even for a smart dev like you (os updates, security, patches, networking, architectures, environment compatibility). Good thing though, you're not alone. You ask your local serverless provider (Amazon AWS, Google GCP, Microsoft Azure, Heroku, etc) for some help to take your deploy your app and put it in on the server out on the internet. And when it's done they give a URL and give it to you to use and enjoy. 🍞😊

 

How is it different from your own server? You pay other people to run your infrastructure.

How is it different from leased VMs or containers? You pay people to set up these things to run your functions and databases when there are users that need them.

Pros: Less staff needed, less hardware needed, pay per second.

Cons. One second is more expensive than a second on your own server, so when you have 100% usage, you may run cheaper with your own stuff.

 

Imagine you want to build an API backend for your web or mobile app. Normally, you'd write an API layer, then add a DB layer, then add logging, then auth middlewares, then you'd write your business logic, then deploy it, then figure out how to update it and maintain it.

With serverless, you only write your business logic and upload it to AWS. They provide you with their logging, data layer, api, auth, hosting and anything else you need. For a price.

code of conduct - report abuse