how to have a turbine cluster for each eureka app in spring boot? - spring

I am trying to obtain an "autoconfiguration" of turbine clusters from my eureka server.
registered on the eureka server I have configured 3 apps: app1, app2, app3.
registered on the eureka server there are also a zuul proxy and a turbine monitor.
i can access the three apps via zuul correctly, i can see all of the hystrix.stream of each app correctly.
I have configured a single turbine cluster 'default' and I can see the merged turbine stream (and the dashboard) of all the three apps from the dashboard without issues.
my turbine application.properties looks like this:
eureka.client.serviceUrl.defaultZone=http://localhost:33210/eureka/
turbine.app-config=app1,app2,app3
turbine.cluster-name-expression=new String("default")
what I can't seem to do is to distinguish the turbine streams to avoid mashing up all the hystrix commands between the three apps in the dashboard.
what I would like to have as a result is the possibility to put
/turbine.stream?cluster=app1
/turbine.stream?cluster=app2
/turbine.stream?cluster=app3
where cluster matches the eureka name of each app, and obtain three different dashboards. I thought by documentation that removing by the cluster-name-expression the default would be the appName instead of the static 'default', but it doesn't happen.
what did I get wrong?

property name should be like
turbine.clusterNameExpression= new String("default")
to have different cluster for each stream... assuming you even have different management port enabled on each service in eureka, i.e. 51511 and 51521 is for service endpoints and 51512 and 51522 is for management endpoints.
turbine.instanceInsertPort=false
turbine.appConfig=service1,service2
turbine.aggregator.clusterConfig=SERVICE1,SERVICE2
turbine.instanceUrlSuffix.SERVICE1=:51512/hystrix.stream
turbine.instanceUrlSuffix.SERVICE2=:51522/hystrix.stream

turbine.clusterNameExpression= new String("default")
this worked out for me.
I only replaced
turbine.cluster-name-expression='dafault'
with above and it worked like a miracle for me.

Related

Spring Cloud Zuul-Gateway mapping with Config-Server

I'm developing a spring-microservice architecture with following modules (see the architecture diagram below):
Configuration-server
Eureka-Server
Zuul Api Gateway
User-api(Config-Server-Client, Eureka-Client)
Stats-api(Config-Server-Client, Eureka-Client)
Auth-Service (in-progress/out of context)
It's is more of a configuration approach rather than a bug. So far everything is running fine.
For most of the configurations of core-apis, I'm loading them from config-Server.
What should be the actual or recommended way if we use config-server with Api-Gateway?
Would it be good to map(load from) the configuration of Zuul-Gateway to my Config-Server as with other core apis like User-Api and Stats-Api.
And if I did so what should be the order of starting the applications?
Like:
1. Start the Config-Server
2. Eureka Server
3. Zuul Gateway
4. Core-Apis
Thanks :)
I have build a similar architecture for testing purpose. You can find in the link below:
https://github.com/rshtishi/payroll
The order I use to start the services is like below:
Configuration Server (Spring Cloud Config Server) is always the first start. Here are the configuration for all the services.
Eureka Server, is responsible for registering all services.
After starting the service above, you can start whatever you wish api-services or zuul gateway server. Zuul gateway server will access the api services through eureka. So it doesn't matter the order.

Eureka service discovery not working in Azure

I have 2 micro-services that register with Eureka. I run the projects locally and call one micro-service from another using Feign & Ribbon and everything works fine.
However when I deploy everything to Azure it no longer works.
I can see the services registered in eureka dashboard but when I click on a particular service I get an url like this http://100.79.xxxx.xx:xxxx and after loading for a while I get a connection timeout. Same happens in code when one micro-service calls the other through Eureka.
I also added this setting to eureka clients but it didn't help:
eureka.instance.prefer-ip-address: false
It seems that the IP addresses of services instances are not reachable.
Is there a way to make Eureka work on Azure? Thanks for your help.

Turbine stream double port binding issue

I'm using Spring Boot 1.5.4 and Spring Cloud Dalston SR4 to stand up a Turbine server on Cloud Foundry and aggregate my application Hystrix streams. In addition I want to add Spring Boot Actuator monitoring and management to the Turbine server. I realize there is ample documentation on how to do this in a local environment and I do have it working locally. However it is a different matter when deploying to Cloud Foundry where I cannot use port numbers in a Url binding.
The issue is that the Turbine stream is provided by an RxNetty server on one port and the Actuator endpoints are provided by via Tomcat on another port. In Cloud Foundry I can only bind my Url to RxNetty endpoint or the Tomcat endpoint, not both.
No combination of management.port and turbine.stream.port allows me to access the turbine stream and the actuator endpoints from one host binding. The following is an example of what I would expect to be able to do:-
https://myapp.mydomain.com/info (to report actuator info details)
https://myapp.mydomain.com/turbine.stream (to stream turbine metrics)
Note: There are no port numbers in these Urls.
Requests to your app on Cloud Foundry go through the Cloud Foundry Go Router, which uses the http host header to direct traffic to all the container instances running your app. The http based gorouter expecter only one port to be opened by the app to forward http traffic to. However, the gorouter also support tcp routing which should allow you to have multiple ports open. see the docsfor an explanation of tcp vs. http routes on cloud foundry.
If you are running on Pivotal Cloud Foundry you can use the Circuit Breaker Dashboard provided by Spring Cloud Serviecs for PCF then you won't need to setup the turbine stream. The Spring Cloud Services Dashboard uses RabbitMQ instead of SSE events see SCS docs for details
Just getting back to this now. As noted by spencergibb, moving to springboot 2.0 and cloud Finchley works.

Spring cloud registering multiple instances of same service

I am developing a microservice, using Spring Boot, that exposes REST Endpoint. Because of scalability, I have to run multiple instances of this services on a different port. What will be the configurations for the applications so that it can register with eureka and requests are load balanced? I am using Spring cloud config, Eureka server and zuul.
Attaching following entries in the client properties file will do the trick. This is for Spring cloud config dalston
eureka.instance.instanceId=${spring.application.name}:${spri‌​ng.application.insta‌​nce_id:${random.valu‌​e}}
I guess you meant to register with Eureka instead of Config server.
To register multiple instances that might be running in the same host but listening on a different port you would need to set eureka.instance.metadataMap.instanceId to a unique value maybe using:
eureka.instance.metadataMap.instanceId=${spring.application.name}:${random.int}

Load Balancing micro services using Spring cloud Netflix OSS

I have a microservice built using Spring Boot and Netflix OSS. I have used Central config server, Eureka and Zuul. Because of scalability multiple instances of the services is running on different port. All the instances are registered in Eureka but requests are going to only last registered server.
How to load balance services. Should I use ribbon in Zuul to load balance? Please let me know how to achieve load balancing on same service running on multiple instances.
If there is a code change required a snippet then please post a code snippet as well.
Application Config
spring.application.name=book-service
server.port=0
eureka.client.region = default
eureka.client.registryFetchIntervalSeconds = 5
eureka.client.serviceUrl.defaultZone=http://discUser:discPassword#localhost:10082/eureka/
#eureka.instance.metadataMap.instanceId=${spring.application.name}:${spring.application.instance_id:${random.value}}
eureka.instance.instanceId=${spring.application.name}:${spring.application.instance_id:${random.value}}
eureka.instance.leaseRenewalIntervalInSeconds=5
eureka.instance.leaseExpirationDurationInSeconds=5
Eureka Config
spring.application.name=discovery
server.port=10082
eureka.instance.hostname=localhost
eureka.client.serviceUrl.defaultZone=http://discUser:discPassword#localhost:10082/eureka/
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
spring.session.store-type=hash-map
ZUUL Config
spring.application.name=gateway
server.port=10080
eureka.client.region = default
eureka.client.registryFetchIntervalSeconds = 5
management.security.sessions=always
zuul.routes.book-service.path=/book-service/**
zuul.routes.book-service.sensitive-headers=Set-Cookie,Authorization
hystrix.command.book-service.execution.isolation.thread.timeoutInMilliseconds=600000
#zuul.routes.rating-service.path=/rating-service/**
#zuul.routes.rating-service.sensitive-headers=Set-Cookie,Authorization
#hystrix.command.rating-service.execution.isolation.thread.timeoutInMilliseconds=600000
zuul.routes.discovery.path=/discovery/**
zuul.routes.discovery.sensitive-headers=Set-Cookie,Authorization
zuul.routes.discovery.url=http://localhost:8082
hystrix.command.discovery.execution.isolation.thread.timeoutInMilliseconds=600000
logging.level.org.springframework.web.=debug
logging.level.org.springframework.security=debug
logging.level.org.springframework.cloud.netflix.zuul=debug
spring.session.store-type=hash-map
Registering application properly with Eureka will do the trick.
Below entries will uniquely register services with Eureka.
#eureka.instance.metadataMap.instanceId=${spring.application.name}:${spring.application.instance_id:${random.value}}
eureka.instance.instanceId=${spring.application.name}:${spring.application.instance_id:${random.value}}

Resources