ode*_*dia 5 production redis spring-data-redis spring-session spring-cloud
我有一个跨越4种服务器类型的Spring Cloud微服务应用程序:一个安全网关,两个UI服务器和一个REST API服务器。其中的每一个都将在生产环境中的自己的VM上运行:REST服务器的4个服务器实例,彼此之间的2个实例。
该系统预计将为大约30,000个用户提供服务。
服务发现由Eureka提供。我有两个用于故障转移的Eureka服务器。
共享的HTTP会话由Spring Session和Spring Data Redis使用参与服务器上的@EnableRedisHttpSession注释提供。
我决定为Redis设置3个VM(在此URL:http://redis.io/topics/sentinel上的“示例2:三个框的基本设置” )。
每个虚拟机将运行Redis服务器和Redis标记进程(其中Redis服务器之一将为主服务器,两个实例为从属服务器)
这一切在开发机器和系统测试机器上都非常有效,它们大多数都在同一服务器上运行所有进程。
我现在正在尝试在具有多个VM的类似于生产的环境中运行性能测试。我想从已经在生产中使用类似Spring Cloud设置的开发人员那里获得一些反馈和建议:
这是我的主Redis服务器的配置。从站几乎是相同的,只是端口不同,表明它们是主站的从站:
daemonize no
port 6379
dbfilename "dump6379.rdb"
dir "/Users/odedia/Work/Redis/6379"
pidfile "/Users/odedia/Work/Redis/redis6379.pid"
#logfile "/Users/odedia/Work/Redis/redis6379.log"
tcp-backlog 511
timeout 0
tcp-keepalive 60
loglevel notice
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
slave-serve-stale-data yes
slave-read-only no
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events "gxE"
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
Run Code Online (Sandbox Code Playgroud)
这是Redis的哨兵配置:
port 5000
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 5000
sentinel config-epoch mymaster 59
Run Code Online (Sandbox Code Playgroud)
这是Eureka服务器的application.yml:
server:
port: 1111
eureka:
instance:
hostname: localhost
client:
serviceUrl:
defaultZone: https://${eureka.instance.hostname}:${server.port}/eureka/
registerWithEureka: false #Dont register yourself with yourself...
fetchRegistry: false
server:
waitTimeInMsWhenSyncEmpty: 0
spring:
application:
name: eureka
Run Code Online (Sandbox Code Playgroud)
这是网关服务器的application.yml,它负责基于Zuul的路由:
# Spring properties
spring:
application:
name: gateway-server # Service registers under this name
redis:
sentinel:
master: mymaster
nodes: 127.0.0.1:5000,127.0.0.1:5001,127.0.0.1:5002
server:
port: 8080
security:
sessions: ALWAYS
zuul:
retryable: true #Always retry before failing
routes:
ui1-server: /ui1/**
ui2-server: /ui2/**
api-resource-server: /rest/**
# Discovery Server Access
eureka:
client:
serviceUrl:
defaultZone: https://localhost:1111/eureka/
instance:
hostname: localhost
metadataMap:
instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
hystrix:
command:
default:
execution:
isolation:
strategy: THREAD
thread:
timeoutInMilliseconds: 40000 #Timeout after this time in milliseconds
ribbon:
ConnectTimeout: 5000 #try to connect to the endpoint for 5 seconds.
ReadTimeout: 50000 #try to get a response after successfull connection for 5 seconds
# Max number of retries on the same server (excluding the first try)
maxAutoRetries: 1
# Max number of next servers to retry (excluding the first server)
MaxAutoRetriesNextServer: 2
Run Code Online (Sandbox Code Playgroud)
我根据 Spring Data Redis 的生产经验写了一篇文章,有兴趣的人可以在这里查看。
| 归档时间: |
|
| 查看次数: |
1317 次 |
| 最近记录: |