Jump to content

Tech Question: Distributed


Hindhustani

Recommended Posts


1. In a typical producer/consumer problem with queue example, where producer feeds the data to queue and consumer consumes the data from queue.
If the application was deployed in multiple nodes for high scalability and availability. That means producers and consumers are from multiple JVMs from different servers ?. How does semaphore and mutex control sharing the resource here between threads of the same JVM/Server and across JVM and servers?

2. Also in the case of ExecutorService, when multiple threads are executing. What if one thread hung up out of 5 threads? the remaining 4 threads continue to work? What will happen to the hung up thread?

 

@Vaampire @ramudu @dasari4kntr @csrcsr

Link to comment
Share on other sites

28 minutes ago, Hindhustani said:


1. In a typical producer/consumer problem with queue example, where producer feeds the data to queue and consumer consumes the data from queue.
If the application was deployed in multiple nodes for high scalability and availability. That means producers and consumers are from multiple JVMs from different servers ?. How does semaphore and mutex control sharing the resource here between threads of the same JVM/Server and across JVM and servers?

2. Also in the case of ExecutorService, when multiple threads are executing. What if one thread hung up out of 5 threads? the remaining 4 threads continue to work? What will happen to the hung up thread?

 

@Vaampire @ramudu @dasari4kntr @csrcsr

first point peddaga ardam akaledu anna

for the second point you can get the Future when you do the ExecutorService Submit 

when you use the future.get with predifined slaTimeout value you catch the TimeOutException and handle the logic

 

  • Upvote 1
Link to comment
Share on other sites

2 hours ago, Hindhustani said:


1. In a typical producer/consumer problem with queue example, where producer feeds the data to queue and consumer consumes the data from queue.
If the application was deployed in multiple nodes for high scalability and availability. That means producers and consumers are from multiple JVMs from different servers ?. How does semaphore and mutex control sharing the resource here between threads of the same JVM/Server and across JVM and servers?

2. Also in the case of ExecutorService, when multiple threads are executing. What if one thread hung up out of 5 threads? the remaining 4 threads continue to work? What will happen to the hung up thread?

 

@Vaampire @ramudu @dasari4kntr @csrcsr

I will try to answer later bro , I am outside 

  • Upvote 1
Link to comment
Share on other sites

On 1/28/2023 at 6:01 PM, Hindhustani said:


1. In a typical producer/consumer problem with queue example, where producer feeds the data to queue and consumer consumes the data from queue.
If the application was deployed in multiple nodes for high scalability and availability. That means producers and consumers are from multiple JVMs from different servers ?. How does semaphore and mutex control sharing the resource here between threads of the same JVM/Server and across JVM and servers?

2. Also in the case of ExecutorService, when multiple threads are executing. What if one thread hung up out of 5 threads? the remaining 4 threads continue to work? What will happen to the hung up thread?

 

@Vaampire @ramudu @dasari4kntr @csrcsr

No, producer or consumer jvm processes doesn't spam servers - they are all separate. Mutex, semaphore are within process only.

If you are trying to solve " read once" or "transaction" problems, then you solve with distributed patterns - ex : saga.

Also, in many cases you use distributed architecture when you don't care about transactions in traditional ways - 

- message may be lost, don't care : ex: weather or sensor feed. It's okay if you you lose one or two messages 

- or transactions are handled by business logic - either with DB locks or etc

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...