From a5781f19af8f2013f4af2a30e1805573eccaeddb Mon Sep 17 00:00:00 2001
From: buildmaster
We also provide a starter that allows you to easily add Spring Cloud LoadBalancer in a Spring Boot app.
-In order to use it, just add org.springframework.cloud:spring-cloud-starter-loadbalancer to your Spring
-Cloud dependencies in your build file.
Apart from the basic ServiceInstanceListSupplier implementation that retrieves instances
+via DiscoveryClient each time it has to choose an instance, we provide a Caffeine-backed
+implementation.
+To make use of it, you need to have com.github.ben-manes.caffeine:caffeine in the classpath.
+The default setup includes expireAfterWrite set to 30 seconds and records set to soft references.
You can set your own TTL value (the time after write after which entries should be expired), expressed as Duration, by passing a String compliant with the Duration API
+as the value of spring.cloud.loadbalancer.cache.ttl property.
You can also override the default Caffeine Cache setup for the LoadBalancer by passing your own Caffeine Specification
+in the spring.cloud.loadbalancer.cache.caffeine.spec property.
WARN: Passing your own Caffeine specification will override any other LoadBalancerCache settings, including TTL.
You can also altogether disable loadBalancer caching by setting the value of spring.cloud.loadbalancer.cache.enabled
+to false.
-In order to make use of the more efficient cached version of ServiceInstanceListSupplier,
- spring-cloud-starter-loadbalancer will enable caching by default.
-Spring Boot Caching
-mechanism will be used under the hood. If you don’t want caching to be used, you can set
-the value of spring.cache.type to none.
+Although the basic, non-cached, implementation is useful for prototyping and testing, it’s much less efficient
+than the cached versions, so we recommend always using the cached version in production.
+ |
+
+
We also provide a starter that allows you to easily add Spring Cloud LoadBalancer in a Spring Boot app.
+In order to use it, just add org.springframework.cloud:spring-cloud-starter-loadbalancer to your Spring
+Cloud dependencies in your build file.
| + + | ++Spring Cloud LoadBalancer starter includes +Spring Boot Caching. |
spring.cloud.loadbalancer.ribbon.enabled
You can also use the @LoadBalancerClient annotation to pass your own load-balancer client configuration, passing the name of the load-balancer client and the configuration class, like so:
We also provide a starter that allows you to easily add Spring Cloud LoadBalancer in a Spring Boot app.
-In order to use it, just add org.springframework.cloud:spring-cloud-starter-loadbalancer to your Spring
-Cloud dependencies in your build file.
Apart from the basic ServiceInstanceListSupplier implementation that retrieves instances
+via DiscoveryClient each time it has to choose an instance, we provide a Caffeine-backed
+implementation.
+To make use of it, you need to have com.github.ben-manes.caffeine:caffeine in the classpath.
+The default setup includes expireAfterWrite set to 30 seconds and records set to soft references.
You can set your own TTL value (the time after write after which entries should be expired), expressed as Duration, by passing a String compliant with the Duration API
+as the value of spring.cloud.loadbalancer.cache.ttl property.
You can also override the default Caffeine Cache setup for the LoadBalancer by passing your own Caffeine Specification
+in the spring.cloud.loadbalancer.cache.caffeine.spec property.
WARN: Passing your own Caffeine specification will override any other LoadBalancerCache settings, including TTL.
You can also altogether disable loadBalancer caching by setting the value of spring.cloud.loadbalancer.cache.enabled
+to false.
-In order to make use of the more efficient cached version of ServiceInstanceListSupplier,
- spring-cloud-starter-loadbalancer will enable caching by default.
-Spring Boot Caching
-mechanism will be used under the hood. If you don’t want caching to be used, you can set
-the value of spring.cache.type to none.
+Although the basic, non-cached, implementation is useful for prototyping and testing, it’s much less efficient
+than the cached versions, so we recommend always using the cached version in production.
+ |
+
+
We also provide a starter that allows you to easily add Spring Cloud LoadBalancer in a Spring Boot app.
+In order to use it, just add org.springframework.cloud:spring-cloud-starter-loadbalancer to your Spring
+Cloud dependencies in your build file.
| + + | ++Spring Cloud LoadBalancer starter includes +Spring Boot Caching. |
spring.cloud.loadbalancer.ribbon.enabled
You can also use the @LoadBalancerClient annotation to pass your own load-balancer client configuration, passing the name of the load-balancer client and the configuration class, like so: