0

We have an environment where we run multiple spring boot web services all linked to a single database schema. All of them are registered to Eureka and a gateway is responsible of accepting client requests and routing to a certain instance based on the load balancing strategies. My question is that in case we have a job on these instances or in case for a certain reason we receive a request twice and each request was routed to a different instance, how can we prevent executing the same request twice?

What i know is that shedlock lib and spring zookeeper can secure a job from being executed at the same time under two instances, but if we do want jobs to exeucte together for better performance but not to execute same transaction id at the same time, what is the best solution for this?

What about not executing same api request twice if received 2 times?

should we just use redis as external system and do a get on a map of transaction ids before executing the transaction? or is there any "spring boot" way to do it?

our target is also to choose a light solution, with best performance and less integration code

3
  • It's unclear what you mean by transaction id. Regardless, RESTful apps have their own paradigms vis-a-vis Idempotency wrt to POST vs GET, that might be where to start.
    – awgtek
    Commented Jun 10 at 16:42
  • Transaciton ID = any request ID or unique identifier for an operation. REST APIs have their own paradigms included in a single instance not a multi instances micro services architecture. This is something else.
    – user666
    Commented Jun 12 at 12:49
  • It sounds like you are dealing with a faulty system. First you say the transaction id should be unique, but then you ask about what if the same unique request goes to two instances. I would look into why a single unique transaction was routed to two instances. Are your clients not minting new transaction ids for every request?
    – awgtek
    Commented Jun 14 at 5:13

0