-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtrainus-architecture-async-processing.py
More file actions
49 lines (39 loc) · 1.46 KB
/
trainus-architecture-async-processing.py
File metadata and controls
49 lines (39 loc) · 1.46 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from diagrams import Cluster, Diagram, Edge
from diagrams.aws.compute import EC2
from diagrams.aws.network import ALB
from diagrams.onprem.database import PostgreSQL
from diagrams.onprem.inmemory import Redis
graph_attr = {
"fontsize": "18",
"pad": "0.6",
"splines": "polyline",
"nodesep": "1.0",
"ranksep": "1.3",
}
with Diagram(
"TrainUs Architecture - Async Processing",
show=False,
filename="trainus-architecture-async-processing",
outformat="png",
direction="LR",
graph_attr=graph_attr,
):
client = ALB("Client / ALB")
with Cluster("API Server"):
api = EC2("API Server\n(api profile)")
with Cluster("Redis Core"):
core = Redis("Redis Core\nstock / duplicate")
with Cluster("Consumer Server - Admission"):
admission = EC2("Consumer Server\n(admission dequeue)")
stream = Redis("Redis Stream\nlesson:apply:stream")
with Cluster("Consumer Server"):
consumer = EC2("Consumer Server\n(batch insert)")
with Cluster("Database"):
db = PostgreSQL("PostgreSQL / PostGIS")
client >> Edge(label="apply request") >> api
api >> Edge(label="duplicate / stock check") >> core
core >> Edge(label="dequeue requestIds") >> admission
admission >> Edge(label="SET PROCESSING + XADD") >> stream
stream >> Edge(label="XREADGROUP batch") >> consumer
consumer >> Edge(label="batch insert") >> db
consumer >> Edge(label="XACK / XDEL", dir="back") >> stream