-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
103 changed files
with
13,769 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2017, joyieldInc | ||
Copyright (c) 2017, Joyield, Inc. <[email protected]> | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
.PHONY : default debug clean | ||
|
||
make = make | ||
plt = $(shell uname) | ||
ifeq ($(plt), FreeBSD) | ||
make = gmake | ||
else ifeq ($(plt), OpenBSD) | ||
make = gmake | ||
endif | ||
|
||
default: | ||
@$(make) -C src -f Makefile | ||
|
||
debug: | ||
@$(make) -C src -f Makefile debug | ||
|
||
clean: | ||
@$(make) -C src -f Makefile clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Predixy | ||
|
||
**Predixy** is a high performance and full features proxy for [redis](http://redis.io/) | ||
|
||
## Features | ||
|
||
+ High performance and lightweight. | ||
+ Multi-threads support. | ||
+ Works on Linux, OSX, BSD, Windows([Cygwin](http://www.cygwin.com/)). | ||
+ Supports Redis Sentinel, single/multi redis group[s]. | ||
+ Supports Redis Cluster. | ||
+ Supports redis block command, eg:blpop, brpop, brpoplpush. | ||
+ Supports scan command, even multi redis instances. | ||
+ Multi-databases support, means redis command select is avaliable. | ||
+ Supports redis transaction, limit in Redis Sentinel single redis group. | ||
+ Supports redis Scripts, script load, eval, evalsha. | ||
+ Supports redis Pub/Sub. | ||
+ Multi-DataCenters support. | ||
+ Extend AUTH, readonly/readwrite/admin permission, keyspace limit. | ||
+ Log level sample, async log record. | ||
+ Log file auto rotate by time and/or file size. | ||
+ Stats info, CPU/Memory/Requests/Responses and so on. | ||
+ Latency monitor. | ||
|
||
## Build | ||
|
||
Predixy can be compiled and used on Linux, OSX, BSD, Windows([Cygwin](http://www.cygwin.com/)). | ||
|
||
It is as simple as: | ||
|
||
$ make | ||
|
||
To build in debug mode: | ||
|
||
$ make debug | ||
|
||
Some other build options: | ||
+ CXX=c++compiler, default is g++, you can specify other, eg:CXX=clang++ | ||
+ EV=epoll|poll|kqueue, default it is auto detect according by platform. | ||
+ MT=false, disable multi-threads support. | ||
+ TS=true, enable predixy function call time stats, debug only for developer. | ||
|
||
For examples: | ||
|
||
$ make CXX=clang++ | ||
$ make EV=poll | ||
$ make MT=false | ||
$ make debug MT=false TS=true | ||
|
||
## Configuration | ||
|
||
See below files: | ||
+ predixy.conf, basic config. | ||
+ cluster.conf, Redis Cluster backend config. | ||
+ sentinel.conf, Redis Sentinel backend config. | ||
+ auth.conf, authority control config. | ||
+ dc.conf, multi-datacenters config. | ||
+ latency.conf, latency monitor config. | ||
|
||
## Running | ||
|
||
$ ./predixy ../conf/predixy.conf | ||
|
||
With default predixy.conf, Predixy will proxy to Redis Cluster 127.0.0.1:6379, | ||
In general, 127.0.0.1:6379 is not running in Redis Cluster mode, | ||
So you will look mass log output. But you can still test it with redis-cli. | ||
|
||
$ redis-cli -p 7617 info | ||
|
||
More command line arguments: | ||
|
||
$ ./predixy -h | ||
|
||
## Stats | ||
|
||
Like redis, predixy use INFO command to give stats. | ||
|
||
Show predixy running info and latency monitors | ||
|
||
redis> INFO | ||
|
||
Show latency monitors by latency name | ||
|
||
redis> INFO Latency <latency-name> | ||
|
||
A latency monitor example: | ||
|
||
LatencyMonitorName:all | ||
latency(us) sum(us) counts | ||
<= 100 3769836 91339 91.34% | ||
<= 200 777185 5900 97.24% | ||
<= 300 287565 1181 98.42% | ||
<= 400 185891 537 98.96% | ||
<= 500 132773 299 99.26% | ||
<= 600 85050 156 99.41% | ||
<= 700 85455 133 99.54% | ||
<= 800 40088 54 99.60% | ||
<= 1000 67788 77 99.68% | ||
> 1000 601012 325 100.00% | ||
T 60 6032643 100001 | ||
The last line is total summary, 624 is average latency(us) | ||
|
||
|
||
Show latency monitors by server address and latency name | ||
|
||
redis> INFO ServerLatency <server-address> [latency-name] | ||
|
||
Reset all stats and latency monitors | ||
|
||
redis> INFO ResetStats | ||
|
||
## License | ||
|
||
Copyright (C) 2017 Joyield, Inc. <joyield.com<at>gmail.com> | ||
|
||
All rights reserved. | ||
|
||
License under BSD 3-clause "New" or "Revised" License |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
## Authority control | ||
## Authority { | ||
## Auth [password] { | ||
## Mode read|write|admin | ||
## [KeyPrefix Prefix1 Prefix2...] | ||
## [ReadKeyPrefix Prefix1 Prefix2...] | ||
## [WriteKeyPrefix Prefix1 Prefix2...] | ||
## }... | ||
## } | ||
|
||
## Example: | ||
# Authority { | ||
##------------------------------------------------------------------------ | ||
# Auth { | ||
# Mode read | ||
# } | ||
#### password is empty, this Auth is default auth | ||
#### Mode read, client connection is readonly, | ||
#### No KeyPrefix or ReadKeyPrefix defined, all key can be visit | ||
##------------------------------------------------------------------------ | ||
# Auth abc { | ||
# Mode write | ||
# } | ||
#### password is "abc", the client must send command Auth abc | ||
#### Mode write, client connection can read and write | ||
#### No KeyPrefix, ReadKeyPrefix, WriteKeyPrefix define, all key can be visit | ||
##------------------------------------------------------------------------ | ||
# Auth bcd { | ||
# Mode admin | ||
# } | ||
#### password is "abc", the client must send command Auth bcd | ||
#### Mode admin, client connection can read and write and admin, | ||
#### the CONFIG command need admin permission | ||
#### No KeyPrefix, ReadKeyPrefix, WriteKeyPrefix define, all key can be visit | ||
##------------------------------------------------------------------------ | ||
# Auth cde { | ||
# Mode read | ||
# KeyPrefix User | ||
# } | ||
#### password is "cde", the client must send command Auth cde | ||
#### Mode read, client connection is readonly, | ||
#### KeyPrefix User, client can read UserXXX key, eg: GET User.123, | ||
#### if client request GET hello, will be deny | ||
##------------------------------------------------------------------------ | ||
# Auth def { | ||
# Mode write | ||
# ReadKeyPrefix User Stats | ||
# WriteKeyPrefix User | ||
# } | ||
#### password is "cde", the client must send command Auth cde | ||
#### Mode read, client connection can read and write, but read and write | ||
#### keyspace is diffrent, client can GET User.123 and also | ||
#### SET User.123 SomeValue, but SET Stats.123 will be deny | ||
##------------------------------------------------------------------------ | ||
# } | ||
## if no Authority spcified, equality below Authority | ||
# Authority { | ||
# Auth { | ||
# Mode admin | ||
# } | ||
# } | ||
|
||
Authority { | ||
Auth { | ||
Mode write | ||
} | ||
Auth "#a complex password#" { | ||
Mode admin | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## redis cluster server pool define | ||
|
||
##ClusterServerPool { | ||
## [Password xxx] #default no | ||
## [MasterReadPriority [0-100]] #default 50 | ||
## [StaticSlaveReadPriority [0-100]] #default 0 | ||
## [DynamicSlaveReadPriority [0-100]] #default 0 | ||
## [RefreshInterval seconds] #default 1 | ||
## [ServerFailureLimit number] #default 10 | ||
## [ServerRetryTimeout seconds] #default 1 | ||
## Servers { | ||
## + addr | ||
## ... | ||
## } | ||
##} | ||
|
||
|
||
## Examples: | ||
#ClusterServerPool { | ||
# MasterReadPriority 60 | ||
# StaticSlaveReadPriority 50 | ||
# DynamicSlaveReadPriority 50 | ||
# RefreshInterval 1 | ||
# ServerFailureLimit 10 | ||
# ServerRetryTimeout 1 | ||
# Servers { | ||
# + 192.168.2.107:2211 | ||
# + 192.168.2.107:2212 | ||
# } | ||
#} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
## DataCenter | ||
## DataCenter { | ||
## DC name { | ||
## AddrPrefix { | ||
## + IpPrefix | ||
## ... | ||
## } | ||
## ReadPolicy { | ||
## name priority [weight] | ||
## other priority [weight] | ||
## } | ||
## } | ||
## ... | ||
## } | ||
## Examples: | ||
#DataCenter { | ||
# DC bj { | ||
# AddrPrefix { | ||
# + 10.1 | ||
# } | ||
# ReadPolicy { | ||
# bj 50 | ||
# sh 20 | ||
# sz 10 | ||
# } | ||
# } | ||
# DC sh { | ||
# AddrPrefix { | ||
# + 10.2 | ||
# } | ||
# ReadPolicy { | ||
# sh 50 | ||
# bj 20 5 | ||
# sz 20 2 | ||
# } | ||
# } | ||
# DC sz { | ||
# AddrPrefix { | ||
# + 10.3 | ||
# } | ||
# ReadPolicy { | ||
# sz 50 | ||
# sh 20 | ||
# bj 10 | ||
# } | ||
# } | ||
#} |
Oops, something went wrong.