Distributed Systems

The Devprime platform offers technology to accelerate software developer productivity by facilitating the development of distributed systems, microservices, and cloud-native applications.

By developing a new project based on the technology and modern software architecture of the Devprime platform, which offers accelerators with production-ready code implementations and components with intelligent behaviors, projects will have access to powerful features including observability (logs, distributed trace, metrics), retry, circuit-break, resiliency, accelerating and simplifying the development of distributed systems.

Modern Architecture Using Intelligent Components

The Devprime Stack components that are part of the Devprime platform implement modern distributed systems strategies, such as the observability approach with logs, distributed tracing, and automatic metrics, which are compatible with Open Telemetry.

The logs are automatically generated and include information such as Request ID, Correlation ID, and Trace ID, allowing traceability between different replicas and facilitating indexing and searching for these IDs in the main tools on the market. This helps maintain control and visibility into operations across distributed, scalable environments.

The Stream, State, and Services Adapters provide Retry, Circuit Break, and Resiliency strategies where applicable, empowering software developers to build more robust and resilient systems.

Automatic strategy using Retry and Circuit Break

In the example below, the Stream Adapter initiates the Retry strategy due to an outage in the “RabbitMQ” service, and then opens a Circuit Break to protect the application processes due to a temporary infrastructure failure.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
[INF][App]["Powered by DevPrime"][Version]["7.0.58"][Company]["DEVPRIME"]
[INF][App]["Start"]["x"][Configuration]["Appsettings"][AppVersion]["1.0.0.0"]
[INF][App][Idempotency]["Disable"]
[INF][State][Type "MongoDB"][Alias "State1"]["Database"]["Enable"]
[INF][App][Tenancy]["Disable"]
[INF][App][Observability]["Enable"][Log "Enable"][Export "Disable"]
[Trace "Disable"][Metrics "Disable"]
[INF][Security]["Disable"]
[INF][Web]["https://localhost:5001"]["http://localhost:5000"]
[Host]["Production"][Parameters]["Appsettings"]
[INF][Stream][Type "RabbitMQ"][Alias "Stream1"]["Enable"]
[INF][Stream][Type "RabbitMQ"][Alias "Stream1"]["Retry"]["1-3"]
[INF][Stream][Type "RabbitMQ"][Alias "Stream1"]["Retry"]["2-3"]
[INF][Stream][Type "RabbitMQ"][Alias "Stream1"]["Retry"]["3-3"]
[ERR][Stream][Type "RabbitMQ"][Alias "Stream1"]["Circuit Break"]["On"]

Automatic resiliency strategy using fallback

In this resiliency strategy, a Fallback is implemented to handle failure situations in a service or component. When a failure occurs, Fallback kicks in, allowing the application to continue to function properly or provide an alternative to the user. This helps ensure application availability and responsiveness, even in adverse scenarios.

Initiating Resiliency After Receiving a POST with the Adapter in Circuit Breaker

By analyzing line 16, it is possible to observe the status “Not delivered” in the sending of the event, and then, in line 26, we see the information of the beginning of the resiliency, preserving the event in a local fallback.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[INF][Web]["HTTP"][Order][POST /v1/order]
[Origin "https://localhost:5001/swagger/index.html"]
[INF][Application][OrderService][Add]
[INF][Domain][Order][Add]
[INF][Domain][Order][ProcessEvent]["CreateOrder"]
[INF][Application][EventHandler]["CreateOrderEventHandler"]
[Event]["CreateOrder"]
[INF][State][Type "MongoDB"][Alias "State1"][Initialize]
[OrderRepository][Add]
[INF][State][Type "MongoDB"][Alias "State1"][Complete][OrderRepository]
[Add][Duration 74.932ms]
[INF][Domain][Order][ProcessEvent]["OrderCreated"]
[INF][Application][EventHandler]["OrderCreatedEventHandler"]
[Event]["OrderCreated"]
[INF][Stream][Type "RabbitMQ"][Alias "Stream1"][Out]
[Event]["OrderCreated"]["Not delivered"]["orderevents"]
["{\"Headers\":{},\"Id\":\"a7bf4882-097c-4930-93ac-fb5fd6c22e70\",
\"CorrelationId\":\"9dd39484-b22c-455a-85f1-526df6eeab99\",
\"TraceId\":\"9dd39484-b22c-455a-85f1-526df6eeab99\",
\"AppId\":\"ed896882-49af-40e6-975a-d9328403e3c3\",
\"AppName\":\"x\",\"TenantID\":\"\",\"TenantUserID\":\"\",
\"Version\":1,\"Name\":\"OrderCreated\",
\"CreationDate\":\"2023-09-02T18:15:01.7438003-03:00\",
\"Payload\":{\"ID\":\"4c66f0f8-6417-4ab1-a5ae-9ac786ddf5aa\",
\"CustomerName\":\"Ramon\",\"CustomerTaxID\":\"string\",\"Total\":0}}"]
[INF][Stream][Type "RabbitMQ"][Alias "Stream1"]["Resilience"]["Write"]

Shutting Down the Circuit Breaker on RabbitMQ Return, Retrieving the Event, and Sending it to the RabbitMQ Queue

By parsing line 1, the Circuit Breaker is changed to the “Off” state, allowing the resiliency process to retrieve the event and finally safely deliver to the RabbitMQ service.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[INF][Stream][Type "RabbitMQ"][Alias "Stream1"]["Circuit Break"]["Off"]
[INF][Stream][Type "RabbitMQ"][Alias "Stream1"]["Resilience"]["Read"]["1"]
[INF][Stream][Type "RabbitMQ"][Alias "Stream1"][Out][Event]["OrderCreated"]
["Delivered"]["orderevents"]
["{\"Id\":\"c5d42299-50f5-4edb-9758-1cabc68874fc\",
\"CorrelationId\":\"9dd39484-b22c-455a-85f1-526df6eeab99\",
\"TraceId\":\"9dd39484-b22c-455a-85f1-526df6eeab99\",
\"AppId\":\"ed896882-49af-40e6-975a-d9328403e3c3\",\"AppName\":\"x\",
\"TenantID\":\"\",\"TenantUserID\":\"\",\"Version\":1,
\"Name\":\"OrderCreated\",\"CreationDate\":\"2023-09-02T21:15:01.743Z\",
\"Payload\":{\"ID\":\"4c66f0f8-6417-4ab1-a5ae-9ac786ddf5aa\",
\"CustomerName\":\"Ramon\",\"CustomerTaxID\":\"string\",\"Total\":0}}"]

Idempotency

The Devprime platform offers an automatic idempotency approach that allows you to control duplicate commands in HTTP/gRPC requests and Stream services (Kafka, RabbitMQ).

Local Transaction

The Devprime platform offers an integrated feature to enable local transactions with databases and can be used in conjunction with SqlServer, MongoDB, MySQL, PostgreSQL, Oracle.

Distributed Transaction

Devprime Distributed Services is a product of the Devprime platform that allows you to orchestrate distributed transactions between microservices using the Saga Pattern approach and event-driven architecture practices.

Last modified January 10, 2024 (967dcac3)