Results 1 to 5 of 5
  1. #1
    johnmerlino is offline Member
    Join Date
    May 2014
    Posts
    56
    Rep Power
    0

    Default Java 8 Database Connection Pool Library

    I have a udp socket server, which will have 100,000 concurrent connections. I spawn each connection in its own thread. I am thinking to implement the Producer-Consumer Pattern discussed here Guarded Blocks (The Java™ Tutorials > Essential Classes > Concurrency). Basically, I have a producer thread, which takes the udp packet, decodes it into an array of strings. Then I invoke a notifyAll to wake up a thread which is the Consumer, which will actually be the thread which is using JDBC to execute sql insert statements to a postgresql database. Now these "database" threads I plan to have a database connection pool for in order to reduce latency. But I want to use a connection pool library rather than rolling out my own. I have done some research on the web and found options such as BoneCP, c3p0, DBPool, etc. I visit the BoneCP website, for example, BoneCP - The fast Java JDBC Connection Pool but it doesn't mention anything about support for Oracle Java 8. Anyone can recommend a database connection pool library for Java 8?

  2. #2
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Java 8 Database Connection Pool Library

    Hi,

    some points that I was thinking of:
    a) If you have a UDP Server, then there are no connections. UDP is a connectionless protocol. So all you do is receiving DatagramPackets and then react on them.
    b) Even if you use TCP so you have connections: Do you really want to spawn 100.000 threads? That does not sound like a good idea to me. The common practice that I used in the past is to keep all sockets / connections in a collection and then go through them:
    - If a listener socket has a new connection, then you accept it
    - If a sockets has data, then you read it.
    Or is short words: you simply avoid blocking calls.

    Regarding your question: Why do you expect any problems when using BoneCP with Java 8 / Oracle JDBC driver? It works with java 1.5 and above. So it should work fine with Java 8.

    With kind regards,

    Konrad

  3. #3
    johnmerlino is offline Member
    Join Date
    May 2014
    Posts
    56
    Rep Power
    0

    Default Re: Java 8 Database Connection Pool Library

    @Konrad

    So you are against the top answer that was voted here? multithreading - How can I implement a threaded UDP based server in Java? - Stack Overflow

    When you have 100,000 concurrent connections, with time-sensitive information, it is critical that they are inserted in the database at the same time. Without multi-threading, this cannot be achieved.

  4. #4
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Java 8 Database Connection Pool Library

    Hi,

    I do not know the content of that thread on Stack Overflow and the site is down for maintenance at the moment.

    But I really doubt that they suggested to have 100.000 threads or a thread per client. And the best solution always depends on the hardware, operating system and other software that is running. If you have more threads than the computer can execute in parallel, then the performance even goes down because cpu cycles are wasted for thread switches. So just let us get up an example:
    - For each incoming packet you spawn a thread. Spawning a thread has some overhead but we accept it right now.
    - The thread gets a connection to the database (from a pool) and then inserts the data.
    - Now (maybe even for a short duration only) we receive new data quicker than we could do the database work: So you will add up higher load which will waste more load (CPU on database and local system and network) which might even make this situation worse.

    What I would do is having a fixed number of threads. These threads will take data to process and simply process the data. That way you do not have the overload of starting new threads (Ok, a pool can help here, too) and you can even ignore the requirement of a Pooling regarding the database (because at startup each thread can open a database connection).

    But all that is my personal view only. Maybe there are some important points that I am missing right now.

    Konrad

  5. #5
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Java 8 Database Connection Pool Library

    Stack Overflow is back again and I was able to look at that thread.

    You are aware that they all do not talk about a heavy load? I doubt that this radius server is build for heavy load (Clients only authenticate, no open connection and no requirement for 100.000 clients!)

    Konrad

Similar Threads

  1. Connection Pool
    By mine0926 in forum Advanced Java
    Replies: 57
    Last Post: 06-18-2011, 03:07 AM
  2. Replies: 2
    Last Post: 12-15-2010, 06:11 AM
  3. Replies: 2
    Last Post: 06-07-2010, 11:33 AM
  4. Using Database connection pool
    By amsagara in forum Advanced Java
    Replies: 0
    Last Post: 08-11-2009, 12:44 PM
  5. connection pool for db2
    By paty in forum JDBC
    Replies: 1
    Last Post: 08-06-2007, 02:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •