Decoupling Architecture
Decoupling Your Architecture
Section titled “Decoupling Your Architecture”What is Decoupling?
Section titled “What is Decoupling?”Decoupling refers to the separation of components in a system so that they can operate independently. This approach addresses the challenges of tight integration by creating more resilient and scalable architectures.
Tight Coupling Problems
Section titled “Tight Coupling Problems”Three-Tier Architecture Challenges
Section titled “Three-Tier Architecture Challenges”- Synchronous Communication: All communication requires “send and wait for reply” patterns
- Direct Dependencies: Web servers communicate directly with application servers
- Scaling Complexity: Adding new servers requires code updates to handle new IP addresses
- Single Points of Failure: Application server failure means entire system failure
- If application server fails, whole system goes down
- System maintenance requires bringing entire system offline
- Each new server requires multiple connections that must be updated in code
Infrastructure Level Tight Coupling
Section titled “Infrastructure Level Tight Coupling”When scaling a tightly coupled system, complexity increases dramatically. Adding components requires establishing multiple new connections across layers:
- Adding one web server requires three new connections (Route 53 + two application servers)
- Adding one application server requires three new connections (from each web server)
- Manual handling of application outages affects all connected components
Application Level Tight Coupling
Section titled “Application Level Tight Coupling”Monolithic Applications create tight coupling when business functions are implemented and deployed as a single unit:
- Single function problems can slow down or stop the entire application
- Changes to one function require entire application maintenance
- Example: Finance, transcoding, and calculation functions all running in same process
- Transcoding slowdown degrades entire application performance
- Can make whole application unresponsive
Loose Coupling Solutions
Section titled “Loose Coupling Solutions”Infrastructure Level Solutions
Section titled “Infrastructure Level Solutions”Elastic Load Balancing (ELB) as intermediary component:
- ALB load balancer in front of web servers distributes traffic from Route 53
- Second ALB between web and application servers handles workload management
- Benefits:
- Automatic health monitoring sends traffic only to healthy instances
- Automatic failover routing
- Adding new web server requires only two connections (to each ALB)
Application Level Solutions
Section titled “Application Level Solutions”Microservice Architecture divides application functions into independently scalable parts:
- Each microservice runs in its own process and maintains its own data
- Functions exposed through well-defined APIs
- Benefits:
- Components can scale and fail independently
- Changes to one component don’t affect others
- Reusable, scalable, and reliable components
- Can use synchronous or asynchronous communication
Example: Finance microservice scaled to three containers while calculations runs in one, based on different request volumes.
Asynchronous Messaging
Section titled “Asynchronous Messaging”Request Offloading Pattern
Section titled “Request Offloading Pattern”Use producer-consumer model for interactions that don’t need immediate responses:
- Producer: Component that generates events
- Consumer: Component that processes events
- Intermediate Storage: Queue or topic handles message passing
Amazon SQS Implementation
Section titled “Amazon SQS Implementation”Transform synchronous transcoding to asynchronous:
- Microservice becomes message producer, stores image in S3
- Places message in SQS queue for consumer processing
- Immediately responds to user for new request acceptance
- Consumer application polls queue and processes images independently
- Uses Amazon SNS topic to notify user when transcoding completes
Amazon MQ for Hybrid Environments
Section titled “Amazon MQ for Hybrid Environments”Enables loose coupling between on-premises and cloud applications:
- On-premises applications send messages through Amazon MQ broker
- Broker stores messages using Amazon EFS or EBS
- Provides message-based interface for cloud consumer applications
- Supports flexible and consistent integration patterns
Categories of Loose Coupling Solutions
Section titled “Categories of Loose Coupling Solutions”Synchronous Solutions
Section titled “Synchronous Solutions”- Infrastructure Level: ELB load balancers
- Application Level: Microservice architecture
Asynchronous Solutions
Section titled “Asynchronous Solutions”- Queue Based: Amazon SQS for point-to-point messaging
- Topic Based: Amazon SNS for publish-subscribe patterns, Amazon MQ for both models
Loose coupling isolates component behavior from dependencies, increasing resiliency and agility while preventing failure propagation between components.
Architecture Pattern