What is the timeout and retry config in Spring Loadbalancer 、CircuitBreak (resilience4j)? - java

I`m migrating and upgrading the project, from Spring Cloud Netflix to New Spring Cloud(Spring loadbalancer CircuitBreak).
https://spring.io/blog/2018/12/12/spring-cloud-greenwich-rc1-available-now#spring-cloud-netflix-projects-entering-maintenance-mode
I have some configurations where I can't find the equivalent config in Spring loadbalancer And CircuitBreak. In my limited experience with Spring ,I searching for a long time on net. But no use. --Here is my questions:
old-ribbon-config migration to loadbalancer:
serverName.ribbon.MaxAutoRetries=0
serverName.ribbon.MaxAutoRetriesNextServer=2
serverName.ribbon.retryableStatusCodes=503
serverName.ribbon.NFLoadBalancerRuleClassName=com.netflix.loadbalancer.RoundRobinRule
serverName.ribbon.ReadTimeout=5000
serverName.ribbon.ConnectTimeout=5000
serverName2.ribbon.ReadTimeout=6000
serverName2.ribbon.ConnectTimeout=7000
The closest configuration as below:
But I need to configure it for each server-name particularly the 'MaxAutoRetriesNextServer' and enabled retry for per server-name.
spring.cloud.loadbalancer.retry.enabled=false
spring.cloud.loadbalancer.retry.max-retries-on-same-service-instance=0
spring.cloud.loadbalancer.retry.max-retries-on-next-service-instance=2
The other configuration is hystrix timeout, In resilience4j it needs to return a CompletedFuture type, which is not compatible with older code.
old-hystrix-config migration to resilience4j:
hystrix.command.FeignClientName#method(String).execution.isolation.thread.timeoutInMilliseconds=2000
resilience4j.timelimiter.instances.name.timeout-duration=6s
What would be the best way to do that? Thanks in advance!

Related

Spring boot Actuator vs prometheus Jmx exporter

For exporting the metrics (to Prometheus) from the spring boot micro service, we can use the spring boot actuator and one more option is to use the Prometheus JMX exporter(https://github.com/prometheus/jmx_exporter) as a javaAgent when running the service. Though both of the options serve the same purpose, I do see that the JMX exporter is exporting way lot more metrics than the spring boot actuator. I was scouting through some spring boot documentations to see if there is any option to enable more metrics with spring boot actuator, looks like all the JMX metrics are enabled by default. So the questions is, is there a way to expose more metrics from spring boot actuator? Is there any recommendation or comparison study available for both the options mentioned above?
Any help here is greatly appreciated. Thanks!
If you are using Spring boot 2.x, then it works like this:
In Spring Boot 2.0, the in-house metrics were replaced with Micrometer support, so we can expect breaking changes. If our application was using metric services such as GaugeService or CounterService, they will no longer be available.
Instead, we're expected to interact with Micrometer directly. In Spring Boot 2.0, we'll get a bean of type MeterRegistry autoconfigured for us.
for Spring boot 1.x:
The metrics endpoint publishes information about OS and JVM as well as application-level metrics. Once enabled, we get information such as memory, heap, processors, threads, classes loaded, classes unloaded, and thread pools along with some HTTP metrics as well.
and this seems to work like Prometheus JMX

Spring Webflux - Actuator - Netty thread metrics?

Small question regarding Netty metrics for a Spring Webflux + actuator project please.
In the Spring MVC world, combined with actuator, we have metrics such as:
tomcat_threads_busy_threads
tomcat_threads_current_threads
tomcat_threads_config_max_threads
jetty_threads_busy
jetty_threads_current
jetty_threads_config_max
Which helps a lot to get the overall status of the application.
However, in Webflux, it seems there is no equivalent.
I was expecting something like netty_threads_busy or something equivalent, but could not find anything related.
May I ask what would be the equivalent in Netty Webflux world please?
Thank you
The metrics expose by reactor-netty are not enabled by default in spring boot. There was a previous discussion on this github issue and the decision was not to enable these by default.
If you wanted to enable the netty server metrics in your own application, you can add the following bean to customise the Netty HttpServer.
#Bean
public NettyServerCustomizer nettyServerCustomizer(){
return httpServer -> httpServer.metrics(true, uriMappingFunction);
}
Caveat:
If you have path parameters in any of your URIs you should provide a uriMappingFunction that converts them to templated URIs ie. /user/1 -> /user/{id}. Failure to do so could lead to cardinality explosion in your MeterRegistry.
Enabling this feature also comes with the following recommendation:
It is strongly recommended applications to configure an upper limit for the number of the URI tags.
Reference Documentation
Java Doc

SpringBoot 1.5.x to 2.x upgrade

I am looking at the migration guide in this link
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide
Our environment currently has SpringBoot Services running 1.5.x. I am planning an upgrade to 2.x but would prefer planning for it a Service at a time at least to start with. We use Discovery (eureka), Config and other Spring Cloud modules as well.
I am planning to start with Discovery and wanted to get advice on how people have gone ahead with a migration as such. So based this plan, discovery will run 2.x with clients running 1.x to start.

spring boot 1.5.x /hystrix.stream actuator not working

I have the same issue as below. A very simple Hystrix spring boot application failing to load actuator /hystrix.stream.
Application uses Spring boot starter parent 1.5.x and hystrix 1.5.x libs. It worked well with Spring boot 1.3.x. Other actuators are good.
There's seems to be a known problem with 1.4.x and 1.5.x, however I'm looking for some workaround. Please don't suggest solutions for Spring boot 2.0.x.
From the github issue:
https://github.com/Netflix/Hystrix/issues/1566
We are using the Spring boot starter parent 1.5.2.RELEASE and hystrix 1.5.6 dependencies.
Fortunately it works once in hundred tries. We are really puzzled, why it works once and then never. All the services are running on the local machine.
The log details are as below:
Proxy opening connection to: http://localhost:6001/hystrix.stream
2017-05-05 12:29:16.951 INFO 4876 --- [nio-6001-exec-5] ashboardConfiguration$ProxyStreamServlet :
Proxy opening connection to: http://localhost:6001/hystrix.stream
2017-05-05 12:31:36.163 INFO 4876 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
If we try to curl the end point instead of getting back a snapshot of data, we get
Previous versions of Spring-boot 1.3.x did not have an issue. At first sight, this seems to be an incompatibility with Spring-boot or one of it's dependencies since our team had not had issues until a recent upgrade with Hystrix.
Noteworthy comment is that all other parts of Hystrix are working just fine. RequestLog, and at least Circuit Breaking are working as designed. For some reason the Hystrix Streaming Servlet is no longer functional for us.
The symptoms we receive for this issue are as follows:
Unable to connect to Command Stream (per description of ticket)
Access log receives 503 http status entry for hystrix.stream end point

Memcached with Spring

I have a Spring based application that uses Spring core, Spring MVC and Spring Data (Mongo) on the server side, and designed as a typical 3-tier application.
I have a list of services, that are typical Spring services/beans that I wish you integrate with memcached to cache some of my service results.
Can someone guide me to the steps to integrate memcached with spring for such an application?
A sample/tutorial/blog that gives a step by step process would be just great.
Thanks.
If you use Spring 3.1 take a look at Spring Cache abstraction. It's the easiest way to integrate caching in Spring application. Unfortunately Spring doesn't support memcached out of the box, there's only support for ehcache.
As far as I know there isn't available any provider that can store data to memcached through Spring Cache. In few days next version 3.0.0 of Simple Spring Memcached is going to be released with such support. In mean time you may try one of the latest snapshot or use Simple Spring Memcached 2.0.0 directly without Spring Cache abstraction.
UPDATE: Simple Spring Memcached 3.0.0 with Spring Cache integration is already available.
It's very trivial to do. You can look at 3levelmemcache project as an example at github its Spring based abstraction.

Categories

Resources