Quantum Software Architecture Design Course

Written by: Igor Korotach

Section 4

Advanced Architectural Styles & Patterns

Small recap

General approaches

Centralized vs Decentralized architecture

Layers vs Tier

Client - Server vs P2P

Monolith Architecture

Pros

  • Simplicity
  • Ease of deployment
  • Ease of testing
  • Better single node performance

Cons

  • Resource-full scaling
  • Tight coupling
  • Limited to a single technology

Pros & Cons of Monolith Architecture

Service-oriented Architecture (SOA)

When to assess using microservices?

  • Your customer has quite a big budget
  • You have non-functional requirements related to throughput 
  • You can't afford vertical scaling at same time as horizontal scaling
  • You have a team of diverse specialists (i.e. different tech stacks)
  • You have a special case of business requirements 
  • You have solid internal processes

Pros

  • Improved scalability
  • Flexibility of deployment
  • Ease of testing

Cons

  • More complexity
  • Network overhead
  • Harder debugging & observability

Pros & Cons of SOA

Broker pattern & Load Balancer

Broker pattern (Message Broker)

Pros

  • Improved decoupling
  • Potential improvements to performance
  • Enhanced reliability if done correctly

Cons

  • Increased complexity
  • Reliance on the broker
  • Worse debugging & troubleshooting

Pros & Cons of Broker Pattern

Load Balancer

Difference between Load Balancer & Broker Pattern

  • Load Balancer operates on a network level, while broker pattern operates on the service level
  • Main purpose of Load Balancer is enhancing the throughput, Broker Pattern is oriented towards decoupling business logic
  • Load Balancers are usually stateless, while Brokers can handle context and meta information
  • A good example of Load Balancer is Nginx, a good example of a Broker Pattern is Apache Kafka, Erlang actor model
  • Broker Pattern is used to build more complex architecture styles such as Publish Subscribe (Pub/Sub) or Event-Driven Architecture

Pipe & Filter Pattern

Pipe & Filter Use Cases

  • Text processing

  • Image processing

  • Streaming data

  • Data analytics

  • Scientific computing

  • Log processing

  • Content Management platforms

Since Pipe & Filter is mostly used in stream processing, below is the list of recommended tools to be used when implementing the pattern

  • Apache Airflow for DAG (Directed Acyclic Graph) construction, manipulation & observability. Best used as a soft real-time tool
  • Apache Flink for streamed real-time data processing
  • Apache Spark for more batch-oriented highly parallelizable systems with focus on building filters
  • Kafka Streaming if you already employ Kafka ecosystem

Pros

  • Modularity
  • Composability
  • Scalability

Cons

  • Increased complexity
  • Network & data copying overhead
  • Lack of adaptibility

Pros & Cons of Pipe & Filter

Event-Driven Architecture (EDA)

EDA Use Cases

  • Chat applications

  • Real-time Financial data processing

  • User Activity Tracking

  • Webhooks 

  • Gaming

  • Fraud detection

Event-Driven Architecture can be tricky to get right, I recommend decomposing it into the following pieces:

  • Event Source - usually a result of parsing/scraping data periodically or a stream of events from client app
  • Event Bus - usually a message broker capable of serving & storing large streams of events. Kafka/RabbitMQ/Cloud Native queues are good solutions
  • Event Sink - a destination of the event, processing unit which transforms event into a business fact. Usually an asynchronous worker attached to a message queue

Pros

  • Loose coupling
  • Scalability
  • Asynchrony

Cons

  • Increased complexity
  • Increased latency
  • Ordering problems

Pros & Cons of EDA

Event sourcing & CQRS

Let's start with event sourcing!

State-based storing

Event-based storing

Event sourcing database

CQRS (Command-Query Reponsibility Segregation)

Event sourcing & CQRS

Event Sourcing & CQRS can be very difficult to implement, I recommend the following tools to help you with that:

  • Event Store which a purposely built database for event sourcing
  • Apache Kafka with permanent log retention (beware Kafka is first and foremost a message queue not a database)
  • Specialized frameworks such as Axon Framework or Akka (Pekko) Persistence

Pros

  • Excellent observability & bookkeeping
  • Segregation of concern
  • Simpler queries

Cons

  • Very high complexity
  • Difficult debugging
  • Eventual consistency of the database
  • Command Tables are very hard to modify

Pros & Cons of Event Sourcing & CQRS

Hexagonal Architecture

Pros

  • Promotes testing
  • Improved Modularity
  • Improved Extensibility

Cons

  • Increased complexity
  • Requires understanding of moving parts in advance
  • Can be challenging to scale horizontally 

Pros & Cons of Hexagonal Architecture

Serverless Architecture

Use Cases for Serverless Architecture

  • Your customer is a small-medium sized business with limited budget
  • You have received a sizable amount of Cloud credits for your provider to build PoC/MVP
  • You have a predictable workload at all times
  • You don't plan to have huge traffic spikes
  • You have a limited development team

Pros

  • Good scalability
  • Low configuration costs
  • Easy to setup 
  • Improved reliability
  • Improved security

Cons

  • Limited control
  • Cold-start issues
  • Dependency on the cloud provider

Pros & Cons of Serverless Architecture

Next time: Scalability, Availability, Load Balancing, Caching, Security Strategies

Thanks for your attention. You've been awesome!

Questions?

  • Presentation link: https://slides.com/emulebest/architecture-4

Quantum Architecture Course - 4

By Igor Korotach

Quantum Architecture Course - 4

  • 110