System Design ‐ Landscape - FullstackCodingGuy/Developer-Fundamentals GitHub Wiki

Technologies

read

✅ EC2, VPC, EBS, and Load Balancers ✅ RDS, Aurora, and DynamoDB ✅ Route 53, CloudFront, and Global Accelerator ✅ Architecting for resilience, high availability, and disaster recovery ✅ Security best practices and cost optimization

Key Components

read

Principles

read
  • GraphQL

Patterns

read

Design patterns offer numerous advantages in software development. They can simplify the coding process, enhance code maintainability, and promote code reuse.

They also help developers write code that is more efficient, scalable, and adaptable. And they're incredibly beneficial when working on a project with multiple contributors. This is because design patterns provide a shared framework of best practices that can ensure consistency across the codebase.

Advantages of system design patterns
  • Code reusability: One of the main advantages of using design patterns is code reusability. By following a standard structure, developers can easily reuse code in different parts of an application or even in different applications altogether.
  • Scalability: Design patterns allow for scalability in applications, as they provide a structured approach to writing code. This makes it easier to add new features or make changes to existing ones without disrupting the overall architecture of the application.
  • Maintainability: Using design patterns can make code more maintainable, as they provide a standardized approach to solving problems. This makes it easier for developers to understand code written by others and to maintain it over time.
  • Reduced errors: Design patterns are tried and tested solutions to common problems. By using these patterns, developers can avoid common errors and pitfalls that might arise when writing code from scratch.
  • Performance: Design patterns can improve the performance of an application by providing a structured approach to solving problems. This can result in more efficient code that executes faster and uses fewer resources.

System Design Patterns

  • API Gateway
  • Backends for frontend
  • Aggregator Pattern
  • CQRS - Read (query) and write (command) operations are decoupled into separate services, allowing each service to be optimized independently. This pattern facilitates better scalability and efficiency in systems with significantly different read and write characteristics, such as social media platforms or ecommerce websites.
  • Circuit Breaker - This pattern prevents cascading failures by detecting and isolating failed service requests, allowing the system to gracefully handle failures and maintain overall stability.
  • Event Sourcing - Instead of storing just the current state of data, event sourcing captures and persists all state changes as a sequence of events. This approach enables better auditing, debugging, and the ability to reconstruct the system's state at any point in time.
  • Publisher/Subscriber - Services that produce events (publishers) are decoupled from services that consume them (subscribers). Publishers push events to an event bus, a central hub that broadcasts events to subscribers. This pattern allows publishers and subscribers to communicate without direct awareness of each other, meaning that components can be added or removed without affecting communication.

References


Security

read
  • GraphQL

Best Practices

read
  • GraphQL

Reference Architecture Design

AWS EC2 - Auto Scaling Reference

Infra Setup

image

  1. Create VPC

  2. Create Internet Gateway (IG) to enable the VPC resources accessible via internet (option available under VPC) 2.1 Attach the newly created internet gateway (IG) to the VPC (option available under Actions menu)

  3. Create Public Subnet - atleast 2 subnets in each availability zone to ensure maximum availability of the services (under the desired VPC) 3.1 Configure 2 different IP ranges in IPv$ subnet CIDR block to differentiate (ex: subnet1: 10.0.1.0/24, subnet2: 10.0.2.0/24)

  4. Create Route Table (under VPC) - to direct network traffic based on the destination IP address, route table is also responsible for providing internet access 4.1 Subnet Association - associate the desired subnets with the route table created under the vpc 4.2 Provide routes - so that internet access is enabled for the subnet destination (ex: Destination: 0.0.0.0/0 - i.e any resources associated with the route table can be accessed via internet, all the public subnet resources will have access to internet, Target: Internet Gateway -> select the newly created internet gateway in step2)

  5. Create Target Group (under load balancing option) - it is a logical group for pointing to the ec2 instances, scaling of ec2 instances happen under this target group 5.1 Configure the http protocol and port 5.2 Select the desired VPC 5.3 Select the health check endpoint - the one from ec2 instance (webserver) 5.4 Note: Once the target group is created, you will not find any ec2 instances, because the load balancer must be created in order for displaying the ec2 instances under this target group, so go ahead and create the target group record. 5.5 once record is created, it will show Load Balancer: None Associated (initially)

  6. Create Load Balancer (under load balancing option) 6.1 Select Scheme: Internet-facing 6.2 Select the desired VPC 6.3 Select the subnets in Network Mapping (min 2 subnets needed) 6.4 Select Security Group (define the access from internet for http, https, configure inbound and outbound rules) 6.5 Configure "Listeners and routing" mapping - to point inbound traffic towards the target group

  7. Create AutoScaling Group (under Autoscaling) 7.1 Define the launch template - to launch the ec2 instance based on conditions 7.2 Define generic security group to define the inbound http:80 traffic and SSH:22 for login to ec2, example: image 7.3 associate this security group in the launch template to facilitate the ec2 launching 7.4 No need of subnet selection 7.5 Enable - auto assign public ip 7.6 Use script under user data - to install the default packages such as web server and create a dummy html page to serve as index page, which will also be helpful for health check. example: image 7.7 Once the launch template is configured, select that and click next 7.8 Configure the VPC 7.9 Select the Availability zones, subnets 7.10 Attach to the existing Load balancer which we created in prev step and target group 7.11 Turn on elastic load balancing health checks 7.12 Configure the Capacity: Desired: 2, Min:1, Max:3 7.13 Configure Scaling Policies (metric type: Average CPU Utilization)

Once the capacity configuration is updated, it will take a while to update the scaling configuration and create the ec2 instances accordingly. Further you can open the Ec2 instances page and see how many instances are running.

AWS Disaster Recovery (DR) Plan image
⚠️ **GitHub.com Fallback** ⚠️