我有一个Spring Cloud微服务应用程序,涵盖4种服务器类型:安全网关,两个UI服务器和一个REST API服务器。其中每个都将在生产环境中的自己的VM上运行:REST服务器的4个服务器实例和每个其他服务器的2个实例。
预计该系统将为大约30,000名用户提供服务。
服务发现由Eureka提供。我有两台Eureka服务器用于故障转移。
共享HTTP会话由Spring Session& Spring Data Redis,在参与的服务器上使用@EnableRedisHttpSession注释。
我决定使用Redis的3个虚拟机设置(“示例2:三个框的基本设置”在此URL:http://redis.io/topics/sentinel)。
每个VM都将运行Redis服务器和Redis sentinel进程(其中一个Redis服务器将成为主服务器,两个实例将成为从服务器)
这一切都适用于开发机器和系统测试机器,主要是在同一台服务器上运行所有进程。
我现在正朝着具有多个虚拟机的类似生产的环境运行性能测试。我想要一些已经在生产中具有类似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
以下是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
这是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
这是网关服务器的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
答案 0 :(得分:1)
我根据自己在Spring Data Redis的制作经验撰写了一篇文章,可以在这里找到感兴趣的人。