Table of Contents
Last updated
Serverless and AWS Lambda created a buzz more than any other technology in AWS reInvent 2018.
Google Cloud has its own serverless offering - Cloud Functions.
IBM offers Cloud functions based on Apache OpenWhisk.
Microsoft has Azure functions. And there are many other serverless providers.
While the world is getting hot on serverless, lets deep dive into serverless and run a GraphQL server on it!
What is serverless technology?
Serverless lets you architect your application without thinking about servers. Traditionally, a web server keeps running listening to incoming requests in a particular port. So there is a process thats running in the CPU somewhere in the cloud.
But when running on a serverless provider like AWS Lambda, a whole “container” gets created, only after it receives an incoming request or a trigger. So there is nothing that is running, which waits for a request. The code gets executed after the container is created. The internal implementation of how this happen, differs from provider to provider. Until the occurance of a trigger(in this case an incoming request from the user), there is no process that is listening to requests. A trigger can be anything, like an updation of a table, or an incoming request.
When there are more triggers, more “containers” gets created and this is scaled automatically by the provider. There are some things to note here - one, there are no “servers” that is running; two, since there are no servers thats waiting for the requests, no resources are used and so no cost is incurred if there are no incoming requests.
AWS Lambda is one such serverless provider. Read about the AWS Lambda container lifecycle here. Amazon recently announced first class support for Ruby language in AWS Lambda.
In this guide, we will create and deploy a Ruby GraphQL end point in AWS Lambda, that can add and list books of a bookshelf. We are using the serverless framework, a toolkit that makes building serverless applications easier.