Netflix / Turbine

SSE Stream Aggregator
Apache License 2.0
835 stars 255 forks source link

Turbine can't aggregate from two microservices running on the same host on a different port #88

Open BertDuerinck opened 9 years ago

BertDuerinck commented 9 years ago

I have two services running on the same host on a different port. Turbine Instance class doesn't uses port in the equals() and hashCode() only the host and cluster name. This causes problem when storing the two instances in a hashSet of the hostsUp.

Is there a workaround for this?

benjchristensen commented 9 years ago

In v1 I don't think so, not easily at least. In v2 (which I have not had time to prove as production ready) it is easy since the stream of connections is far more abstracted and each can have their own host:port.

xxlabaza commented 9 years ago

How about a solution for this problem?

I'm using Spring Cloud Turbine:

<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-turbine</artifactId>
        <version>1.0.1.BUILD-SNAPSHOT</version>
</dependency>

And have the next configuration for Turbine:

InstanceDiscovery.impl: com.netflix.turbine.discovery.EurekaInstanceDiscovery.class

turbine:
  appConfig: clientsample
  instanceUrlSuffix: /admin/hystrix.stream
  clusterNameExpression: new String("default")

As you can see, I'm using Eureka Discovery service. My 'clientsample' instances start at localhost with server.port 8181 and 8282.

When I start Turbine it logs:

Retrieved hosts from InstanceDiscovery: 2
Found hosts that have been previously terminated: 0
Hosts up:1, hosts down: 0

And it shows hystrix logs only for one 'clientsample' host (random choose) and ignore another.

When I try to configure host explicitly:

turbine:
  appConfig: clientsample
  instanceUrlSuffix: /admin/hystrix.stream
  aggregator:
    clusterConfig: CLIENTSAMPLE
  ConfigPropertyBasedDiscovery:
    CLIENTSAMPLE:
      instances: localhost:8181,localhost:8282

it has no effect and the result is same.

How can I solve my problem?

benjchristensen commented 9 years ago

This still does not have an official solution as it was not an original design requirement of Turbine which assumed a single process per machine (the norm in AWS cloud deployments which this was originally built against).

I want there to be a solution but it is not something getting any attention right now. If you want to submit a pull request that would be great. I personally think the work should be done on the new Turbine 2 branch though.

codependent commented 9 years ago

@benjchristensen I have come across this issue after posting in Stackoverflow with this same problem. Any advance with this in v1?

codependent commented 9 years ago

@benjchristensen @xxlabaza @BertDuerinck I just submited a pull request solving this Issue.

Waiting for your feedback