I am using spring cloud gateway Hoxton.M1 release to implement API gateway. I can see logs in below format-
[2019-11-13 18:33:09,432] [448877242] [reactor-http-epoll-5] [DEBUG] [r.n.r.PooledConnectionProvider] - [id: 0xfc0b1eb2, L:/x.x.x.x:42538 - R:xxxx4076.x.x.com/x.x.x.x:5001] Channel connected, now 1 active connections and 0 inactive connections
[2019-11-13 18:33:09,679] [448877489] [reactor-http-epoll-5] [DEBUG] [r.n.r.PooledConnectionProvider] - [id: 0xfc0b1eb2, L:/x.x.x.x:42538 - R:xxxx4076.x.x.com/x.x.x.x:5001] onStateChange(POST{uri=/gateway/api/public/process, connection=PooledConnection{channel=[id: 0xfc0b1eb2, L:/x.x.x.x:42538 - R:xxxxx4076.x.x.com/x.x.x.x:5001]}}, [request_sent])
[2019-11-13 18:33:09,880] [448877690] [reactor-http-epoll-5] [DEBUG] [r.n.r.PooledConnectionProvider] - [id: 0xfc0b1eb2, L:/x.x.x.x:42538 - R:xxxx4076.x.x.com/x.x.x.x:5001] onStateChange(POST{uri=/gateway/api/public/process, connection=PooledConnection{channel=[id: 0xfc0b1eb2, L:/x.x.x.x:42538 - R:x.x.x.com/x.x.x.x:5001]}}, [response_received])
Also in the access logs I can see below -
x.x.x.x - - [13/Nov/2019:18:33:09 +0800] "POST /x/x/x HTTP/1.1" 200 14895 5556 455 ms
From this it seems -
- Downstream took ~ 200 ms
- Rest of time i.e. 455 - 200 ~ 255 ms was taken by spring cloud gateway
There are no global filters configured. Also the route is only using rewrite path and add request header filters. Below is the route. It also uses redis rate limiting feature.
- id: xxxx
uri: http://xxxxx.xxx.xxx.com:5001
predicates:
- Path=/x/x/x
- Method=POST
filters:
- RewritePath=/x/x/x,/gateway/api/public/process
- AddRequestHeader=xxxxx,yyyyy
- AddRequestHeader=appid,zzzzz
- SecureHeaders
- name: RequestRateLimiter
args:
key-resolver: "#{@userRemoteAddressResolver}"
redis-rate-limiter.replenishRate: 10
redis-rate-limiter.burstCapacity: 20
When downstream takes only 200 ms, 255 ms taken by spring cloud gateway looks a bit high.
I have given adequate heap memory to the gateway application and in gc analysis I do not see any memory issues.
Any suggestions on how to optimize the gateway performance?