Inspect the code to ensure that it closes connections immediately it has finished using them.
Check that the code opens the minimum number of connections required:
If you are processing a large number of files you can open one or a group of several at a time rather than all of them. Then you can close the first group before processing the next group.
You might set an upper limit on connections and not open more when the limit is reached. Then when the number of connections drops you can open more.
In particular you need to ensure that persistent connections are kept to a minimum:
Persistent connections (particularly to databases) can be very efficient – and it is possible reduce the number of connections by using a small number of persistent connections. The key thing with persistent connections is to ensure that the number cannot keep increasing.
Persistent connections to resources that you are re-using all the time make good sense – they are particularly useful for databases
This page explains about persistent database connections: https://help.interfaceware.com/v6/database-connection
Make sure that you are not continuing to open extra or duplicate persistent connections unintentionally (i.e., logic error that opens multiple database connections).
Check that the code does not allow the number of connections to continually increase:
This is basically checking for “connection leaks” in the the same way as you would check code for memory or other resource leaks – this is particularly important for long running programs as any “leak” will eventually reach the system limit.
Make sure connections are closed as soon as possible.
Set limits on the maximum number of connections.
In the unlikely situation where you actually need more files open than the limits allow you can split the processing between several Iguana servers.