I am developing a service which figures out the freights and frequencies to deliver a product to the customer.
The flow goes as below-
- I receive a request for a one item
- For every item I have 5 different Time Windows to check
- For every Time Window, I have 21 different days to check for weekly frequencies.
If I try to achieve this without spawning threads my service takes around 1 second to compute all the desired functionality.
To reduce the response time, I have built the service by spawning threads at different levels as below -
- Spawned threads for every item in the request
- Spawned threads per item per window (5 windows would correspond to 5 threads)
- Spawned threads per date per window (21 dates would correspond to 21 threads)
So if I get a single item in the request, I would spawn in total of (1x5x21= 105 threads). Does this look correct? Should I worry running out of heap space or Context Switching Time?
Any leads would be helpful. Thanks in advance!!