Throughout this study plan, I’ve been getting you to try and think for yourself, and use the resources that are out there. I’m sure you look at more than just this website for AWS pointers and tutorials, so you’re already doing that mostly. Sources simply need distilling, so thinking through questions and ‘searching for meaning’ will help you more in the long run. This week, I’ll be going through the Lambda and Serverless resources, and helping you to think about:
- Why are they needed?
- When would we use?
- What do we need to know about them to understand?
- How are they used?
- What do we need to know to pass the exam?
Let’s start with the why. As ever I’ve created a table of resources for you.
Why use Lambda/Serverless technologies?
If you happened to read my Tim Fellows case study, you’ll see how I used a course plan to prime my brain for a DevOps training course at work. In a similar way, I used the serverless whitepaper to prime my brain for the overall raison d’etre of Lambdas and serverless technologies. Think of it like the ‘sales pitch’ for the technology. You’re welcome to see the flashcards I created for this overall process if you’d like some context.
So the ‘why’ in this case becomes a case of economics – we don’t pay for provisioned resources that we never use. We don’t pay developer time for patching and managing the infrastructure we never use. Further, as well see later the scalability of what you do use can be configured in quite elegant fashion.
Equally as important from the perspective of ‘exam filtering’ is knowing when not to use, which we can see from the paper is:
- When the goal is explicitly to avoid making any changes to an application – so it’s clear ‘Lambdas need some setup’.
- When fine-grained control over the environment is required, such as specifying particular operating system patches or accessing low-level networking operations, in order for the code to run properly. Makes sense, the trade-off for not managing something ourselves is we don’t get a say on precise-implementation details
- When an on-premises application hasn’t been migrated to the public cloud – hmm, so when we learn more perhaps there will be some info about where it will run too.
Hope you’re with me so far. I’m trying to use a line of questioning that will shape my ultimate understanding of Lambdas. Regardless of whether you read the whitepaper/flashcards we’ll go into some details of the ‘what’ next. We’ll do that by looking at the Lambda Architecture, but first let’s at least do something hands-on…
So, just dive in and play with the tools. We’re aiming for the exam sure, but let’s try a simple 101 example. Read/try the Getting Started section from ‘Create a function‘, all the way through to ‘Tools‘. Don’t forget to clean up any resources afterwards!
With a little hands-on experience, we can go back to the what is Lambda guide briefly, if we didn’t read it already. If you’re really interested in the high level view, read any/all of the whitepaper, my flashcards or the welcome page.
Next we’ll dive a bit deeper into the lambda concepts page that you might have skimmed when going through the ‘Getting started’ section. We’ll want to expand up on the basic concepts now we’ve played around a bit. I have formulated a questions page for this reason. The questions here are meant as a starting point. The idea is to make you aware that Lambda crosses over into a number of areas, such as.
- The core concepts/components.
- Networks/VPC for your functions.
- Security esp in terms of Service Linked Roles.
- Metrics and Logging.
- CI such as CodePipeline.
By reading the questions page first, we are ‘sowing the seed’ of what else is out there in the Lamda world.
You’ll get hands on with how the Lambda and the function body are separate entities when you do any tutorial, so we don’t need to cover that. It will be very familiar for those of you who do functional programing. One concept that came up in the exams for me and seems a very likely concept to be tested on is around function scaling.
The first time you invoke your function, AWS Lambda creates an instance of the function and runs its handler method to process the event. When the function returns a response, it stays active and waits to process additional events. If you invoke the function again while the first event is being processed, Lambda initializes another instance, and the function processes the two events concurrently. As more events come in, Lambda routes them to available instances and creates new instances as needed. When the number of requests decreases, Lambda stops unused instances to free up scaling capacity for other functions.https://docs.aws.amazon.com/lambda/latest/dg/invocation-scaling.html
This whole approach is the very essence of scalability, i.e. being stateless and able to respond to demand in linear fashion. Let’s look at that a bit more.
There are several approaches to scaling, each with pros and cons, I’d read this overview and this questions list to get some ideas. The diagram below shows the ‘concurrency limit’ approach to scaling a lambda, where you have a fixed upper and an number of instances that scale with the number of requests. There us also the capability to serve some requests a little quicker (burst capacity ) to account for a small, temporary rush as you get close to the concurrency limit.
I’d look at provisioned concurrency and autoscaling with pricidosed concurrency on the same page. What do these diagrams do differently from each other?
Why might I need one over the other? Think in terms of the exam at this point.
Another exam point that is important to understand is versioning, as it relates to both development and deployment questions.
I think versioning is important to get for 2 reasons in the exam. One is that from a development point of view, it’s like moving from a snapshot to a tagged version.
The other is that it’s a mechanism for CI/CD and any manual deployments – you want to know you’re deploying a precise version, and you want to the option of phasing newer versions in. If you think back to the exam guides and blueprints, deployment strategies are important to understand.
See my previous article on deployment technologies for an overview of deployment strategies if you’d like.
It’s an exam. You think you won’t get questions on best practice one way or another? I would try and cover all understand the topics on this page at least lightly.
A lot of these subjects you can build on when you gain hands-on experience, which we’ll revisit now.
More hands-on Tutorials
There’s a lot of concepts to take in, Lambdas are a vast area. I can’t teach it all to you (in fact that’s not really my aim) but I can point you in the direction to help yourself by highlighting some concepts.
I’d encourage you to try some of these tutorials (better still find some of your own) and then re-visit the concepts such as scaling and monitoring later.
Some examples are:
- Pluralsight (Subscription required, but I get no commission for this incidentally).
- Simple S3 tutorial (building blocks to learn Lambda).
- Samples (a handful of ideas you could build on too).
- API Gateway Tutorial – useful as we’ll cover API Gateway in the next module.
- If you’re just looking to pass the exam, that’s fine, do the tutorials to get a feel for functions, handlers and the like. Just keep an active reminder of the concepts such as versioning and scaling in flashcards.
- If you’re trying to get a better at your day job too, do the tutorials as above, but then try and incorporate the more advanced concepts. Can you add versioning into a tutorial? What about finding out about monitoring? Change the scaling pattern perhaps?
- You can choose a hybrid too – take the first approach for the exam itself, but use the tutorials to get you started. Then in your day job, explore the more advanced examples with some ‘real code’.
There was a lot to cover with Lambda, more than I could hope to distill in one article. I would encourage you to look at the big picture as per this article, and then use active learning (flashcards/quizzes) to at least cover these high level concepts. My exam experience has already been distilled on these pages, but you’ll want to learn architectures, not questions by rote.
Additionally, nothing beats the hands on experience that tutorials give you, so get a few under your belt I’d say.
I hope you found this week useful. Please feel free to give feedback as ever. Next week we’ll build on this by looking at API Gateway.