Serverless Functions

Introduction

One of the protagonists of the Serverless architecture is the Function as a Service (FaaS). With FaaS, you get to deploy a single function (written in JavaScript for example) that will be executed depending on some kind of event, e.g. using a scheduled plan that executes the function periodically or when an HTTP request is made to a designated URL.

With FaaS, you get the provider managing the servers running these functions, you are charged only when these functions get executed on request and it can easily scale to accommodate for a large number of requests or executions.

Major players in this area include:

The following companies use AWS Lambda Functions to provide FaaS services with a layer of abstraction and an user-friendly interface that makes both of them really good candidates for developers that want to dive into FaaS quickly and easily:

Study

Watch the following video and code along to build and deploy your serverless functions:

Post: Build and Deploy a Serverless Function to Netlify

You can also watch and follow Ania Kubow as she codes and deploys a Serverless function using Netlify:

Feedback

  • Is there anything we can help with up to this point? Do you have something to suggest about this chapter? Let us know in the comments below.

UPDATED: 13.03.2021

Introduction to the Serverless Architecture

Spoiler

Introduction

So, what is the Serverless architecture?

Serverless refers to a category of web services where the provider of these services takes the responsibility of managing and allocating the servers required to run them.

Some of the advantages of this approach are:

  • You do not need to maintain any servers and you only get to pay for the time that you are actually running code on the serverless providers’ servers (quite a paradox here, huh?)

  • Automatic (and much, much easier) scaling

  • Easy deployment and updating

Major providers for the serverless architecture include:

  • Amazon Web Services
  • Microsoft Azure
  • IBM (OpenWhisk)
  • Google Cloud

Serverless means that there are no servers you have to manage to run a particular service or an app. Usually, in Serverless architectures you rely on services that are managed for you. Be that function-as-a-service, storage-as-a-service, and others. Using managed services means that all the maintenance and operational tasks are abstracted away. Yes, there are still servers there, but they are no longer your responsibility to manage. Source: Webiny

Why serverless is the future of development?

Serverless removes complexities around managing infrastructure and frees up developer resources. Developers no longer need to deal with configuring and installing different tools that their application requires, as those are now abstracted away as a managed service. In return, developers spend more time building business logic and less time on installing, configuring and maintaining infrastructure. This also means that products get faster to market and cost less to develop. All these advantages are driving the adoption of serverless and, over time, serverless will be the standard of how all applications are built. Source: Webiny

Watch this next video for a great introduction to Serverless by Jame Q Quick.

Duration: 8 minutes

Resources mentioned in the video:

Pros of Serverless Functions

  • Low cost
  • Low maintainance
  • Easy to scale (up/down)

Cons of Serverless Functions

  • No access to a filesystem
  • Cold Starts (The phenomenon that functions which haven’t been used take longer to start up.)

We can now do things on the front-end that used to require a back end. When we do need a back end, our front-end skills can be put to work, giving us some surprisingly powerful new abilities. Join Chris Coyier on a whirlwind tour of the tools, tech, and code that puts more power than ever into our front-end hands. The All Powerful Front End Developer – Chris Coyier

Duration: 30 minutes

JAMStack

Closely related to the Serverless Architecture and its services is the JAMStack architecture which creates fast, secure and scalable sites and web apps without the complexity of a server. It builds on traditionally static workflows and adds dynamic elements with modern techniques like serverless functions and webhooks.

Read through the material below to get a good understanding of this modern stack that is taking the web developer community by storm.

What is JAMStack?

JAM stands for Javascript API & Markup. The term JAMstack was popularised by Mathias Biilmann (CEO & Co-founder of Netlify) to describe “a modern web development architecture based on client-side JavaScript, reusable APIs, and prebuilt Markup”. Source: Pedro Duarte

Read Why Jamstack? An Animated Guide by Sarah Drasner.

Watch What is JAMstack! By Ania Kubów

Duration: 5 minutes

(Optionally) watch Mathias Biillmann describing the JAMStack in the next short video.

Duration: 13 minutes

(Check the resources below for links to the technologies mentioned in the video)

Why JAMStack?

  • Speed, security, reliability and availability
  • Highly scalable since you aren’t relying on individual servers
  • Reduced hosting cost from the server-side render for each request approach
  • Removes the need to manage infrastructure by prerendering files which can be served directly from a CDN
  • More streamlined development allowing for easier focus on the different aspects of your stack with seamless deployments

Source: FaunaDB

Want to dive into more details about why would you choose JAMStack? Here’s Why JAMStack?

Take a short break, grab yourself a coffee and read through the next article that describes the JAMStack in full detail. Estimated reading time: 30~45 minutes

New to JAMstack? Everything You Need to Know to Get Started

Here’s a collection of terms often used when talking about Jamstack and associated web technologies.

Projects

The Covid Tracking Project

The Covid Tracking Project Stack

Resources

Technologies mentioned by Mathias Biilmann:

LOOKING FOR HELP?

When looking for help, try doing so in the following order:

  • Did you try everything you could?
  • Did you read the documentation?
  • Did you Google for it?
  • Did you post your question on Slack/Forum?
  • Did you ask your fellow students for help?
  • Did you ask your Mentors for help?
  • Did you leave a comment on the comments section of this page?
  • Did you ask your Instructor for help?
    • Did you arrange and appointment with your instructor using Calendly? Visit this URL and set up an appointment: https://calendly.com/kostasx
    • Is it urgent? Did you try reaching him on Slack

UPDATED: 19.03.2021

  • [19.03.2021] Added Serverless Computing YT video by Fireship
  • [17.03.2021] Added What is Jamstack by Ania Kubow
  • [05.03.2021] Adding Modern Web Development with JAMstack
  • [05.02.2021] Adding Serverless introduction in Greek by Nikiforos Botis of AWS
  • [19.11.2020] Adding Why Jamstack? An animated guide by Sarah Drasner