Predixy
오픈소스로 Redis 센티넬 및 Redis 클러스터를 위한 고성능 및 모든 기능을 갖춘 프록시이다.
Install & Config
github : https://github.com/joyieldInc/predixy
Install
1. Package Install
# apt install -y build-essential
2. git clone
# git clone https://github.com/joyieldInc/predixy.git
3. Build
# cd predixy
# make
4. copy command
# cd src/predixy /usr/local/bin/
# predixy -h
Config
1. predixy config
# vim conf/predixy.conf
Bind 0.0.0.0:7617
WorkerThreads 4
MaxMemory 0
ClientTimeout 300
BufSize 4096
LogRotate 1d
LogVerbSample 0
LogDebugSample 0
LogInfoSample 10000
LogNoticeSample 1
LogWarnSample 1
LogErrorSample 1
Include cluster.conf
Include latency.conf
2. cluster config
# vim conf/cluster.conf
ClusterServerPool {
MasterReadPriority 60
StaticSlaveReadPriority 50
DynamicSlaveReadPriority 50
RefreshInterval 1
ServerTimeout 1
ServerFailureLimit 10
ServerRetryTimeout 1
KeepAlive 120
Servers {
+ 192.168.50.14:6379
+ 192.168.50.15:6379
+ 192.168.50.16:6379
+ 192.168.50.14:6380
+ 192.168.50.15:6380
+ 192.168.50.16:6380
+ 192.168.50.14:6381
+ 192.168.50.15:6381
+ 192.168.50.16:6381
}
}
3. run predixy
# predixy conf/predixy.conf
predixy conf/predixy.conf
2020-05-25 13:44:29.123965 N Proxy.cpp:112 predixy listen in 0.0.0.0:7617
2020-05-25 13:44:29.124092 N Proxy.cpp:143 predixy running with Name:PredixyExample Workers:4
2020-05-25 13:44:29.124417 N Handler.cpp:456 h 0 create connection pool for server 192.168.50.15:6380
2020-05-25 13:44:29.124436 N ConnectConnectionPool.cpp:42 h 0 create server connection 192.168.50.15:6380 8
2020-05-25 13:44:29.125279 N ClusterServerPool.cpp:174 redis cluster create new group 29c5855872ff38f9f2a4203094fc4928fec7744f 192.168.50.15:6379@16379 master -
2020-05-25 13:44:29.125298 N ClusterServerPool.cpp:174 redis cluster create new group b1e905ca7d3fb5f743930565994aef6eb48cfe95 192.168.50.16:6379@16379 master -
2020-05-25 13:44:29.125308 N ClusterServerPool.cpp:174 redis cluster create new group 186deee637ea73f136d671f674320b424c3dddf4 192.168.50.14:6379@16379 master -
~~~~~~~~~~~~~~~~~~~~~~~~
Test
1. Client Get Query
# redis-cli -p 7617 -h 192.168.50.13 get hello
"world"
predixy가 실행중인 서버에서 hello key의 world value를 리턴하였다.
만약 predixy가 없는 상황이라면 redis cluster에 직접 질의를 해야하고 보통의 구조에서는 하나의 Master에서 모든 요청을 처리하기때문에 부하가 발생할 수 있다.
2. Log
2020-05-25 13:46:37.252826 N Handler.cpp:456 h 3 create connection pool for server 192.168.50.14:6380
2020-05-25 13:46:37.252874 N ConnectConnectionPool.cpp:42 h 3 create server connection 192.168.50.14:6380 40
2020-05-25 13:46:38.012174 N Handler.cpp:373 h 1 accept c 192.168.50.10:35870 42 assign to h 0
2020-05-25 13:46:38.012860 N Handler.cpp:212 h 0 remove c 192.168.50.10:35870 42 with status 2 End
192.168.50.10에서 온 요청을 redis master 중 요청한 key를 가진 slot이 있는 master (192.168.50.14) 로 전달하였다.
3. redis latency check (predixy support)
# redis-cli -p 7617 -h 192.168.50.13 INFO Latency all
# LatencyMonitor
LatencyMonitorName:all
<= 100 36 3 100.00%
T 12 36 3
# ServerLatencyMonitor
ServerLatencyMonitorName:192.168.50.14:6379 all
ServerLatencyMonitorName:192.168.50.15:6379 all
ServerLatencyMonitorName:192.168.50.16:6379 all
ServerLatencyMonitorName:192.168.50.14:6380 all
ServerLatencyMonitorName:192.168.50.15:6380 all
ServerLatencyMonitorName:192.168.50.16:6380 all
ServerLatencyMonitorName:192.168.50.14:6381 all
ServerLatencyMonitorName:192.168.50.15:6381 all
ServerLatencyMonitorName:192.168.50.16:6381 all
predixy에서 지원하는 기능 중 하나로 각 Redis node에 대한 Latency를 확인할 수 있다.
Redis Cluster 생성은 아래 링크
https://lascrea.tistory.com/214
참조 URL
'Tech' 카테고리의 다른 글
Base64 Encoding (0) | 2020.10.25 |
---|---|
Redis Cluster (0) | 2020.05.25 |
Kafka (카프카) (0) | 2019.04.09 |