http:
multipart:
max-file-size: 20MB
max-request-size: 20MB
application:
name: amad-gateway
ribbon:
ConnectTimeout: 20000000
ReadTimeout: 20000000
maxAutoRetries: 1
MaxAutoRetriesNextServer: 2
MaxTotalHttpConnections: 1600
MaxConnectionsPerHost: 800
eureka:
enabled: true
zuul:
hystrix:
command:
default:
execution:
isolation:
strategy: SEMAPHORE
semaphore:
maxConcurrentRequests: 100000
fallback:
isolation:
semaphore:
maxConcurrentRequests: 100000
semaphore:
maxSemaphores: 100000
Finchley.RELEASE
Finchley.SR3
and see if the problem persists?
multipart:
max-file-size: 20MB
max-request-size: 20MB
application:
name: amad-gateway
ribbon:
ConnectTimeout: 20000000
ReadTimeout: 20000000
maxAutoRetries: 1
MaxAutoRetriesNextServer: 2
MaxTotalHttpConnections: 1600
MaxConnectionsPerHost: 800
eureka:
enabled: true
zuul:
hystrix:
command:
default:
execution:
isolation:
strategy: SEMAPHORE
semaphore:
maxConcurrentRequests: 100000
fallback:
isolation:
semaphore:
maxConcurrentRequests: 100000
semaphore:
maxSemaphores: 100000
Finchley.RELEASE
100000
of concurrent requests with semaphore isolation
MaxConnectionsPerHost: 800
100000
parallel simulatenous requests on any hardware
100000
simultaneous requests, you need a RAM to the tune of 100000 * 1MB
=> 100GB
. This is just for holding thread stacks. If you add all the heap requirements, you are looking at a very large RAM space. Please note that I have not added the cost of context switch CPU needs to perform to schedule these threads on to the underlying cores
MaxConnectionsPerHost
?
800
?
@spencergibb Continuing from twitter
https://twitter.com/thekalinga/status/1102589484556869632
Is this how loadbalancing works in Spring Cloud Gateway
LoadBalancerClient
, we select the server based on serviceIdGreenwich.RELEASE
, when I make a call using @LoadBalanced
restTemplate
, may I know who actually makes the underlying http request once the serviceId
-> server
resolution is done
zuul 1
Greenwich.RELEASE
@LoadBalanced
restTemplate
, who does the actual underlying call? Ribbon with its own http client (or) someone else. If someone else, appreciate if you can share the class responsible for sending?@FeignClient
, with who does the actual underlying call? Ribbon with its own http client (or) someone else. If someone else, appreciate if you can share the class responsible for sending?zuul 1
, who does the actual underlying upstream calls? Ribbon with its own http client (or) someone else. If someone else, appreciate if you can share the class responsible for sending?restTemplate
delegates the whole request processing when using serviceId to LoadBalancerInterceptor
, which further delegates everything to Ribbon
, who finally makes the undlying call using its own htp client
RestTemplate
are integrated with Ribbon, Hystrix, Feign & Zuul
I need to train others :) Tho I know how to use the APIs at the developer level, its better for me to explain in depth till the framework level on how everything is wired. I am trying to gain that level of knowledge
I see that there is a org.springframework.cloud.netflix.ribbon.RibbonHttpRequest#executeInternal
, which does delegate to netflix client. Is this class not used during RestTemplate
flow
I have to follow the old school approach to understanding the flow by debugging then :)
Thanks a lot for your help!!
RestTemplate
case) is delegating the actual calls to Request
s for some reason which is where I am quite confused
I see that RibbonLoadBalancerClient implements LoadBalancerClient
& loadBalancer.execute(..)
does this T returnVal = request.apply(serviceInstance);
(delegates to LoadBalancerRequest
)
LoadBalancerInterceptor
. The ribbon execute is just to choose the server and record some metrics. The request is a parameter.
Sure.. I see that. The only aspect thats confusing is the handshakes restTemplate -> interceptor -> request -> ....???... -> actual call
Is this understanding correct?
http://my-service
as URL, org.springframework.cloud.client.loadbalancer.ServiceRequestWrapper
converts this virtual URL to real URL based on ServiceInstance
ClientHttpRequestExecution
makes the ultimate http call (which LoadBalancerRequest
wraps)RibbonLoadBalancerClient.execute
is run, the load balancer request create at org.springframework.cloud.client.loadbalancer.LoadBalancerRequestFactory.createRequest
invokes execution.execute
using the uri created using ribbonAfter this, I checked who implemented ClientHttpRequestExecution
. I see only one implementation in the classpath i.e org.springframework.http.client.InterceptingClientHttpRequest.InterceptingRequestExecution
But he is creating another ClientHttpRequest
. I could not follow why & for what. So the actual library that ultimately makes calls is a bit of a mystery
RouteToRequestUrl
filter in gateway?
From Documentation
The RouteToRequestUrlFilter
runs if there is a Route
object in the ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR
exchange attribute. It creates a new URI, based off of the request URI, but updated with the URI attribute of the Route
object. The new URI is placed in the ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR
exchange attribute.
If the URI has a scheme prefix, such as lb:ws://serviceid
, the lb
scheme is stripped from the URI and placed in the ServerWebExchangeUtils.GATEWAY_SCHEME_PREFIX_ATTR
for use later in the filter chain.
Is it mainly for supporting loadbalancing across non-http protocols?
ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR
directly, Appreciate if you can give a usecase for storing the URI under a seperate variable again
exchange.setAttribute(SHARED_KEY, exchange.getRequest().getURI())