Architecting Serverless Microservices
Architecting Serverless Microservices
Section titled “Architecting Serverless Microservices”Characteristics of a Microservice
Section titled “Characteristics of a Microservice”Autonomous
Section titled “Autonomous”- Independent Development and Deployment: Can be developed and deployed without affecting other microservices
- Independent Scaling: Scales based on its own demand patterns
- Code Isolation: Does not share code with other microservices
- API Communication: Communicates over well-defined APIs using lightweight protocols
Specialized
Section titled “Specialized”- Single Business Function: Performs one specific business capability solving a particular problem
- Small Team Ownership: Owned by small development teams who choose their own tools
- Stateless Design: Should be stateless to ensure fast instantiation and scaling
- Own Data Store: Has its own dedicated data store for ACID transactions when needed
Example: Breaking a Monolithic Application
Section titled “Example: Breaking a Monolithic Application”Monolithic Forum Application:
- Tightly coupled processes for users, topics, and messages
- Single service deployment
- Scaling affects entire architecture
- Complex feature additions as codebase grows
- High availability risk due to dependent processes
Microservice Forum Application:
- User Service: Independent user management
- Topic Service: Separate topic handling
- Message Service: Dedicated message processing
- Each service can be updated, deployed, and scaled independently
- Lightweight API communication between services
Benefits of Microservices
Section titled “Benefits of Microservices”Team Agility
Section titled “Team Agility”Microservices foster small, independent teams with ownership of their services. Teams work within well-understood contexts and can develop more quickly with shorter development cycles.
Reusable Code
Section titled “Reusable Code”Dividing software into small, well-defined modules enables teams to use functions for multiple purposes. Services written for specific functions can be reused as building blocks for other features.
Flexible Scaling
Section titled “Flexible Scaling”Each microservice can be independently scaled to meet demand for specific application features. This enables:
- Right-sizing infrastructure needs
- Accurate cost measurement per feature
- Maintained availability during demand spikes
Technological Freedom
Section titled “Technological Freedom”Development teams have autonomy to make technical decisions and choose the best tools for their specific problems. Teams are responsible for creating, deploying, and maintaining their microservices.
Resilience
Section titled “Resilience”Applications handle service failures through functionality degradation rather than complete system crashes, unlike monolithic applications.
Simplified Deployment
Section titled “Simplified Deployment”Continuous integration and continuous delivery pipelines simplify trying new ideas and rolling back changes. Low cost of failure enables experimentation and accelerates time-to-market.
Microservice Serverless Patterns on AWS
Section titled “Microservice Serverless Patterns on AWS”RESTful APIs
Section titled “RESTful APIs”- Architecture: Representational State Transfer requiring stateless compute
- Implementation: Amazon API Gateway with AWS Lambda
- Alignment: Matches Lambda’s stateless function design principle
- Duration Limit: Lambda functions have maximum 15-minute execution time
Containers
Section titled “Containers”- Use Case: When microservices require more than 15 minutes to complete
- Serverless Option: AWS Fargate deployed behind Application Load Balancer
- Alternative: Amazon ECS or Amazon EKS if serverless isn’t a requirement
- Request Flow: Amazon API Gateway → Application Load Balancer → Containers
Streaming
Section titled “Streaming”- Integration: AWS Lambda integrated with streaming services
- Services: Amazon Kinesis Data Streams for scalable streaming solutions
- Scaling: Lambda scales automatically with Kinesis
Microservices in Three-Tier Architecture
Section titled “Microservices in Three-Tier Architecture”Microservices operate primarily at the application tier and data tier of a web three-tier architecture:
- Each API request fulfills a specific business capability
- Pattern: Amazon API Gateway + AWS Lambda + Amazon DynamoDB = Serverless microservice
- Lambda Suitability: 15-minute maximum execution time makes Lambda ideal for microservice compute components
Microservices form only part of a three-tier architecture solution and should not be considered a standalone full three-tier architecture solution.
Microservice applications are composed of autonomous, specialized services that provide significant benefits in team agility, code reusability, flexible scaling, technological freedom, resilience, and simplified deployment.