In this scenerio, I have to Poll AWS SQS messages from a queue, each async request can fetch upto 10 sqs items/messages. Once I Poll the items, Then I have to process those items on a kubernetes pod. Item processing includes getting response from few API calls, it may take some time & then saving the item to DB & S3. I did some R&D & reach on following conclusion
- To use consumer producer model, 1 thread will poll items & another thread will process the item or to use multi-threading for item processing
- Maintain a data structure that will containes sqs polled items ready for processing, DS could be Blocking collection or Concurrent queue
- Using Task Parellel Library for threadpooling & in item processing.
- Channels can be used
My Queries
- What would be best approach to achieve best performance or increase TPS.
- Can/Should I use data flow TPL
- Multi threaded or single threaded with asyn tasks