hemerajs / hemera

🔬 Writing reliable & fault-tolerant microservices in Node.js https://hemerajs.github.io/hemera/
MIT License
806 stars 70 forks source link

Multiple server versions #19

Closed vitorcamachoo closed 7 years ago

vitorcamachoo commented 7 years ago

Hii,

Image if you have multiple servers on a NAT, spread by multiple version. What I want to know is, if there's any way to communicate to a specific server version using act command?

The logic behind that is, imagine you have two session servers (0.0.1 and 0.0.9). One specific application requests for something to session server this server depends on 0.0.9, so the request will reach to session@0.0.9. For some reason that server will crash and the request goes to the other server that is compatible with (ex. 0.0.1).

Thanks!

StarpTech commented 7 years ago

Hi, please specify what do you mean with "multiple servers on a NAT". Do you talking about NATS Server or Hemera Client?

but I will try to answer your question.

@vitorcamachoo NATS is a simple pub/sub system. How we communicate with it is standarzied in the protocol. Hemera also have a protocol. As long as we dont change the way how we communicate everything is still backwards compatible.

Scenario 1: If you talking about a different scenario like

Hemera Instance A with your API version 1.0.0 Hemera Instance B with your API version 2.0.0

here you can easily subscribe to a topic like math:version:1.0.0

act({topic: 'math:version:1.0.0', cmd: 'add', a: 1, b: 2 })

Scenario 2: Single Hemera Instance with your API version 1.0.0 and 2.0.0.

here you can easily subscribe to a topic like math and change your pattern based on your API version

act({ api: '1.0.0', topic: 'math', cmd: 'add', a: 1, b: 2 })
vitorcamachoo commented 7 years ago

Hi, I was talking about multiple Hemera instances spread by version. The correct scenario is the first one, and that is what I was thinking.

Imagine an Hemera instance depends on Math@1.0.9 and make a request: act({topic: 'math:version:1.0.9', cmd: 'add', a: 1, b: 2 })

If that instance is down, I will received a timeout, and the recovery process to a compatible Math instance (ex: 1.0.1) is through that timeout handling, getting all instances which begin with math:* and filter by the last compatible version and make that request. I'm right?

Thanks.

StarpTech commented 7 years ago

@vitorcamachoo hemera is a RPC toolkit which based on the messaging platform NATS. You have to create multiple instances of your service and multiple NATS Server to increase fault tolerance.

NATS can dealing with weak members in your network Pruning.

vitorcamachoo commented 7 years ago

Thanks a lot for the explanations!