-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedis-Architecture-Diagram.html
More file actions
174 lines (153 loc) Β· 4.91 KB
/
Redis-Architecture-Diagram.html
File metadata and controls
174 lines (153 loc) Β· 4.91 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!DOCTYPE html>
<html>
<head>
<title>Redis Sentinel Architecture</title>
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background: #f5f5f5;
}
.container {
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
h1 {
color: #333;
text-align: center;
margin-bottom: 30px;
}
.mermaid {
text-align: center;
}
.explanation {
margin-top: 30px;
background: #f8f9fa;
padding: 15px;
border-radius: 5px;
border-left: 4px solid #007bff;
}
</style>
</head>
<body>
<div class="container">
<h1>π Redis Sentinel Architecture</h1>
<div class="mermaid">
graph TB
subgraph "Spring Boot Application"
subgraph "Configuration Layer"
APP[ApplicationProperties]
CONFIG[RedisConfig]
YML[application.yml]
end
subgraph "Service Layer"
CTRL[UserController]
SVC[UserService]
REDIS_SVC[RedisService]
REPO[UserRepository]
end
subgraph "Redis Infrastructure"
subgraph "Connection Factories"
MCF[masterConnectionFactory<br/>ReadFrom.MASTER]
RCF[replicaConnectionFactory<br/>ReadFrom.REPLICA_PREFERRED]
end
subgraph "Redis Templates"
MT[masterRedisTemplate<br/>Writes + Transactions]
RT[replicaRedisTemplate<br/>Reads Only]
end
subgraph "Cache Managers"
MCM[masterCacheManager<br/>Write Operations]
RCM[replicaCacheManager<br/>Read Operations]
FCM[FallbackRedisCacheManager<br/>Primary Cache Manager]
end
end
end
subgraph "Redis Sentinel Cluster"
subgraph "Sentinel Nodes"
S1[Sentinel 1<br/>localhost:26379]
S2[Sentinel 2<br/>localhost:26380]
S3[Sentinel 3<br/>localhost:26381]
end
subgraph "Redis Nodes"
RM[Redis Master<br/>mymaster<br/>localhost:6379]
RR[Redis Replica<br/>localhost:6380]
end
end
%% Configuration relationships
YML --> APP
APP --> CONFIG
CONFIG --> MCF
CONFIG --> RCF
%% Template relationships
MCF --> MT
RCF --> RT
%% Cache manager relationships
MT --> MCM
RT --> RCM
MCM --> FCM
%% Service relationships
CTRL --> SVC
SVC --> REPO
SVC --> REDIS_SVC
REDIS_SVC --> MT
REDIS_SVC --> RT
%% Sentinel connections
MCF -.->|"Discovers & Connects"| S1
MCF -.->|"Discovers & Connects"| S2
MCF -.->|"Discovers & Connects"| S3
RCF -.->|"Discovers & Connects"| S1
RCF -.->|"Discovers & Connects"| S2
RCF -.->|"Discovers & Connects"| S3
%% Sentinel monitoring
S1 -.->|"Monitors"| RM
S1 -.->|"Monitors"| RR
S2 -.->|"Monitors"| RM
S2 -.->|"Monitors"| RR
S3 -.->|"Monitors"| RM
S3 -.->|"Monitors"| RR
%% Redis replication
RM -->|"Replicates to"| RR
%% Application connections
MT -.->|"Writes"| RM
RT -.->|"Reads (Preferred)"| RR
RT -.->|"Reads (Fallback)"| RM
%% Styling
classDef configClass fill:#e1f5fe
classDef serviceClass fill:#f3e5f5
classDef redisInfra fill:#fff3e0
classDef sentinelClass fill:#e8f5e8
classDef redisNode fill:#ffebee
class APP,CONFIG,YML configClass
class CTRL,SVC,REDIS_SVC,REPO serviceClass
class MCF,RCF,MT,RT,MCM,RCM,FCM redisInfra
class S1,S2,S3 sentinelClass
class RM,RR redisNode
</div>
<div class="explanation">
<h3>π― Key Features:</h3>
<ul>
<li><strong>Automatic Failover:</strong> When master fails, replica becomes master</li>
<li><strong>Read Scaling:</strong> Reads from replica, writes to master</li>
<li><strong>Zero Downtime:</strong> Lettuce client handles reconnection automatically</li>
<li><strong>High Availability:</strong> 3 sentinels ensure consensus</li>
<li><strong>Monitoring:</strong> Built-in health checks for all nodes</li>
</ul>
<h3>π Failover Process:</h3>
<p>Master Fails β Sentinels Vote β Promote Replica β App Reconnects β Zero Downtime</p>
</div>
</div>
<script>
mermaid.initialize({
startOnLoad: true,
theme: 'default',
flowchart: {
useMaxWidth: true,
htmlLabels: true
}
});
</script>
</body>
</html>