in reply to Need suggestion on problem to distribute work
The main program queues new work onto a queue that is accessible by multiple worker threads. There will be multiple Worker threads. If a worker thread is not busy and work is available, it accepts new work and processes the DB and remote server work items. If your DB and remote server can handle multiple operations at the same time, this will speed things up.
Ultimately there will be a maximum throughput. Some sort of throttle will probably be necessary on the main program so that the work queue doesn't grow to an infinite size. I suspect there will be other complications with error handling. But is this general idea what you seek?
Update: Clarification is needed on this point: Remote server connection and sending request is taking about 10ms due to latency Surely you are not connecting and disconnecting for each server request? Connect once, use many. However, 10ms for remote communication overhead doesn't strike me as particularly long. I work with some networks where a simple ping response time takes 60-70ms. BTW, you don't mention DB processing time, but that can be very significant. A DB commit is "expensive" and requires multiple disk operations. Search for "ACID DB". I suspect the DB operation takes longer than the "send to remote server" operation.Main Program: there is just one of these while (I don't know) { generate work item push work onto shared work queue } Worker Bee Thread: There will be N of these running in parallel #each worker gets its own connections connect to DB connect to remote server while (pop from work work queue, if queue not empty) { manipulate DB send to remote server }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need suggestion on problem to distribute work
by perlfan (Parson) on Jun 14, 2020 at 23:31 UTC | |
by Marshall (Canon) on Jun 14, 2020 at 23:35 UTC | |
by perlfan (Parson) on Jun 14, 2020 at 23:37 UTC | |
by marto (Cardinal) on Jun 15, 2020 at 08:11 UTC | |
by Marshall (Canon) on Jun 14, 2020 at 23:49 UTC | |
by smarthacker67 (Beadle) on Jun 15, 2020 at 18:32 UTC | |
|
Re^2: Need suggestion on problem to distribute work
by smarthacker67 (Beadle) on Jun 15, 2020 at 18:20 UTC |