• Post Reply Bookmark Topic Watch Topic
  • New Topic

connection pooling code

 
Manisha reddy
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do we implement connection pooling in our applicaon without making use of the service provided by application/web servers ?

Thanks in advance
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always use an existing library to do the connection pooling. It comes with documentation, and there are plenty of others out on the net, too.
 
susha bhogs
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You require lot of coding for this.
1. Define property which holds the min and max number of objets (Threads)
e.g. min_thread=5
max_thread=10
min_wait_time=1000 (10 secs)
2. Write one custom code and this code would
2.1 On startup create the min # of objects and store in some collection.
2.2 Everytime this object gets used - set one counter
2.3 When this counter goes beyond min, then create a new instance and add that into the collection and then return to the client.
2.4. Increment the conter.
2.5 Whenever the object is released , return the same thread to the collection.
2.6. Decrement the counter.
2.7. When the counter is less than min and objects are released, then remove them from the colllection (maintain only min)
2.8. When the max level is reached then throttle the new client request by waiting for the time (min_wait_time) and then timing out if no object is available in that time.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!