Technical Blog Post
Posssilbe reasons why Db2LUW connections are slow
Following is a good document on possible reasons why db2 connections could be slow,
I just wanted to highlight one more area to consider for the connect slowness.
Sometimes a database which might not be continuously in use.
Connections are happening in low numbers and then being terminated and there is a silent period after that before some more connections are being tried again.
If the database is not activated explicitly what happens is, the first connection will activate the database implicitly and then when it will go away the database will be deactivated implicitly against the last connection in the database.
As a result, when a new connection comes after a delay it will find the database needed to be activated again.
A database activation has overheads depending on the size of the total memory it need to allocate during the activation sequence and other initialization steps there too.
So, one easy way to rule out this issue is to issue an explicit activation at the beginning with "db2 activate database <db-name>". That will keep the database activated continuously even if there is no connections left in the database. It will remain activated until an explicit deactivate is issued.
The clue to find the symptom is to find FirstConnect messages in the db2diag.log over and over.
Also, there could be various reasons why db2 connections could be terminated. It could be as per the design of the setup or, by some abnormal reasons. Usually messages with -1224 will show up in the db2diag.log file if connections are being terminated.