serverless Flashcards

(51 cards)

1
Q

What is serverless?

A

A paradigm where developers don’t manage servers—only deploy code.

Typically involves deploying functions (FaaS).

Originated with AWS Lambda; now includes managed services like databases, messaging, storage.

Servers still exist—you just don’t provision, manage, or see them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What AWS services are commonly used in a serverless architecture?

A

Lambda

DynamoDB

Cognito

API Gateway

S3

SNS & SQS

Kinesis Data Firehose

Aurora Serverless

Step Functions

Fargate

Typical flow:
Users → S3 (static content)
Users → API Gateway → Lambda → DynamoDB
Users → Cognito (login)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why choose AWS Lambda over EC2?

A

EC2:

Virtual servers in the cloud

Limited by RAM/CPU

Always running

Scaling requires manual intervention

Lambda:

Virtual functions with no servers to manage

Short, time-limited executions

Runs on-demand

Scaling is fully automated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the key benefits of AWS Lambda?

A

Simple pricing: pay per request/compute; generous free tier

Deep integration with AWS services

Supports many programming languages

Built-in monitoring via CloudWatch

Easy to scale function resources (up to ~10 GB RAM)

More RAM also boosts CPU and network performance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What languages and runtimes does AWS Lambda support?

A

Node.js

Python

Java

C# (.NET Core) / Powershell

Ruby

Custom runtimes (e.g., Rust, Go) via Runtime API

Container images that implement the Lambda Runtime API (use ECS/Fargate for general Docker workloads)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does Amazon Cognito provide, and how do User Pools differ from Identity Pools?

A

Purpose: Gives users an identity to interact with web or mobile apps.

Cognito User Pools:

Handles user sign-in for app users.

Integrates with API Gateway & Application Load Balancer.

Cognito Identity Pools (Federated Identity):

Provide AWS credentials so users can access AWS resources directly.

Can use User Pools as an identity provider.

Cognito vs IAM: Best for hundreds of users, mobile users, and SAML authentication.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What features do Cognito User Pools provide for managing users in web and mobile applications?

A

Serverless user database

Username/email + password login

Password reset

Email & phone number verification

Multi-factor authentication (MFA)

Federated identities (Google, Facebook, SAML, etc.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do Cognito User Pools integrate with API Gateway and Application Load Balancer?

A

CUP issues tokens used to authenticate requests

API Gateway receives the token and validates it with Cognito

Application Load Balancer (ALB) can authenticate users using CUP

ALB listeners evaluate the Cognito token before routing traffic

Backend applications receive only authenticated requests

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does a Cognito Identity Pool provide, and how is it used?

A

Provides temporary AWS credentials for users

Users can come from Cognito User Pools or 3rd-party logins (Google, Facebook, SAML, etc.)

Allows direct access to AWS services (e.g., S3, DynamoDB) or via API Gateway

IAM policies are defined in the Identity Pool

Policies can be customized per user_id for fine-grained access control

Supports default IAM roles for authenticated and guest users

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does a Cognito Identity Pool provide users with temporary AWS credentials?

A

User logs in through a provider:

Cognito User Pool, Google, Facebook, SAML, etc.

The login provider returns a token

Identity Pool exchanges the token for temporary AWS credentials

These credentials allow direct access to AWS services (e.g., S3, DynamoDB)

Access is controlled by IAM roles assigned in the Identity Pool

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do Cognito Identity Pools enable row-level security in DynamoDB?

A

Identity Pools assign temporary AWS credentials to each authenticated user

IAM policies can include conditions based on the user’s identity (e.g., cognito-identity.amazonaws.com:sub)

DynamoDB item access can be restricted so users can only read/write their own items

Achieves fine-grained, per-user authorization without application-side filtering

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the main ways AWS Lambda integrates with other AWS services?

A

API Gateway — invoke Lambda for REST/HTTP/WebSocket APIs

EventBridge / CloudWatch Events — cron, scheduled, and event-driven triggers

S3 — invoke Lambda on object creation or deletion

DynamoDB Streams — process item-level changes

SNS — process messages fan-out style

SQS — poll and process queue messages

Kinesis / Kafka — consume streaming data

Cognito — trigger Lambda on auth events

CloudFormation custom resources — Lambda-backed actions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does the serverless thumbnail-creation workflow using AWS Lambda work?

A

An image is uploaded to Amazon S3

The S3 upload triggers a Lambda function

Lambda generates a thumbnail of the image

Lambda then:

Stores the new thumbnail in S3

Saves metadata (image name, size, creation date, etc.) in DynamoDB

Entire workflow is fully serverless and event-driven

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you implement a serverless scheduled (CRON) job in AWS?

A

Create a CloudWatch Events / EventBridge rule

Configure it with a CRON or rate expression

The rule triggers a Lambda function on the schedule

Lambda runs the task (e.g., cleanup, reporting, automation)

Common example: run every 1 hour

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How is AWS Lambda priced?

A

Pay per request

First 1M requests free

Then $0.20 per 1M requests

Pay per duration (billed per 1 ms)

First 400,000 GB-seconds free per month

Cost: $1.00 per 600,000 GB-seconds after free tier

Cost varies with memory size (more RAM = more CPU + network)

Lambda is typically very cheap because usage is event-driven & short-lived

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the key AWS Lambda limits to know (per region)?

A

Execution Limits

Memory: 128 MB – 10 GB

Max runtime: 900 sec (15 min)

Env vars: 4 KB

/tmp storage: 512 MB – 10 GB

Concurrency: 1000 (increasable)

Deployment Limits

Deployment package (zip): 50 MB

Uncompressed size: 250 MB

Env vars size: 4 KB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How does AWS Lambda concurrency and throttling work?

A

Concurrency

Default regional concurrency: 1000

You can set reserved concurrency per function to limit or guarantee capacity.

Throttling Behavior

When concurrency is exceeded → Throttle

Synchronous invokes: return 429 ThrottleError

Asynchronous invokes: automatically retried, then sent to DLQ

To increase the limit: open a support ticket

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What problem can occur if you don’t set reserved concurrency on a Lambda function?

A
  • Other services (ALB, API Gateway, SDK/CLI, etc.) may consume all available regional concurrency.
  • Your function may hit the 1000 concurrent executions limit.
  • This causes throttling for other functions or parts of your application.
  • Result: some users get throttled, others don’t, depending on traffic distribution.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How does AWS Lambda handle concurrency limits for asynchronous invocations?

A

If the function doesn’t have enough available concurrency, extra events are throttled.

When throttled (429) or on system errors (5xx), Lambda automatically retries.

Retry window: up to 6 hours.

Retry delay: exponential backoff from 1 sec up to 5 minutes.

Events are returned to the queue and reprocessed until successful or timeout.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is a Lambda cold start, and how does Provisioned Concurrency prevent it?

A

Cold Start

Happens when a new Lambda instance is created.

Lambda loads code + dependencies and runs initialization.

First request to a new instance has higher latency.

Provisioned Concurrency

Pre-initializes Lambda instances in advance, so they’re always warm.

Ensures consistent low latency for all invocations.

Can be auto-scaled with Application Auto Scaling.

Cold starts in VPC were significantly reduced (Oct–Nov 2019).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the difference between Reserved Concurrency and Provisioned Concurrency in AWS Lambda?

A

Reserved Concurrency

Sets a hard limit on how many concurrent executions a function can use.

Guarantees that this amount is always available for that function.

Also prevents the function from consuming more than the reserved amount (protects other functions from being starved).

Provisioned Concurrency

Pre-initializes Lambda instances so they are always warm (no cold starts).

Ensures consistently low latency for all invocations.

Managed automatically through Application Auto Scaling.

22
Q

What does AWS Lambda SnapStart do, and how does it improve performance?

A

Speeds up Lambda functions by up to 10x for Java, Python, and .NET.

Invokes functions from a pre-initialized snapshot instead of starting from scratch.

When you publish a new version:

Lambda initializes the function.

Takes a snapshot of memory + disk state.

Snapshot is cached for fast reuse.

Result: dramatically reduced initialization time → reduced cold start latency.

23
Q

What does “Customization at the Edge” mean in AWS, and which services enable it?

A

Running application logic at AWS edge locations to reduce latency for end users.

Achieved using Edge Functions attached to CloudFront distributions.

Two AWS services enable this:

CloudFront Functions (lightweight, very fast)

Lambda@Edge (more powerful, supports deeper request/response manipulation)

No servers to manage; code runs close to users globally.

24
Q

What is Lambda@Edge and what can you do with it?

A

A feature of CloudFront that lets you run Lambda functions at AWS edge locations.

Used to customize and modify CloudFront requests and responses.

Common capabilities:

Inspect/alter viewer requests (from users).

Modify origin requests (to the backend).

Adjust origin responses and viewer responses.

Helps with A/B testing, header manipulation, user authentication, URL rewrites, caching logic, and more.

Global execution with no servers to manage.

25
What are common use cases for CloudFront Functions and Lambda@Edge?
Website security & privacy Dynamic web application logic at the edge SEO optimizations Intelligent origin routing Bot mitigation Real-time image transformation A/B testing User authentication & authorization User prioritization User tracking & analytics
26
What are CloudFront Functions and what are they used for?
Lightweight JavaScript functions for high-scale, ultra-low-latency CDN customizations. Designed for millions of requests per second with sub-millisecond startup times. Used to modify Viewer Requests and Viewer Responses: After CloudFront receives a viewer request Before CloudFront sends the response back Fully managed inside CloudFront (no separate Lambda service).
27
What is Lambda@Edge and how does it modify CloudFront requests/responses?
Lambda functions written in Node.js or Python that run at CloudFront edge locations. Scales to thousands of requests per second. Can modify all four CloudFront event phases: Viewer Request – after CloudFront receives the request Origin Request – before CloudFront forwards the request to the origin Origin Response – after CloudFront gets the origin’s response Viewer Response – before the response is returned to the viewer You author functions in us-east-1, and CloudFront replicates them globally.
28
How do CloudFront Functions and Lambda@Edge differ?
CloudFront Functions Runtime: JavaScript Scale: Millions of req/s Triggers: Viewer Request/Response Exec time: < 1 ms Memory: 2 MB Package size: 10 KB No network access, no file system, no access to request body Cheaper (1/6 price of Lambda@Edge) Lambda@Edge Runtime: Node.js, Python Scale: Thousands of req/s Triggers: Viewer + Origin Request/Response Exec time: 5–10 sec Memory: 128 MB to 10 GB Package size: 1–50 MB Has network access, file system access, and request body access No free tier; billed per request + duration
29
When should you use CloudFront Functions vs. Lambda@Edge?
CloudFront Functions – best for: Cache key normalization Transforming headers, cookies, query strings, URLs Header manipulation (add/modify/remove) URL rewrites or redirects Lightweight request authentication & authorization Validating user tokens (e.g., JWT) Lambda@Edge – best for: Longer logic with more compute time Using third-party libraries (e.g., AWS SDK) Network access to external services File system access Accessing and processing the request body
30
What is the default VPC behavior of AWS Lambda, and what limitation does it create?
By default, Lambda runs outside your VPC in an AWS-owned VPC. It can access the public internet, but cannot reach private resources inside your VPC. This means it cannot directly connect to: RDS (private) ElastiCache Internal load balancers Any private subnet resources Result: To access private resources, you must configure the Lambda function to run inside your VPC.
31
What happens when you place a Lambda function inside a VPC?
You must specify: VPC ID Subnets Security Groups Lambda creates ENIs (Elastic Network Interfaces) in your subnets. This allows Lambda to access private resources like RDS, ElastiCache, internal services, etc. Adds some initialization overhead because ENIs must be attached.
32
Why use RDS Proxy with AWS Lambda, and what benefits does it provide?
Prevents Lambda functions from opening too many DB connections during high concurrency. RDS Proxy benefits: Connection pooling & sharing → improved scalability Faster failover (up to 66% reduction) Enhanced security via IAM auth & Secrets Manager integration Lambda must run inside your VPC to use RDS Proxy.
33
What is S3 Object Lambda and what can you use it for?
Lets you run Lambda functions to transform S3 objects as they are retrieved. Requires only one S3 bucket plus S3 Access Points and S3 Object Lambda Access Points. Use cases: Redacting PII before analytics or lower environments Converting formats (e.g., XML → JSON) Resizing or watermarking images dynamically based on caller attributes
34
How can RDS and Aurora invoke AWS Lambda, and what requirements must be met?
RDS (PostgreSQL) and Aurora MySQL can invoke Lambda functions directly from within the DB instance. Enables processing of data events inside the database (e.g., triggers). DB instance must have outbound network access to Lambda: Public internet NAT Gateway VPC Endpoints DB instance requires permissions to invoke Lambda, via: Lambda resource-based policy IAM policy attached to the DB environment
35
What are RDS Event Notifications and what information do they provide?
Notify you about DB instance–level events (e.g., created, stopped, started). Do not provide any information about the data itself. Event categories you can subscribe to: DB instance DB snapshot DB parameter group DB security group RDS Proxy Custom Engine Version Near real-time delivery (up to 5 minutes). Can send to SNS or be consumed via EventBridge.
36
What is Amazon DynamoDB and what are its main characteristics?
Fully managed, highly available NoSQL database. Automatically replicated across multiple AZs. Supports millions of requests per second and massive scale (trillions of rows, 100s of TB). Provides single-digit millisecond performance. Schema flexibility: items can evolve over time. Integrated with IAM for access control and security. Offers low cost and auto-scaling. Table classes: Standard & Infrequent Access (IA).
37
What are the core structural concepts of DynamoDB?
Data is stored in tables. Each table has a primary key (defined at creation). Tables contain items (rows), which can grow infinitely. Items contain attributes, which can evolve and be nullable. Max item size: 400 KB. Supports these data types: Scalar: String, Number, Binary, Boolean, Null Document: List, Map Sets: String Set, Number Set, Binary Set Allows rapid schema evolution and flexible data modeling.
38
In DynamoDB, how do partition keys, sort keys, and items relate?
A DynamoDB table stores items with attributes. Each item is uniquely identified by its primary key. Primary key can be: Partition key only, or Partition key + Sort key Items with the same partition key are grouped and sorted by the sort key. Useful for modeling related data, such as games, scores, logs, or time-series entries.
39
What are the two DynamoDB read/write capacity modes and how do they differ?
Provisioned Capacity Mode You specify Read Capacity Units (RCU) and Write Capacity Units (WCU). Best for predictable workloads. Can enable Auto Scaling to adjust capacity automatically. Cheaper when traffic is steady. On-Demand Capacity Mode No capacity planning; DynamoDB scales automatically. You pay per request. Ideal for unpredictable or spiky workloads. More expensive at sustained high throughput.
40
What is DynamoDB Accelerator (DAX) and why would you use it?
Fully managed, in-memory cache for DynamoDB. Delivers microsecond read latency—up to 10× faster than DynamoDB alone. Ideal for read-heavy or burst-y workloads. Requires no application logic changes (API-compatible with DynamoDB). Helps reduce read pressure on DynamoDB tables. Cluster-based, highly available, and managed by AWS.
41
What are DynamoDB Streams and what can you do with them?
Capture a time-ordered sequence of item-level changes in a DynamoDB table. Records include: INSERT, MODIFY, REMOVE events. Retention: 24 hours. Common use cases: Trigger Lambda functions to react to data changes. Real-time processing (analytics, indexing, notifications). Cross-region replication patterns. Streams guarantee at-least-once delivery and preserve order per partition key.
42
What are DynamoDB Global Tables and why use them?
Provide multi-Region, multi-writer replication for DynamoDB tables. Enable low-latency reads and writes for globally distributed applications. Regions stay synchronously replicated (last-writer-wins conflict resolution). Fully managed—no custom replication code required. Ideal for: Global applications Disaster recovery Multi-Region active-active architectures
43
What is DynamoDB TTL and what does it do?
Time To Live (TTL) automatically deletes items after a specified timestamp. Helps reduce storage costs by removing stale data. Deletion is automatic, background, and free. Common use cases: Session expiry Event logs Temporary data Expired items are removed within 48 hours, not instantly.
44
How does DynamoDB provide backups for disaster recovery?
Supports on-demand backups that create full table snapshots at any time. Supports Point-in-Time Recovery (PITR): Restores table to any second in the last 35 days. Backups do not affect performance or availability. Restores create a new table, preserving the original. Useful for accidental deletes, corruption, and DR scenarios.
45
How does DynamoDB integrate with Amazon S3?
Use DynamoDB Export to S3 to send table data directly to S3 without affecting table performance. Exports data in parquet format for analytics (e.g., Athena, Glue, EMR). Can perform full historical exports using Point-in-Time Recovery (PITR) timestamps. Use cases: Analytics at scale Archival Data lake ingestion Auditing & compliance
46
What is AWS API Gateway and what is it used for?
Fully managed service for creating and managing APIs at scale. Supports REST, HTTP, and WebSocket APIs. Handles authorization, throttling, caching, monitoring, and request/response transformation. Integrates with Lambda, ECS, EC2, DynamoDB, and many other AWS services. Automatically scales to handle millions of requests. Offloads common API concerns: CORS, deployment stages, versioning, rate limiting.
47
What high-level integration types does API Gateway support?
Lambda Integration Invoke Lambda functions to process API requests. HTTP / Private Integrations Forward requests to HTTP backends, ALB/NLB, or private services in a VPC. AWS Service Integrations Directly call AWS services (e.g., SQS, SNS, DynamoDB) without Lambda. Mock Integration API Gateway returns a predefined response without calling any backend. VPC Link Securely connect APIs to private VPC resources.
48
What are the three API Gateway endpoint types and how do they differ?
Edge-Optimized Default for REST APIs. Uses CloudFront to reduce latency for global clients. Regional Designed for clients in the same region. You can attach your own CloudFront distribution. Private Accessible only from a VPC using VPC Endpoints (Interface). Not exposed to the public internet.
49
How does API Gateway provide security for your APIs?
IAM Authorization Use IAM roles/policies for programmatic or internal access. Lambda Authorizers (formerly Custom Authorizers) Run custom logic to allow/deny requests (e.g., token validation). Cognito User Pools Built-in authentication for web & mobile users. Resource Policies Restrict access by VPC, IP range, account, or principal. mTLS (Mutual TLS) Client certificates for strong client authentication. TLS Termination All API Gateway endpoints enforce HTTPS.
50
What are AWS Step Functions and what problem do they solve?
A serverless orchestration service for coordinating multiple AWS services and Lambda functions. Build workflows using state machines with visual, JSON-based definitions. Support sequential, parallel, branching, retry, and error-handling steps. Ensure reliable execution with automatic retries and built-in error handling. Integrate with over 200 AWS services without writing glue code. Ideal for: Long-running workflows Microservice orchestration Data processing pipelines Human approval workflows
51