I setup a Spring boot application with #EnableDiscoveryClient and using Consul as the cloud provider. I noticed that this generates high cpu consumption due to ConsulCatalogWatch.catalogServicesWatch. Looking at the code, I noticed that the annotation
#Scheduled(fixedDelayString = "${spring.cloud.consul.discovery.catalogServicesWatchDelay:10}")
will cause this method to be call at a very high rate.
Does anyone have met this and am I missing something ?
As a workaround, set spring.cloud.consul.discovery.catalogServicesWatchDelay=30000.
Fixed via issue 94.
Related
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!
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
i want to expose the disk usage for my micro-service to Prometheus, i'm already using micrometer and micrometer Prometheus with jdk 11 and spring boot actuator
im able to get all the other metrics working like tomcat_sessions and jvm_buffer_total_capacity_bytes etc,
and i can't seem to find a way of exposing the disk usage
I am having an issue where EC2MetaDataUtils.getItems is being invoked on application start up ( Spring boot app), we do not use EC2 and so the calls made to AWS to get Metadata always fail, the application attempts to get this data 3 times and so this is adding around 15 seconds to the start time of the application.
I have been searching high and low for solutions I found a promising solution would suggested the following #EnableAutoConfiguration(exclude = { ContextResourceLoaderAutoConfiguration.class, ContextResourceLoaderConfiguration.class, ContextInstanceDataAutoConfiguration.class })
However when I try to start up the application it complains that ContextResourceLoaderConfiguration.class cannot be excluded as it is not auto configuration; if I just exclude the other 2 the application still invokes the MetaDataUtils.
Has anyone experienced this in the past and managed to resolve it?
Thank you for your time.
Resolved with the following:
#EnableAutoConfiguration(exclude = {ContextInstanceDataAutoConfiguration.class, ContextStackAutoConfiguration.class, ContextResourceLoaderAutoConfiguration.class})
when running spring-boot-application with AWS dependencies ,
It invokes stack auto-configuration , you need to disable it ,
add following to application.yml
cloud.aws.stack.auto: false
SpringBoot application should not do any call to EC2. This mean your are using some AWS specific library/component/what ever and this library on startup do this call.
Please check your dependencies and context configuration. There are nothing about SpringBoot. There is something with your custom dependencies/components.
If you're not using EC2, you can try removing the spring-cloud-aws* libraries from your dependencies.
You can use Spring profiles to differentiate between cloud and default profiles. For cloud profile, you can use spring-cloud-aws artifact to get metadata about EC2 instance which you need EC2 read permission access from an attached IAM role whereas for default profile, you don't need to worry about cloud environment and disable the cloud configuration properties which should not cause an issue for the application startup.
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.