Search code examples
spring-cloud-loadbalancer

Is it not recommended to use Spring Cloud LoadBalancer's default cache on production?


Spring Boot version 2.5.2 spring-cloud version 2020.0.3

WARNING at the time of application startup --

2021-07-10 12:30:58.286  WARN 21316 --- [           main] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.

Why this log line is printed as Warning? Is it bad to use Spring Cloud LoadBalancer's default cache?


Solution

  • The answer is provided in this GitHub issue spring-cloud 1050

    More specifically this explanation can help you understand if it's bad to use the default cache or not, based on your project:

    I would say Caffeine has definitely been much more used and tested in production, while the default solution, which at this point is Evictor, is a solution based on a ConcurrentMap implemented as a hash-map with added TTL support. I would recommend using Caffeine in a production application. However, if you would like to stick to the default solution, you would need to consider if based on the predicted cache entry volume and the TTL settings that you would be applying, a concurrent HashMap would be enough.