For my project,we are asked to implement our own connectionpooling. We are NOT allowed to used PGPoolingDataSource from jdbc. When I used the jdbc pooling my program is very fast, with my own connection pool its unpredictable and much slower. My connection makes some tasks wait for a long time,something that doesnt happen with jdbc pooling.
I am using Arrayblockingqueue for my implementation of connection pool, I just create a pre said number of connections and then I let clients borrow and put them back.
I mean this seems to make sense to me,and it works. But its slow and sometimes the tasks take forever to get done,is there anyway I could improve it? Make it faster more reliable?
You are using wrong data structure for storing connections ArrayBlockingQueue
is the FIFO structure which slowdown your processing, using ConcurrentLinkedQueue
is the reasonable and faster choice for this.