Friday, April 9, 2021

Developing Applications with the Microservices Architecture by Chris Richardson (Complete)

 April 9, 2021

Here is the link. 

Background: The Microservices pattern, which structures an application as a set of small, narrowly focused, independently deployable services, is becoming an increasingly popular way to build cloud-native applications. This approach avoids many of the problems of a monolithic architecture. It simplifies deployment and let’s you create highly scalable and available applications.

About this Talk: In this talk Chris Richardson describes the microservice architecture and how to use it to build complex applications. He explains how techniques such as Command Query Responsibility Segregation (CQRS) and Event Sourcing address the key challenges of developing applications with this architecture. We will also cover some of the various frameworks such as NodeJS and Spring Boot that you can use to implement microservices.

1:04:14/ 1:33/55

Use event-driven architecture

  • How
    • Services publish events when data changes
    • Subscribing services update their data
  • Benefits
    • Simpler
    • Better availability
  • Drawbacks
    • Application has to handle eventually consistent data
    • Application has to handle duplicate events
How do services publish events?
To maintain consistency the application must atomically publish an event whenever a domain object chagnes

1:06:21/ 1:33:55
How to generate events?
  • Database triggers
  • Hibernate event listener
  • Ad hoc event publishing code mixed into businesses logic
  • Domain events - "formal" modeling of events
  • Event sourcing
1:08:03/ 1:33:55
Automatically publishing events

Now it is 12:19 AM. Better go to sleep and get up early and study.


Thursday, April 8, 2021

System design: Azure / Architecture / Cloud Design Patterns

 April 8, 2021

Here is the link. 

I plan to spend at least three hours to study cloud design patterns, and then write down what I learn most through this article.


These design patterns are useful for building reliable, scalable, secure applications in the cloud.

Each pattern describes the problem that the pattern addresses, considerations for applying the pattern, and an example based on Microsoft Azure. Most of the patterns include code samples or snippets that show how to implement the pattern on Azure. However, most of the patterns are relevant to any distributed system, whether hosted on Azure or on other cloud platforms.

Challenges in cloud development

CHALLENGES IN CLOUD DEVELOPMENT
Data management

Data Management

Data management is the key element of cloud applications, and influences most of the quality attributes. Data is typically hosted in different locations and across multiple servers for reasons such as performance, scalability or availability, and this can present a range of challenges. For example, data consistency must be maintained, and data will typically need to be synchronized across different locations.

Design and implementation

Design and Implementation

Good design encompasses factors such as consistency and coherence in component design and deployment, maintainability to simplify administration and development, and reusability to allow components and subsystems to be used in other applications and in other scenarios. Decisions made during the design and implementation phase have a huge impact on the quality and the total cost of ownership of cloud hosted applications and services.

Messaging icon

Messaging

The distributed nature of cloud applications requires a messaging infrastructure that connects the components and services, ideally in a loosely coupled manner in order to maximize scalability. Asynchronous messaging is widely used, and provides many benefits, but also brings challenges such as the ordering of messages, poison message management, idempotency, and more.

Catalog of patterns

CATALOG OF PATTERNS
PatternSummaryCategory
AmbassadorCreate helper services that send network requests on behalf of a consumer service or application.Design and Implementation,
Operational Excellence
Anti-Corruption LayerImplement a façade or adapter layer between a modern application and a legacy system.Design and Implementation,
Operational Excellence
Asynchronous Request-ReplyDecouple backend processing from a frontend host, where backend processing needs to be asynchronous, but the frontend still needs a clear response.Messaging
Backends for FrontendsCreate separate backend services to be consumed by specific frontend applications or interfaces.Design and Implementation
BulkheadIsolate elements of an application into pools so that if one fails, the others will continue to function.Reliability
Cache-AsideLoad data on demand into a cache from a data storeData Management,
Performance Efficiency
ChoreographyLet each service decide when and how a business operation is processed, instead of depending on a central orchestrator.Messaging,
Performance Efficiency
Circuit BreakerHandle faults that might take a variable amount of time to fix when connecting to a remote service or resource.Reliability
Claim CheckSplit a large message into a claim check and a payload to avoid overwhelming a message bus.Messaging
Compensating TransactionUndo the work performed by a series of steps, which together define an eventually consistent operation.Reliability
Competing ConsumersEnable multiple concurrent consumers to process messages received on the same messaging channel.Messaging
Compute Resource ConsolidationConsolidate multiple tasks or operations into a single computational unitDesign and Implementation
CQRSSegregate operations that read data from operations that update data by using separate interfaces.Data Management,
Design and Implementation,
Performance Efficiency
Deployment StampsDeploy multiple independent copies of application components, including data stores.Reliability,
Performance Efficiency
Event SourcingUse an append-only store to record the full series of events that describe actions taken on data in a domain.Data Management,
Performance Efficiency
External Configuration StoreMove configuration information out of the application deployment package to a centralized location.Design and Implementation,
Operational Excellence
Federated IdentityDelegate authentication to an external identity provider.Security
GatekeeperProtect applications and services by using a dedicated host instance that acts as a broker between clients and the application or service, validates and sanitizes requests, and passes requests and data between them.Security
Gateway AggregationUse a gateway to aggregate multiple individual requests into a single request.Design and Implementation,
Operational Excellence
Gateway OffloadingOffload shared or specialized service functionality to a gateway proxy.Design and Implementation,
Operational Excellence
Gateway RoutingRoute requests to multiple services using a single endpoint.Design and Implementation,
Operational Excellence
GeodesDeploy backend services into a set of geographical nodes, each of which can service any client request in any region.Reliability,
Operational Excellence
Health Endpoint MonitoringImplement functional checks in an application that external tools can access through exposed endpoints at regular intervals.Reliability,
Operational Excellence
Index TableCreate indexes over the fields in data stores that are frequently referenced by queries.Data Management,
Performance Efficiency
Leader ElectionCoordinate the actions performed by a collection of collaborating task instances in a distributed application by electing one instance as the leader that assumes responsibility for managing the other instances.Design and Implementation,
Reliability
Materialized ViewGenerate prepopulated views over the data in one or more data stores when the data isn't ideally formatted for required query operations.Data Management,
Operational Excellence
Pipes and FiltersBreak down a task that performs complex processing into a series of separate elements that can be reused.Design and Implementation,
Messaging
Priority QueuePrioritize requests sent to services so that requests with a higher priority are received and processed more quickly than those with a lower priority.Messaging,
Performance Efficiency
Publisher/SubscriberEnable an application to announce events to multiple interested consumers asynchronously, without coupling the senders to the receivers.Messaging
Queue-Based Load LevelingUse a queue that acts as a buffer between a task and a service that it invokes in order to smooth intermittent heavy loads.Reliability,
Messaging,
Resiliency,
Performance Efficiency
RetryEnable an application to handle anticipated, temporary failures when it tries to connect to a service or network resource by transparently retrying an operation that's previously failed.Reliability
Scheduler Agent SupervisorCoordinate a set of actions across a distributed set of services and other remote resources.Messaging,
Reliability
Sequential ConvoyProcess a set of related messages in a defined order, without blocking processing of other groups of messages.Messaging
ShardingDivide a data store into a set of horizontal partitions or shards.Data Management,
Performance Efficiency
SidecarDeploy components of an application into a separate process or container to provide isolation and encapsulation.Design and Implementation,
Operational Excellence
Static Content HostingDeploy static content to a cloud-based storage service that can deliver them directly to the client.Design and Implementation,
Data Management,
Performance Efficiency
Strangler FigIncrementally migrate a legacy system by gradually replacing specific pieces of functionality with new applications and services.Design and Implementation,
Operational Excellence
ThrottlingControl the consumption of resources used by an instance of an application, an individual tenant, or an entire service.Reliability,
Performance Efficiency
Valet KeyUse a token or key that provides clients with restricted direct access to a specific resource or service.Data Management,
Security

System Design Interview – Step By Step Guide

 April 8, 2021

Here is the link. 

Topics mentioned in the video: - Stages of a typical system design interview: functional requirements (API), non-functional requirements, high-level design, detailed design, bottlenecks and tradeoffs. - Why requirements clarification is so important. - What questions to ask the interviewer. - How to design API. - Non-functional requirements to consider: scalability, performance, availability, consistency, cost. - How to define a data model. - How to scale a SQL database. - Apache Cassandra high-level architecture. - Data processing concepts: checkpointing, partitioning, in-memory aggregation, deduplication cache, dead-letter queue, embedded database, state management. - Data ingestion pipeline concepts: blocking vs non-blocking I/O, buffering and batching, timeouts, retries, exponential backoff and jitter, circuit breaker pattern, software vs hardware load balancing, load balancing algorithms, DNS, health checking and high availability of load balancers, partition strategy, hot partitions, client-side and server-side service discovery, single leader replication and leaderless replication, textual vs binary data formats. - Data retrieval pipeline concepts: time-series data, data rollup, hot storage, cold storage. - Types of performance testing: load testing, stress testing, soak testing. - Health monitoring. - Audit systems.