Overall design architecture diagram
1. Nginx load balancing
http { upstream tomcats { server localhost:19997; server localhost:19998; server localhost:19999; } server { listen 80; location / { proxy_pass http://shopservice.api; }}}Copy the code
2. Product service configuration requests shall not exceed three times within 60 seconds
<dependency> <groupId>com.marcosbarbero.cloud</groupId> <artifactId>spring-cloud-zuul-ratelimit</artifactId> < version > 1.3.4. RELEASE < / version > < / dependency > zuul. Ratelimit. Enabled = true zuul. Routes. The API - Anderson, d = API - a zuul.routes.api-a.path=/api/a/** zuul.routes.api-a.service-id=productservice zuul.ratelimit.api-a.limit=3 zuul.ratelimit.api-a.refresh-interval=60 zuul.ratelimit.api-a.type=originCopy the code
Current limiting parameters:
3. Zuul gateway times out and retry
< the dependency > < groupId > org. Springframework. Retry < / groupId > < artifactId > spring - retry < / artifactId > < version > 1.3.1 < / version > </dependency> # open zuul gateway retry. Retryable =true The default timeout mand 1000 ms hystrix.com. Default. Execution. The isolation. Thread. TimeoutInMilliseconds = 8000 # ribbon timeout Settings: ConnectTimeout= 5000ms ribbon.ConnectTimeout= 5000ms ribbon. Default 5000ms ribbon.ReadTimeout= 5000ms ribbon.ReadTimeout=5000 MaxAutoRetriesNextServer said access service cluster (in server) ribbon. The rest of the node under MaxAutoRetries = 1 ribbon. Open retry MaxAutoRetriesNextServer = 1 # ribbon.OkToRetryOnAllOperations=trueCopy the code