I have Tomcat running on 2 Kubernetes pods. When my app receives a HTTP request it reads a list of records from database and does some process on each record. But since its a single HTTP request this process runs only on one pod. Is there any way that I can distribute the process over both pods, so half of the records get processed on pod1 and rest of the records get processed on pod2?
What I have tried
I could not find exact solution so as an alternative approach I tried this:
After receiving HTTP request and reading list of records from database. I am posting each record to a queue and let my service consume it. This way process is distributed in both pods.
Is there any better solution to this problem?