How to Become a Serverless Developer in 2022

The demand for serverless computing skills is growing faster than ever. Over 60% of organizations have already adopted serverless or plan to within the next year, according to the 2021 State of Serverless Report from Datadog. By 2025, the serverless market is projected to reach $21.1 billion, a 22.7% annual growth rate.

Serverless Adoption
Source: Datadog

As a result, serverless developers are in high demand. A recent search on Indeed.com showed over 3,000 job postings mentioning "serverless" in the United States alone. These roles command an average salary of $130,000 according to Payscale.

So how can you position yourself for success as a serverless developer? As a full-stack engineer with over a decade of experience, here is my advice:

1. Master the fundamentals of your programming language

Before diving into serverless, you need a rock-solid foundation in a programming language. JavaScript (Node.js), Python, Java, and C# are the most popular choices for serverless development. Personally, I recommend JavaScript as you can use it across the entire web stack.

Regardless of language, there are certain concepts you must master:

  • Data types, variables, functions, control flow
  • Asynchronous programming (callbacks, promises, async/await)
  • Working with APIs and JSON data
  • Error handling and debugging
  • Unit and integration testing

As an example, here‘s a simple Node.js function that makes an asynchronous HTTP request:

const axios = require(‘axios‘);

async function getUser(userId) {
  try {
    const response = await axios.get(`https://api.example.com/users/${userId}`);
    return response.data;
  } catch (error) {
    console.error(error);
    throw new Error(‘Failed to get user‘);
  }
}

This function uses the axios library to make a GET request to a /users endpoint. The async/await syntax is used to handle the promise returned by axios.get(). Any errors are caught and logged to the console.

Mastering concepts like this is critical for serverless development, where your code runs in short-lived, stateless functions.

2. Learn the serverless ecosystem

The next step is to dive into the world of serverless platforms and services. While there are many options, the "Big Three" cloud providers are a good place to start:

Provider Serverless Compute Database API Gateway Authentication
AWS Lambda DynamoDB API Gateway Cognito
Azure Functions Cosmos DB API Management Active Directory
GCP Cloud Functions Firestore Cloud Endpoints Firebase Auth

Comparison of popular serverless services

I recommend starting with AWS as it has the most mature serverless offering. Key services to learn include:

  • Lambda – Run code without provisioning servers. Supports Node.js, Python, Java, C#, Go, and Ruby.
  • DynamoDB – A NoSQL database that scales seamlessly and has single-digit millisecond response times.
  • API Gateway – Create, publish, and manage APIs. Provides security, monitoring, and rate limiting.
  • S3 – Scalable object storage for files, images, videos, and static website hosting.
  • Cognito – Manage user sign-up, sign-in, and access control. Integrates with social logins like Facebook and Google.

The documentation for these services is excellent. Start with the Developer Guides which provide overviews and tutorials. The API references have detailed information on every parameter and data type. AWS also offers free digital training through their serverless learning path.

3. Choose a deployment framework

Deploying and managing serverless apps by hand is time-consuming and error-prone. That‘s why most developers use an Infrastructure-as-Code (IaC) framework to automate the process. The two most popular options are the Serverless Framework and AWS SAM.

The Serverless Framework is an open-source tool that supports multiple languages and cloud providers. It has a large ecosystem of plugins and lets you define your entire serverless app in a single YAML file.

Here‘s an example serverless.yml that defines an HTTP API:

service: my-api

provider:
  name: aws
  runtime: nodejs12.x

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: hello
          method: get

This config file defines a single Lambda function named hello that is triggered by a GET request to /hello. The function code is in a file named handler.js.

The AWS Serverless Application Model (SAM) is a similar framework developed by AWS. It uses a CloudFormation template to define your serverless resources. SAM integrates with the AWS CLI and can be used to test and debug functions locally.

Here‘s the same HTTP API example using SAM:

AWSTemplateFormatVersion: ‘2010-09-09‘
Transform: AWS::Serverless-2016-10-31

Resources:
  HelloFunction:
    Type: AWS::Serverless::Function
    Properties: 
      Handler: handler.hello
      Runtime: nodejs12.x
      Events:
        HttpGet:
          Type: Api
          Properties:
            Path: /hello
            Method: get

The choice between the Serverless Framework and SAM largely depends on your background and goals. The Serverless Framework is more flexible and portable, while SAM has deeper integration with AWS services.

Regardless of which framework you choose, using IaC is a must for serverless development. It allows you to version control your infrastructure, streamline deployments, and easily replicate environments.

4. Practice with small projects

Learning the theory of serverless is important, but you really start to internalize the concepts when you build your own projects. Start small and iterate rapidly. Here are a few project ideas:

  • URL Shortener – Create a serverless API that takes a long URL and returns a shortened version. Store the URL mapping in DynamoDB and use API Gateway to expose the endpoints.

  • Serverless Blog – Host a static blog on S3 and use Lambda to handle dynamic functions like comments and email subscriptions. Use Cognito to authenticate users and DynamoDB to store data.

  • Image Thumbnail Generator – Automatically generate thumbnail images when an image is uploaded to S3. Use Lambda to resize the image and store the thumbnail back in S3.

  • Alexa Skill – Create a custom Alexa skill that interacts with a serverless backend. Use Lambda to handle the voice requests and return responses.

For each project, start by sketching out the architecture and data model. Write the infrastructure code using your chosen framework. Then implement the function logic and wire everything up. Test thoroughly and deploy to production.

As you build projects, you‘ll quickly gain hands-on experience with serverless development. You‘ll also start to encounter common challenges like cold starts, function timeouts, and debugging distributed applications.

Overcoming these challenges is what separates a novice serverless developer from an expert. Some tips:

  • Keep functions small and focused. Limit dependencies to minimize cold start times.
  • Use asynchronous I/O and streaming data where possible to avoid timeouts.
  • Leverage structured logging and distributed tracing to debug issues across services.
  • Monitor performance and set alerts on key metrics like function errors and duration.
  • Optimize for cost by tuning memory settings and using cost-efficient services.

5. Contribute to real-world projects

Building toy projects is a great way to learn, but nothing beats working on a real-world serverless application. This could be at your day job, a freelance gig, or an open-source project. The key is to gain experience shipping serverless code to production.

One way to get started is to look for serverless projects on GitHub. Many projects have beginner-friendly issues and welcome contributions from the community. Some popular projects include:

  • Serverless Examples – A collection of boilerplate serverless architectures
  • AWS SAM Examples – Sample serverless apps built with AWS SAM
  • OpenFaaS – An open-source serverless platform for Kubernetes
  • Architect – A simple provisioning tool for serverless infrastructure

Contributing to open-source is a great way to build your portfolio, gain credibility, and learn from experienced developers. Don‘t be afraid to jump in and start submitting pull requests!

6. Never stop learning

The serverless ecosystem is evolving at a rapid pace. Cloud providers are constantly releasing new services and features that make serverless development easier and more powerful. As a serverless developer, you need to stay on top of these changes.

Some ways to keep learning:

As a serverless expert, you should also share your knowledge with the community. Write blog posts, give talks at meetups, and contribute to open-source projects. This will help cement your understanding and establish you as a leader in the field.

The serverless landscape may look intimidating at first, but don‘t let that stop you. With dedication and practice, you can quickly become a proficient serverless developer. The demand for these skills will only continue to grow, opening up exciting opportunities for your career.

So what are you waiting for? Get out there and start building with serverless! The cloud is the limit.

Similar Posts