Serverless computing is an architecture where code execution is fully managed by a cloud provider, instead of the traditional method of developing applications and deploying them on servers.
It means developers don't have to worry about managing, provisioning and maintaining servers when deploying code. Previously a developer would have to define how much storage and database capacity would be needed pre-deployment, slowing the whole process down.
What is AWS Lambda?
AWS Lambda is a compute service from the cloud vendor Amazon Web Services (AWS) that lets you do just this: run code without provisioning or managing servers. AWS charges you for the compute power you use according to 100 millisecond increments. Developers can focus on their code and event triggers and AWS takes care of the rest.
Events could include changes to data in an Amazon S3 bucket or an Amazon DynamoDB table; in response to HTTP requests using Amazon API Gateway; or using API calls made using AWS SDKs. For example, when a user requests a car on your ride sharing app this could trigger the code which is written to fetch a car, or clicking the ‘buy’ button on an app.
"Lambda is an event driven execution environment,” explains Ian Massingham, chief evangelist at AWS. “So in very simple terms you have code and events, when the event arrives the code is executed for you automatically. So you don’t have to pre-position resources or have any standing infrastructure to provide the execution environment."
He adds that when the event is triggered, a piece of infrastructure is allocated dynamically to execute the code. “What happens under the covers is a Linux container is started on a machine and details, metadata about the event, is passed into the container at the point of execution."
Serverless isn't just available to AWS customers. IBM OpenWhisk is an alternative event based architecture. Google has Cloud Functions for "developers to create single-purpose, stand-alone functions that respond to Cloud events without the need to manage a server or runtime environment". And Microsoft has Azure WebJobs for running applications without having to worry about servers and infrastructure.
Massingham says that it is important to note that Lambda doesn't equate to serverless. "Lambda is the execution part and serverless is a little bit bigger," he said. "Beyond compute you also want to run things like your data stores in a way which doesn’t require you to operate infrastructure, a way to do identity management in a way that doesn’t require you to operate infrastructure.
"Lambda is the compute, and there are four core AWS services at play here: S3, DynamoDB, Lambda and Cognito, those are the four building blocks [to serverless]."
AWS CTO Werner Vogels added during his keynote at AWS re:Invent 2016: "There is the combination between Lambda, DynamoDB, API Gateway and Kenesis which allows you to build serverless applications. It is the whole ecosystem AWS gives you."
This is opposed to even the 'traditional' deployment model within AWS itself. As Massingham explained: "The traditional environment is EC2 [Elastic Compute Cloud] instances running web or app servers that wait around for requests and when they come they service them. That gives you floor costs, with Lambda your cost of execution with no traffic is zero and as you start to get traffic you scale up. It is way more cost effective at low levels of usage and way more scalable at high levels of usage, so benefits at both ends of the scale."
Vogels used an old favourite metaphor during his keynote: "Before, your servers were like pets. If they became ill you had to nurture them back to health. Then with cloud they were cattle, you put them out to pasture and got yourself a new one. In serverless there is no cattle, only your application. You don’t even have to think about nurturing back to health or getting new ones, all the execution is taken care of.”
Massingham concluded: "For new applications it's a no brainer, if you have an existing code base then you have to port it. For new apps it is a simple way to reduce costs and improve reliability."
Serverless is better for new applications, so tends to be the architecture of choice for startups, however enterprises are increasingly getting on board.
Enterprises customers that are already moving applications to serverless with Lambda include Thomson Reuters, Finra, Hearst, Vevo and Expedia, and AWS expects more to move in that direction. Vogels said: “It’s not just young companies that are going down this path of serverless, the largest enterprises have figured out that this is the way which is most cost effective for them.”
Massingham has similar views: "Serverless will go completely mainstream and you see these large enterprise customers looking towards this model to reduce costs and improve reliability and scalability."
If your organisation has built an Alexa app – known as a ‘skill’ - they have already effectively used Lambda. Massingham explained: "Lambda functions are the way Alexa skills are built and also with Lex you can trigger it as a step in the voice application you might develop. Adding new triggers and event sources all the time."
US bank Capital One is a Lambda customer, using it for "Cron style jobs and reacting to events produced by Amazon Web Services (everything from automatic data encryption, to cost management & compliance exercises like GitHub: capitalone/cloud-custodian)", according to a blog post from Ben Woodward, a software engineer at Capital One UK.
UK digital agency Parallax uses Lambda for campaigns, such as an app for a recent David Guetta ad campaign during the UEFA 2016 finals, which had to contend with big traffic spikes and a lot of downtime.
Accenture's entire Cloud Platform is built on a serverless architecture with AWS Lambda and API Gateway. This is the AWS competency partner's platform for helping customers manage their cloud resources.
Find your next job with computerworld UK jobs