What is Lambda

Lambda is a service from cloud provider Amazon Web Services (AWS).

It allows small pieces of computer code to be run without servers. Because of this, it’s often said that Lambda is part of the ‘serverless‘ movement.

How is it possible to run computer code without a computer? It’s not – the ‘serverless’ tag is a bit mis-leading, so what’s going on?

Here’s What Happens

Usually computer code for Lambda is split into simple functions – each is usually good at doing one specific thing – calculating the total or a shopping cart, applying a filter over an image, and so on.

The code is written on a local machine and then uploaded to Lambda.

When the new function is triggered it executes. A typical trigger might be a special AWS url being hit on.

The Mayfly

The Mayfly
The giant mayfly (Hexagenia limbata)

Just like the Mayfly – a Lambda function lives only for a very brief time. The smallest billable period for a Lambda function is 100mS – one tenth of a second, but a functions lifetime could be a just few milliseconds.

When it’s first triggered, AWS creates a ‘container’ on one of their thousands of servers. The container is a virtual computer, but without many of the resources that a proper server might have.

Once the container is up and running, the Lambda function is executed inside of the container. That way, it can’t affect other clients functions – millions of which will be running at the some time, some of them on other servers, maybe some on the same server (but different containers) as yours.

Once execution has finished – that’s that. AWS sometimes destroys the container, sometimes they keep it open just in case you want to run the same function again.

Like the Mayfly, your code has been born, unfurled its wings, done its job, and died, all in the blink of an eye.

Massive Benefits

So why do we care?

Truth is that running and administering your own fully fledged server is complicated, expensive, and relatively painful. There are updates, security issues – you name it.

Serverless functions don’t suffer from most of these problems. Their containers are secure, and include only what they need to run the function. Behind the scenes AWS is looking after the containers so that when they’re created they run flawlessly.

Each invocation (that’s what creating and executing a lambda function is called) is very cheap. You’re charged only on execution, so if your service that depends on Lambda isn’t busy, you’ll be charged nothing.

So price is one massive benefit – another is that Lambda functions usually do just one thing. Because of that – it’s easy to find the parts of your system that aren’t working well, or at all, and fix them.

Use of serverless code and systems is growing quickly. According to reports, serverless use is growing by 75% a year.


Tags

AWS, Cloud Function, Lambda, Serverless


Subscribe to our newsletter now!