DEV Community

Danny Chan
Danny Chan

Posted on

Dive deep into serverless system design: event-driven, NoSQL, decouple, real-world practice

Introduction of serverless


 

What is serverless?

  • Serverless uses cloud services without servers to manage.
  • Developers focus on code without worrying about infrastructure.
  • Scales are automatically based on events like API calls.
  • Pay only for resources used instead of always-on servers.
  • Uses compute services like AWS Lambda for building apps.
  • Apps built from independent functions that run on-demand.
  • Well-suited for APIs, microservices, and event-driven architectures.
  • Removes server management overhead and reduces costs.

serverless-computing
CHAP_Serverless
serverless-next-steps


 

What is event-driven design?

  • Events trigger code execution instead of direct calls.
  • Independent services communicate through event messages.
  • Events are generated when the application state changes.
  • Services subscribe to relevant events asynchronously.
  • Events decouple services for independent development.
  • Microservices process single events without coordination.
  • Event brokers distribute events to multiple consumers.
  • Services are scaled independently based on event load.
  • Fault tolerance through duplicate event processing.

event-driven-benefits


 

What is a serverless microservice?

software architecture:
collection of small, independent, and loosely coupled services
Serverless microservice:
Decentralized architecture with minimal infrastructure management.
No dedicated servers:
Services run on ephemeral computing resources.
Event-driven:
Triggered by specific events or requests from other services.
Scalability:
Automatically scales based on demand, reducing operational complexity.
Pay-per-use:
Billed for actual resource consumption rather than fixed capacity.
Stateless:
Services don't maintain a session state, promoting scalability and fault tolerance.
Third-party services:
Use managed services for databases, storage, and authentication.
Rapid development:
Focus on coding business logic rather than infrastructure.
Fault tolerance:
Resilient to failures through redundancy and distributed design.
Increased agility:
Enables faster deployment and iteration of individual microservices.


 

The underlying mechanism of AWS Lambda

  • Lambda runs code on virtual machines called Workers.
  • Workers are isolated AWS accounts using EC2 instances.
  • Firecracker creates secure containers for functions.
  • Functions run in containers on Workers.
  • Lambda scales Workers automatically for the load.
  • Workers have short lifetimes for security.
  • Lambda assumes execution roles to run functions.
  • Functions have isolated environments and storage.
  • The data plane uses encryption for communication.


 

The underlying mechanism of lambda running

  • Lambda runs code in response to events like HTTP requests.
  • Code runs in ephemeral containers on virtual machines.
  • Containers managed by AWS on computing optimized for serverless.
  • Lambda scales automatically based on incoming events.
  • Pay only when resources are used, not for idle computing capacity.
  • Code runs in isolated environments without servers to manage.
  • Events trigger code without worrying about provisioning.
  • AWS handles all infrastructure management for developers.
  • Lambda invokes code asynchronously and parallelizes executions.


 

The Underlying step of running lambda

  1. Configure trigger event for function code execution.
  2. Upload function code to Lambda.
  3. Assign execution role for Lambda to access resources.
  4. Lambda scales automatically based on event traffic.
  5. Lambda runs code in a containerized environment.
  6. Code handled and executed by AWS Lambda service.
  7. Lambda invokes code in response to a configured trigger.
  8. Logs and metrics were sent to CloudWatch for monitoring.
  9. Lambda bills only for compute duration used.
  10. Automatic management of computing resources by AWS.

welcome
level-abstraction
getting-started
lambda-foundation


 

What is an API gateway?

  • Manages access to APIs and services.
  • Acts as a front door for applications.
  • Routes requests to appropriate backends.
  • Handles traffic management and security.
  • Scales automatically for performance.
  • Enforces usage plans and quotas.
  • Integrates APIs and microservices.
  • Monitors APIs for observability.
  • Manages versions and deployments.

welcome


 

System design -

single service lambda with API gateway (merchant to merchant)


 


 


 


 


 


 


 


 

Top comments (0)