Serverless or Edge Functions: Which Should I Go With?

A Quick Guide to Finding the Right One For You

Serverless functions and edge functions are two different types of functions used in cloud computing.

Serverless functions refer to a cloud computing model where the cloud provider manages the infrastructure and automatically provisions and scales the computing resources based on the demand of the application. In this model, developers only have to write the code for their application logic, and the cloud provider takes care of everything else. When a user requests a serverless function, the cloud provider spins up a new instance of the function to handle the request and then spins it down when it's done.

Edge functions, on the other hand, are functions that are run on the edge of a network, closer to the end user. In this model, the function is executed on a server that is geographically close to the user, which reduces latency and improves performance.

While both serverless functions and edge functions are designed to handle compute workloads, there are some key differences between the two. Serverless functions are typically used for application logic and are triggered by events such as user requests or changes to a database. Edge functions, on the other hand, are used for tasks such as content delivery and network optimization.

History

Serverless functions and edge functions have different origins and histories.

Serverless functions have their roots in the idea of "function as a service" (FaaS), which was first introduced by hook.io in 2014. According to a post on the hook.io blog, "The vision of hook.io is to provide developers with a frictionless way to deploy small pieces of code that can be accessed via HTTP." This idea of deploying small pieces of code quickly and easily without worrying about the underlying infrastructure became the foundation of FaaS.

AWS Lambda, one of the most popular serverless computing services, was announced by Amazon in 2014. As Amazon CTO Werner Vogels wrote in a blog post, "Lambda is a new compute service that runs your code in response to events and automatically manages the compute resources for you, making it easy to build applications that respond quickly to new information." Since then, other cloud providers such as Google and Microsoft have released their own serverless computing services.

Edge functions, on the other hand, have their roots in content delivery networks (CDNs), which were first introduced in the late 1990s. According to a post on the Cloudflare blog, "CDNs were first introduced in the late 1990s as a way to distribute content more efficiently by placing servers closer to end-users." This idea of placing servers closer to end-users to reduce latency and improve performance is the foundation of edge computing.

Cloudflare Workers, one of the most popular edge computing platforms, was announced by Cloudflare in 2017. As Cloudflare CEO Matthew Prince wrote in a blog post, "Cloudflare Workers lets developers deploy serverless code written in JavaScript to Cloudflare's edge, closest to the end user." Since then, other companies such as Fastly and Akamai have released their own edge computing platforms.

In summary, serverless functions and edge functions have different origins and histories. Serverless functions have their roots in the idea of "function as a service" (FaaS) and were first introduced by hook.io in 2014, while edge functions have their roots in content delivery networks (CDNs) and were first introduced in the late 1990s.

Benefits

One of the main benefits of using serverless functions is that they can scale automatically to handle any amount of traffic, which can be particularly useful for applications that experience sudden spikes in traffic. Serverless functions are also cost-effective, as users only pay for the number of resources that their application uses.

Similarly, edge functions can provide improved performance by reducing latency and minimizing the amount of data that needs to be transferred between the user and the cloud provider. This can be particularly useful for applications that require real-time data processing or have low-latency requirements.

In summary, both serverless functions and edge functions offer benefits for specific use cases. While serverless functions are best suited for handling application logic and scaling automatically to meet demand, edge functions are best suited for optimizing network performance and reducing latency for users.

Stackin' It Up

Commonly used serverless stacks:

  1. AWS Lambda
  • Location: Amazon Web Services (AWS)

  • Tech and coding languages used: JavaScript, Python, Java, Go, C#, and Ruby.

  • Additional information: AWS Lambda is a popular serverless computing service that lets you run code without provisioning or managing servers. Lambda functions can be triggered by various AWS events such as API Gateway requests, S3 object uploads, and more. You can also use AWS Lambda to build serverless web applications, data processing pipelines, and more.

  1. Google Cloud Functions
  • Location: Google Cloud Platform (GCP)

  • Tech and coding languages used: JavaScript, Python, and Go.

  • Additional information: Google Cloud Functions is a serverless computing service that lets you run code in response to events such as Cloud Storage object changes, Cloud Pub/Sub messages, and more. Cloud Functions can be used to build serverless web applications, microservices, and more.

  1. Microsoft Azure Functions
  • Location: Microsoft Azure

  • Tech and coding languages used: C#, F#, Java, JavaScript, PowerShell, Python, and TypeScript.

  • Additional information: Microsoft Azure Functions is a serverless computing service that lets you run code in response to events such as HTTP requests, timer triggers, and more. Azure Functions can be used to build serverless web applications, IoT backends, and more.

  1. Serverless Framework
  • Location: Open source framework

  • Tech and coding languages used: JavaScript, TypeScript, Python, Java, and C#.

  • Additional information: The Serverless Framework is an open-source framework for building serverless applications on various cloud platforms such as AWS, Google Cloud, and Microsoft Azure. The framework lets you easily deploy serverless functions, APIs, and more. You can use various plugins and templates to customize and extend the framework.

  1. Zeit Now
  • Location: Zeit

  • Tech and coding languages used: Node.js, JavaScript, and Docker.

  • Additional information: Zeit Now is a cloud platform for building and deploying serverless web applications, static sites, and more. You can use various languages and frameworks to build your applications, including Node.js, JavaScript, and Docker. Zeit Now provides a simple and intuitive command-line interface for deploying your applications to their platform.

Commonly used edge computing stacks:

  1. Cloudflare Workers
  • Location: Cloudflare

  • Tech and coding languages used: JavaScript, Rust, and C/C++.

  • Additional information: Cloudflare Workers is an edge computing platform that lets you run JavaScript and WebAssembly at the edge of the network. Workers can be used to build serverless applications, APIs, and more. Cloudflare Workers also provides a powerful caching and routing system that can help improve the performance and security of your applications.

  1. Fastly Compute@Edge
  • Location: Fastly

  • Tech and coding languages used: Rust, C++, and AssemblyScript.

  • Additional information: Fastly Compute@Edge is an edge computing platform that lets you write and run code at the edge of the network. Compute@Edge can be used to build serverless applications, APIs, and more. The platform also provides a powerful caching and routing system that can help improve the performance and security of your applications.

  1. AWS Lambda@Edge
  • Location: Amazon Web Services (AWS)

  • Tech and coding languages used: JavaScript and Python.

  • Additional information: AWS Lambda@Edge is an edge computing platform that lets you run Lambda functions at the edge of the AWS network. Lambda@Edge can be used to build serverless applications, APIs, and more. The platform also provides a powerful caching and routing system that can help improve the performance and security of your applications.

  1. Akamai EdgeWorkers
  • Location: Akamai

  • Tech and coding languages used: JavaScript and C/C++.

  • Additional information: Akamai EdgeWorkers is an edge computing platform that lets you write and run code at the edge of the Akamai network. EdgeWorkers can be used to build serverless applications, APIs, and more. The platform also provides a powerful caching and routing system that can help improve the performance and security of your applications.

  1. StackPath Edge Computing
  • Location: StackPath

  • Tech and coding languages used: JavaScript, Python, and Go.

  • Additional information: StackPath Edge Computing is an edge computing platform that lets you write and run code at the edge of the network. Edge Computing can be used to build serverless applications, APIs, and more. The platform also provides a powerful caching and routing system that can help improve the performance and security of your applications.

In summary, serverless functions and edge functions are two different types of functions used in cloud computing. Serverless functions are designed to handle application logic and are triggered by events such as user requests or changes to a database, while edge functions are used for tasks such as content delivery and network optimization. Both serverless and edge functions offer benefits for specific use cases. Serverless functions are best suited for handling application logic and scaling automatically to meet demand, while edge functions are best suited for optimizing network performance and reducing latency for users.

Popular serverless stacks include AWS Lambda, Google Cloud Functions, Microsoft Azure Functions, Serverless Framework, and Zeit Now. Each platform has its own set of features, languages, and tools to help developers build and deploy serverless applications. Choosing the right stack depends on the specific requirements of the application and the preferences of the development team.

Popular edge computing stacks include Cloudflare Workers, Fastly Compute@Edge, AWS Lambda@Edge, Akamai EdgeWorkers, and StackPath Edge Computing. Each platform provides the ability to write and run code at the edge of the network to improve network performance and reduce latency. Choosing the right stack depends on the specific requirements of the application and the preferences of the development team.