What is a Serverless Function?
Defining Serverless Functions
Conventionally, serverless functions are single-purpose, programmatic functions that are hosted on managed infrastructure. These functions, which are invoked through the Internet, are hosted and maintained by cloud computing companies. The engineering teams within those companies ensure that the serverless functions have near-perfect uptime, redundant instances around the world, and scale to any incoming network request volume.
Who creates serverless functions?
So who creates serverless functions? It is not the cloud computing companies themselves; it’s their customers. Software developers are moving their product code to serverless functions.
What is the advantage of serverless functions and services?
In addition to those benefits, deployment of new code is quicker, simpler, and easily automated.
What is an example of a serverless function?
Google Cloud Functions
Serverless functions can be considered
Why companies are using serverless functions and architectures
Historically, monoliths have large, unified codebases, which require a full deploy of the entire platform for any shipment of new code. This includes new features, but also single line bug fixes.
Monoliths can be practical in some situations, but when a platform’s codebase grows to the stage where the development team is large, some tasks become cumbersome.
With microservice architecture, new developers can be on-boarded to engineering projects rapidly, because they do not need to have a deep understanding of an entire monolith to begin making substantial contributions. Another advantage of microservices is that deployment of small code updates to single services results in little or no downtime for customers. When a monolith needs code updates, it might mean that all customers experience downtime for the duration of a serverless deploy function.
Serverless Functions and Functions-as-a-Service (FaaS)
The magic parts of serverless functions are autoscaling and redundant code deployments. This means that an app developer can concern themselves with one thing: writing great application code. The cloud hosting providers call this product offering Functions-as-a-Service or FaaS for short.
With conventional app hosting, software developers need to repeatedly ask themselves these questions when they write their code:
- Will my servers respond to all client requests, with very low latency, regardless of each client’s physical location?
- Am I creating room for human error in my code deployment process?
- Can my servers handle sudden increases in request volume without overloading?
- Can my servers handle sudden increases in request volume without wasting lots of money?
- Do I need to constantly monitor my app’s infrastructure? I sure do like sleeping 8 hours per night.
These questions do not apply when a software system is built upon a platform with Serverless Functions.
Serverless Function code should have entirely stateless logic, so redundant instances will not cause inconsistencies for customers. Cloud hosting providers usually have many points-of-presence around the globe. This means that the servers in which an application runs are nearest to all possible end users. The cloud hosting provider will redundantly deploy a Serverless Function to data centers around the world, at the same time. This is good for a developer’s customers because their client-side requests will be responded to with as little latency as possible. All of the networking logic is implemented by the cloud provider.
Google and AWS Serverless Functions with Cloud hosting platforms
Cloud hosting providers that offer Serverless Functions use industry standard best practices for automated code deployment. This means that there is no chance of human error breaking a service during deployment. It allows for fast shipment of new code, with little to no downtime for a web product. If there are 100+ global data centers that host a service, automation makes the whole deploy near-instant and more reliable.
One of the most valuable features of Serverless Function hosting is out of the box autoscaling. Cloud hosting providers have made idle server costs a thing of the past for their customers. Thanks to software products like Kubernetes, services can programmatically scale their infrastructure in an automated fashion. Whether it be scaling up, or scaling down, this new kind of “elastic” infrastructure makes hosting more efficient. This results in big cost savings for companies that buy cloud hosting.
Cloud hosting providers have internal engineering teams that monitor the Serverless infrastructure 24/7/365. This is included in the price developers pay for hosting. The 3am Pager Duty phone calls become a thing of the past after Serverless Functions are leveraged.
FaaS Providers and Serverless Function Examples
Cloud hosting companies are offering bleeding-edge FaaS platforms. Server costs are going down for consumers globally, as big tech companies build more and more server farms. However, not all FaaS services are created equal. FaaS platforms are not like the telephone company. Each platform has unique scenarios in which it shines.
AWS Lambda Serverless Functions
AWS Lambda is a serverless function environment on Amazon Web Services. The supported programming languages are Java, Go, PowerShell, Node.js, C#, Python, and Ruby. Using Lambda functions is ideal in scenarios where on-demand compute is required e. g. provide compute for operations like file processing like file conversion.
Azure Functions Serverless Functions
Azure Functions is a serverless function environment on Microsoft Azure. The supported programming languages are C#,
Google Cloud Serverless Functions
A developer can execute code on an in-transit PubNub message after its publish, but before the message reaches a subscriber. There are other execution configurations including non-blocking after publish, and a REST API Endpoint that can be accessed like a Node.js server. State can be managed using a built using KV-Store within the functions environment. There is also a catalog of open source, 3rd party integrations on the PubNub Blocks Catalog.
Which Serverless Provider should I use for my Service?
The answer to this question depends on the type of service that needs to be built. As you can see from the providers described above, there are different programming languages that are usable, depending on the cloud. The most important thing to consider when selecting a provider is: which attributes are mission-critical for my service?
The largest cloud companies (AWS, Azure, Google) provide solutions that are meant to fit nearly every situation with generic cloud products. Companies like PubNub focus on specialization in addressing developer pain points so PubNub outshines generic serverless products exclusively in real time use cases.
Functions make in-transit message computation exhibit extremely low latency execution. Additionally, Functions are easy to build and easy to deploy. Functions are ideal for real-time applications like Chat, GPS location tracking, IoT signaling, multiplayer games, and more.
If your needs are heavy in computation, heavy in languages that need OS access, and are not real-time critical, you are better off using any of the big cloud hosting companies.
See the comparison of Functions and AWS Lambda on the PubNub blog for even more insights on the topic of choosing a serverless provider.