Sandro Volpicella
Sandro's Blog - Serverless, AWS, SaaS

Sandro's Blog - Serverless, AWS, SaaS

AWS Lambda Interview Questions - How to Prepare for a Tech Interview

AWS Lambda Interview Questions - How to Prepare for a Tech Interview

24 Example Questions for Your Tech Interview

Sandro Volpicella
·Feb 26, 2022·

5 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

Table of contents

Cloud is everywhere! Especially AWS is used in so many different companies and roles. It is a skill that you need for a future-proof career.

AWS Lambda is one of these AWS Services that changed a lot in terms of developing scalable & resilient architectures.

It is important to be prepared for questions regarding Cloud, AWS, Serverless, and some services when preparing for an interview.

I've gone through a lot of interviews and some of the main questions I see when talking about cloud & serverless are questions about AWS Lambda. For many AWS Lambda is the serverless service. Questions are often not just about the service itself but also about serverless and event-driven concepts.

I collected several questions and possible answers for that. The questions range from really easy definitions and settings to concepts and more practical questions.

Let's dive right in.

Basics

We will start with some basic questions

What is AWS Lambda?

Lambda is an AWS service that executes your code. You don't need to handle any infrastructure and simply write code that gets executed.

Which languages is Lambda supporting?

  • Python
  • Node.js
  • Go
  • Java
  • PowerShell
  • C#
  • Ruby

What is the maximum timeout of a lambda function?

Lambda functions run for a maximum of 15 Minutes.

What is the main hardware configuration you can choose?

Memory. Between 128MB and 10,240MB. The computing processor will increase or decrease accordingly.

Can I use Lambda in VPCs?

Yes, you can simply choose the VPC in the configuration. Your lambda is then executed in your own network configuration.

How is the pricing of Lambda calculated?

Costs are purely calculated by the time a lambda function runs. The price varies for settings like:

  • Architecture
  • Memory

See an example calculation here

image.png

Which architectures are available in Lambda?

  • x86
  • arm

How do you trigger a lambda function?

There are many different ways of triggering lambda:

  • AWS Services (SQS, SNS, DynamoDB Streams, S3 Events)
  • CLI
  • Manually
  • API Gateway

How would you SSH into your lambda server?

This is not possible.

What are Pros of a serverless approach?

  • You don't have to manage infrastructure
  • You don't need to pay for idle times
  • Development is often easier

What are Cons of a serverless approach?

  • Vendor lock-in
  • Developer needs to know more areas (infrastructure, networking, coding)

Advanced

What are Cold Starts?

Cold starts refer to the time a lambda function needs to provision the environment to execute the actual handler code. The basic steps of a cold start are:

image.png

  1. Downloading code (e.g. from S3)
  2. Start Environment
  3. Initialise Code (outside of handler function)

In which cases do cold starts appear?

  • The lambda function didn't run for a certain time
  • Lambda needs to scale-out
  • Lambda refreshes the environment

It is never 100% predictable when a cold starts to happen.

What are methods for avoiding cold starts?

  • Function warmers: Call your lambda every n seconds. -> No 100% solution
  • Provisioned Concurrency. See this article
  • Not using lambda at all -> Use fargate or EC2

What is Provisioned Concurrency?

Provisioned Concurrency keeps your lambdas running instead of shutting them down after a certain period. With that, no cold start times will be there but it is pretty expensive.

Which workloads are not well suited for lambda?

  • Long-running processes. Often a container or many smaller lambda functions make more sense
  • Simple filtering operations between AWS services -> No lambda needed

How can you use secrets in AWS Lambda?

Use the AWS Secretsmanager and access it via the API. Attach IAM permissions to the Lambda role.

Where should you initialize static code?

Outside of the handler function. Because everything outside of the handler function won't run again for warm lambdas.

How would you assign a certain private IP range to your lambda?

Put your lambda into a VPC in a certain subnet and this is possible for your internal network.

How do you monitor Lambda functions?

Lambda functions come with CloudWatch metrics. There is a CloudWatch Group per lambda function with different streams. Metrics such as events, invocations, errors, latency, etc. are automatically included. Custom metrics can be added.

Third-party tools such as Dashbird or Lumigo are very popular as well for monitoring lambdas.

What is Lambda @ Edge

Edge lambdas run in the Content-Delivery Network of AWS. They execute closer to the user's location. They can be called from a CloudFront request. The available languages are Python and Node.

What are the benefits compared to containers or EC2?

  • You don't manage the infrastructure
  • No operations for NACLs, Security Groups, and network operations
  • You only pay for the time the lambda runs and not for idle times
  • You focus only on the business logic

How do you log in Lambda Functions?

All standard outputs will be redirected to CloudWatch by default. It is encouraged to use a more structured logger approach with JSON logger.

What is an idempotent lambda?

An idempotent function has the exact same behavior even if it will be executed several times. That means somehow the function knows it was already executed or the execution of the code won't change something.

This is often needed in an event-driven architecture since many calls in AWS are executed at least once. For example, an SQS standard queue can execute the same message twice. For that we need to ensure that the lambda function knows it was already executed (e.g. save the state in a DynamoDB table) and do a certain action (e.g. exit early) if the function was already executed.

Final Words

These are some example questions you can get with Lamdba. There are many more of course but I think it is really important to understand the main concepts of serverless computing and event-driven architectures. If you understand the basics you will be able to architect scalable architectures with AWS.

Good luck with your interview!

Did you find this article valuable?

Support Sandro Volpicella by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors
 
Share this