Cloud

Serverless computing: The smart person's guide

This comprehensive guide covers what serverless computing is and how it could reduce the complexity and cost of your cloud infrastructure.

cloud-computing.jpg
Getty Images/iStockphoto

The world's major cloud providers are rushing to offer serverless computing services. Here's everything you need to know about what it means to go serverless and how it could benefit your business.

SEE: Check out all of TechRepublic's smart person's guides

Executive summary

  • What it is: Services that run snippets of back-end code for apps and websites without any overhead of managing servers.
  • Why it matters? Serverless computing services reduce the overhead and cost of managing either physical or virtual infrastructure.
  • Who this affects: Businesses running websites and apps with a need for back-end services or analytics.
  • When this is happening: Now - all of the major cloud platform providers offer a serverless computing service.
  • How to get it: Via your cloud platform of choice. Serverless computing is available via AWS, Google Cloud Platform, Microsoft Azure and IBM Bluemix.

What it is:

Serverless computing is a category of cloud computing service that encapsulates two of the main selling points of the as-a-service model — offering computing that is nearly entirely hands-off and where you really do only pay for what you use.

With serverless computing there is no virtual infrastructure for the user to manage and the user is only billed for when their code is running, down to the nearest 100 milliseconds.

Serverless computing services, such as AWS Lambda, are built to run snippets of code that carry out a single short-lived task.

These small self-contained blocks of code, known as functions, have no dependencies on any other code and as such can be deployed and executed wherever and whenever they are needed. An example of a Lambda function could be code that applies a filter to every image uploaded from a website to Amazon's S3 storage service.

Unlike a cloud application where code is structured in a more monolithic fashion and may handle several tasks, code running on serverless services like Lambda is more typical of that found in a microservices software architecture. Under this model, applications are broken down into their core functions, which are written to be run independently and communicate via API.

These small functions run by serverless services are triggered by what are called events. Taking Lambda as an example, an event could be a user uploading a file to S3 or a video being placed into an AWS Kinesis stream. The Lambda function runs every time one of these relevant events is fired. Once the function has run the cloud service will spin down the underlying infrastructure. This approach results in users being billed only for the time the code is running, in the case of AWS Lambda and its Microsoft Azure alternative, down to the nearest 100ms.

Additional resources:

Why it matters:

This more granular, pay-per-use approach can be much cheaper for the right kind of workloads. A case in point is the web app that was built to allow football fans to upload themselves singing along with the official Euro 2016 anthem by David Guetta. The agency that built the web app, Parallax, used AWS Lambda for various functions, including generating a custom album artwork based on information shared by the user.

James Hall, director of Parallax, said the service needed an infrastructure that could cope from going from no users to "millions" after Guetta read out the web address on TV.

Rather than paying to repeatedly spin virtual machines up on AWS EC2 in an attempt to meet demand, the team instead paid only for the time their code was running on Lambda.

Using "a more traditional architecture" with an AWS EC2 Auto Scaling pool would have cost between £500 to £1,500 per month, he said, compared to "less than £300 a month" it ended up costing to use Lambda and other AWS services to power the site.

The first one million requests on Lambda per month are free, followed by $0.2 per million requests thereafter, so for "for small applications, you could ostensibly run for absolutely nothing", said Hall.

Using Lambda can also be simpler than meshing together several other AWS services yourself, said Hall.

"The reason doing that in Lambda is so good is because you don't have a load of servers sat around waiting to process these images, you don't need to write a queuing system, you don't need any of that plumbing and leg work, you can just have one function that returns an image," he said.

Serverless services such as Lambda are not suited to running existing applications without those applications being rewritten, however, due to the code they run being structured very differently to that found inside most existing apps. Serverless services run small modular functions, which are event-driven and stateless.

Long-running computational tasks are also a no-no for Lambda at present, with each function to running for a maximum of five minutes, although Google's serverless offering doesn't have this restriction. A Lambda function can also only be executed 100 times concurrently, although this limit can be raised on request. Because serverless offerings like Lambda are relatively new they are also relatively immature. For instance, AWS Lambda is not covered by PCI DSS compliance statements at present, so couldn't be used to process credit card numbers.

That said there are plenty of use cases today for serverless computing. AWS Lambda can easily be integrated with many different AWS services and NoSQL databases via API and there are no charges for transferring data between Lambda and other AWS services within the same AWS region.

For Lambda, other possible uses include data processing, with Lambda carrying out real-time ETL on data within a Kinesis stream and loading it into a database after it's been transformed. A more concrete example is provided by Twitter, which uses a Lambda function to check video captured by users of its streaming service Periscope for pornography. Lambda functions can also be used to glue AWS services together, being triggered by Auto Scaling events or CloudWatch alarms and in turn calling other AWS services.

Additional resources:

Who this affects:

Serverless computing services are available on all of the major cloud platforms, both to individuals and businesses.

Firms from many sectors are using AWS Lambda, including Coca-Cola, Major League Baseball, AdRoll, Localytics for app usage analytics, FireEye, which built an intrusion detection system that processes events using Lambda, and US retailer Bustle. Amazon's own smart virtual assistant Alexa is also built in-part on Lambda.

AWS technical evangelist Ian Massingham says Lambda is well suited to web applications, analytics and IoT and, as such, should have cross-sector appeal.

Additional resources:

When this is happening:

You can get started with serverless computing right now. Since Amazon revealed Lambda in November 2014, competing services have been launched on each of the major cloud platforms.

Additional resources:

How to get it:

Various serverless computing services are available via the major cloud platforms but the most mature is AWS Lambda. There are plenty of guides to getting started with setting up a Lambda instance.

Lambda functions can be written in the Java, Python and JavaScript (Node.js) languages and there are software frameworks that help you build serverless applications, such as the appropriately-named Serverless Framework.

Other options for serverless services include Google Cloud Functions, an Alpha release which only supports JavaScript (Node.js) but allows for unlimited execution time for functions. Microsoft's Azure Functions, which supports a wider range of languages including C#, F#, Java, JavaScript (Node.js), PHP and Python and that has similar pricing to Lambda. Finally, there's also IBM Bluemix OpenWhisk, whose language support includes JavaScript (Node.js) and Swift.

Additional resources

About Nick Heath

Nick Heath is chief reporter for TechRepublic. He writes about the technology that IT decision makers need to know about, and the latest happenings in the European tech scene.

Editor's Picks