What is Serverless?

Grigor Khachatryan
Jun 17, 2018 · 4 min read
Image for post
Image for post

Although the cloud has revolutionized the way we manage applications, many companies still view their systems in terms of servers — even though they no longer work with physical servers. What if you take the concept of servers out of the equation and begin to think of cloud-based applications as workflow, distributed logic, and externally managed data stores? This report examines the new approach to operations.

Like many trends in software, there’s no one clear view of what Serverless is. For starters, it encompasses two different but overlapping areas:

  • Serverless was first used to describe applications that significantly or fully incorporate third-party, cloud-hosted applications and services, to manage server-side logic and state. These are typically “rich client” applications — think single-page web apps, or mobile apps — that use the vast ecosystem of cloud-accessible databases (e.g., Parse, Firebase), authentication services (e.g., Auth0, AWS Cognito), and so on. These types of services have been previously described as “Backend as a Service” or
  • Serverless can also mean applications where server-side logic is still written by the application developer, but, unlike traditional architectures, it’s run in stateless compute containers that are event-triggered, ephemeral (may only last for one invocation), and fully managed by a third party. One way to think of this is “Functions as a Service” or . AWS Lambda is one of the most popular implementations of a Functions-as-a-Service platform at present, but there are many others, too.

Despite the name, it does not actually involve running code without servers. The name “serverless computing” is used because the business or person that owns the system does not have to purchase, rent or provision servers or virtual machines for the back-end code to run on.

With comes the following:

  • No server management (no need to manage any form of the machine)
  • Pay-per-execution (never pay for idle)
  • Auto-scale (scale based on demand)
  • Function as a unit of application logic

pattern encourages development focus on well-defined units of business logic, without premature optimization decisions related to how this logic is deployed or scaled. As a result, development focus is on a single function or module rather than a service with a large surface area. frees the software developer from deployment concerns and allows them to focus on factoring the application following logical encapsulation lines.

A typical example is an image uploaded to a file store, this event calls a serverless function which creates a thumbnail and stores this thumbnail back into the file store as well as recording the thumbnail location in NoSQL databases. The insert into the NoSQL database could then trigger further functions. This thumbnail creation function only runs on demand and the only cost incurred is how many times the function is invoked. The function will scale out in real time if many people are uploading images and then scale to zero once they are done.

However, the downside is that system monitoring and debugging becomes difficult and is based on logging available from the service, vendor lock occurs especially when leveraging events from other services, while the compute may be cheap the other services may not be, also deployment mechanisms and IDEs are not typically prepared to manage serverless functions.

Simple HTTP Endpoint Example

(From Serverless Framework Github Repo).

— Build applications comprised of microservices that run in response to events, auto-scale for you, and only charge you when they run. This lowers the total cost of maintaining your apps, enabling you to build more logic, faster.

This example demonstrates how to setup a simple HTTP GET endpoint. Once you ping it, it will reply with the current time. While the internal function is name currentTime the HTTP endpoint is exposed as ping.

Quick Start with Serverless Framework

  • Install via npm:
npm install -g serverless

Use Case: Wrapping an existing internal or external endpoint/service.

We need to create and files to describe and deploy our serverless function.

Invoke the function locally

Go to the terminal window and paste this string:

serverless invoke local --function currentTime

Which should result in:

Deploy

In order to deploy your endpoint simply run:

serverless deploy

The expected result should be similar to:

Usage

You can now invoke the Lambda directly and even see the resulting log via

serverless invoke --function currentTime --log

or as send an HTTP request directly to the endpoint using a tool like a curl

curl https://XXXXXXX.execute-api.us-east-1.amazonaws.com/dev/ping

Coming Soon

Running a endpoint with

Like to learn?

Follow me on twitter where I post all about the latest and greatest AI, DevOps, VR/AR, Technology, and Science! Connect with me on LinkedIn too!

devgorilla

http://devgorilla.xyz

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store