I have a java spring boot application with some open source schedulers in it. The main workflow of the application is: whenever we get the requeusts we create a task at some time as configured in the app (lets say 12 hrs from time of launch) and store the details of task as a blob in a table, say task_table. There is a poller in the application which gets started at the time of app startup and that keeps on polling the task_table to check if the task are due execution to be picked up. So once it picked up, the application will take 15 secs max to complete a task.
The poller has a seperate thread pools configured. There is a master agent who checks the table and distribute the picked tasks to the slave threads. I am using postgres sql as my database.
I have containarized my app as a docker containers and depolyed in aws ec2 instances. The main problem I'm seeing is when I run the app on a single container the tasks are getting executed at 15 as mentioned above. But when I scale the containers to 2,3,4 etc. I see constance increase in the task execution time. Say 2 containers it takes 20 secs, 3 containers 45 sec so on.
I have checked all the connection pool settings on the db side and IOPS values for read/write latency. Everything seems to be fine but I'm not able to find out how on auto scaling the containers the task takes more time? Because there is nothing shared across the containers other than DB.
Can someone help me with some inferences for the above problem??
I tried changing the ec2 instance types, RDS storage size, connection pool settings, IOPS values etc