I have a simple express app that on request launches a worker, the worker generates a lot of data (5 MB, takes about 3 seconds) and sends over the first 50KB of it. Incase the same request is repeated, the worker gets a message to send over the next 50KB, otherwise it terminates after some time.
The issue with this setup is that the mainthread spends time unnecessarily by decoding the message and sending it again via express. I want to avoid this overhead as much as possible.
I have looked into using Node Clusters, but they seem to be unfit for this as I am unable to cache my data to respond with the next part of it quickly. It seems like I am unable to decide which part of the cluster gets which request, which is essential here. Is there an easy solution I am missing, or is Node not the right framework for this issue?