Can you break down the processing into smaller batches?
There is an old (but still good) blog post on how to do this using the Limit and Offset options of a Retrieve action. The principle is still the same.
Hope this helps.
I'm already using batch processing, but it keeps causing this issue.
in the project I'm using connector database in this case querying data in external database the connection pool restricts the number of connections too?