2

I have a Spring boot application (Micro-service) running on Two nodes and registered with Eureka Naming server. My requirement is as follows:

  1. An Autosys job will trigger one complex calculation in micro-service which will take about 45 minutes to complete. Result of this calculation will be saved to Gemfire cache and database. I want these two nodes act as Master-Slave where only Master node will take up and execute the request of complex calculation. If master goes down then only slave will become master and will be responsible for execution of complex calculation.

  2. Another catch is while complex calculation is running, if adhoc request for the same calculation comes; latest request needs to be rejected saying calculation is already running.

I explored the possibility to use Apache ZooKeeper but it doesn't seem to satisfy my requirement of serving the request only using Master node.

Is there any way of achieving this?

James Z
  • 12,209
  • 10
  • 24
  • 44

1 Answers1

0

What about Kafka? It uses ZooKeeper under the covers: https://kafka.apache.org/

You are probably looking for leader election: When does Kafka Leader Election happen?

Fabio Manzano
  • 2,847
  • 1
  • 11
  • 23
  • I did explored Leader Election in Kafka with ZooKeeper, however in that use case even slaves are participating in serving the request (Write request). For our requirement, we strictly need that only Master/Leader node should serve the request. Let me know if you have come across any such use case using Kafka & ZooKeeper or maybe by some another tool. Thanks Again !! – Gurunath Solanki Aug 02 '18 at 10:29
  • Reading your question again, it looks more like a batch processing challenge. Maybe you could try to have a Kubernetes cluster orchestrating your batch, or even consider a cloud service, such as AWS Batch: https://aws.amazon.com/batch/use-cases/ – Fabio Manzano Aug 02 '18 at 21:42
  • Hi @fabio-manzano , yeah I figured it out that for my problem I need not use any fancy tool. I can rather easily control this using entry in database. – Gurunath Solanki Aug 08 '18 at 10:13
  • @GurunathSolanki, thanks! Hope you found a solution. – Fabio Manzano Sep 02 '18 at 17:08