Cloud Notes
Comprehensive overview of serverless computing paradigm, covering its principles, architecture patterns, benefits, limitations, and real-world applications.
Serverless computing is a cloud execution model where the cloud provider dynamically manages the allocation and provisioning of servers. Despite the name, servers still exist — but developers never interact with them. The provider handles all infrastructure concerns while developers focus exclusively on writing code.
Serverless Spectrum
| VMs | Containers | Managed | FaaS | BaaS | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| (ECS) | Services | (Lambda | ||||||||
| (RDS) | etc) |
Serverless Services Beyond FaaS
| Category | AWS | Azure | GCP |
|---|---|---|---|
| Compute | Lambda | Functions | Cloud Functions |
| API | API Gateway | API Management | Cloud Endpoints |
| Storage | S3 | Blob Storage | Cloud Storage |
| Database | DynamoDB | Cosmos DB | Firestore |
| Queue | SQS | Queue Storage | Cloud Tasks |
| Events | EventBridge | Event Grid | Eventarc |
| Auth | Cognito | Azure AD B2C | Firebase Auth |
Serverless Architecture Pattern
Serverless Framework Deployment
# serverless.yml
service: my-serverless-app
provider:
name: aws
runtime: python3.11
stage: production
region: us-east-1
environment:
DYNAMODB_TABLE: ${self:service}-${self:provider.stage}
functions:
createUser:
handler: handlers/users.create
events:
- http:
path: users
method: post
cors: true
getUser:
handler: handlers/users.get
events:
- http:
path: users/{id}
method: get
cors: true
processOrder:
handler: handlers/orders.process
events:
- sqs:
arn: !GetAtt OrderQueue.Arn
batchSize: 10
resources:
Resources:
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:provider.environment.DYNAMODB_TABLE}
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH# Deploy serverless application
serverless deploy --stage production
# Invoke a function locally
serverless invoke local --function createUser --data '{"name": "John"}'
# View logs
serverless logs -f createUser --tail
# Remove all resources
serverless removeServerless Benefits
- Zero Server Management: No provisioning, patching, or scaling
- Pay-per-Execution: No cost when idle
- Automatic Scaling: From zero to thousands of concurrent executions
- High Availability: Built-in across multiple AZs
- Faster Time-to-Market: Focus on business logic only
- Reduced Operational Complexity: No infrastructure team needed
Serverless Challenges
- Cold Starts: Initial invocation latency
- Vendor Lock-in: Tightly coupled to provider's ecosystem
- Debugging Difficulty: Distributed tracing is complex
- Execution Limits: Timeout, memory, payload constraints
- State Management: Functions are stateless by design
- Testing Complexity: Hard to replicate cloud environment locally
Interview Questions
- What does 'serverless' actually mean?
Serverless doesn't mean no servers — it means developers don't manage servers. The cloud provider handles all infrastructure (provisioning, scaling, patching, availability). Developers deploy code; the provider runs it.
- What serverless services exist beyond functions (FaaS)?
Serverless databases (DynamoDB, Aurora Serverless), serverless storage (S3), serverless queues (SQS), serverless APIs (API Gateway), serverless event buses (EventBridge), and serverless authentication (Cognito).
- Design a serverless e-commerce backend.
API Gateway handles HTTP requests, Lambda functions process business logic (user auth, order processing, inventory), DynamoDB stores data, S3 holds product images, SQS queues order processing, SES sends email confirmations, and CloudFront serves the frontend.
- What are the cost implications of serverless vs traditional servers?
Serverless is cheaper for intermittent workloads (pay only during execution). For constant high-throughput workloads, traditional servers with reserved pricing may be cheaper. Break-even depends on utilization — typically serverless wins below 20-30% average utilization.
- How do you handle state in serverless architectures?
Use external state stores: DynamoDB for key-value data, S3 for files, ElastiCache/Redis for session data, Step Functions for workflow state, and SQS/EventBridge for event-driven state transitions.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Serverless Computing.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Cloud Computing topic.
Search Terms
cloud-computing, cloud computing, cloud, computing, service, models, serverless, serverless computing
Related Cloud Computing Topics