Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #33257

Re: multithread client socket

From Martin Gregorie <martin@address-in-sig.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: multithread client socket
Date 2015-12-01 19:38 +0000
Organization A noiseless patient Spider
Message-ID <n3ksvl$683$2@dont-email.me> (permalink)
References <cd5afdca-ada8-4c3e-b1da-c29fc8f7442e@googlegroups.com>

Show all headers | View raw


On Tue, 01 Dec 2015 09:36:58 -0800, Philipp Kraus wrote:

> Hello,
> 
> I'm using a cached thread pool which gets a lot of callable objects.
> Each callable create with "new Socket" a client socket to a server,
> sends data to the server, receive the response and returns the response
> with a future object. The server closes the socket after the response is
> send.
>
Have any server transactions finished before you get the error?

If the answer is 'No', then limit the size of the thread pool to prevent 
the error and use a Queue to store pending requests that are waiting for 
a thread to come available because this shows that requests are arriving 
faster than the server can handle them.

From what you say, it sounds as though each thread can close its socket 
once it gets the disconnection and then re-open after it gets a new 
request to process.

How many threads does the server use to handle these requests? It may be 
a bit pointless for your client to have more requests outstanding than 
the server can handle at once. Make your thread pool size configurable so 
you can tune your client for maximum speed without swamping the server 
with requests and/or impacting the performance of other parts of the 
application system.

There may be a limit on the number of sockets a Java process can have 
open: if so this will set an upper limit to the size of your thread pool. 
Is such a limit documented anywhere? Can it be changed?


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

multithread client socket Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2015-12-01 09:36 -0800
  Re: multithread client socket Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-12-01 10:12 -0800
  Re: multithread client socket Martin Gregorie <martin@address-in-sig.invalid> - 2015-12-01 19:38 +0000
    Re: multithread client socket Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2015-12-01 22:56 -0800
      Re: multithread client socket Martin Gregorie <martin@address-in-sig.invalid> - 2015-12-02 14:57 +0000
        Re: multithread client socket Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-12-02 10:54 -0500
          Re: multithread client socket Martin Gregorie <martin@address-in-sig.invalid> - 2015-12-02 19:18 +0000
          Re: multithread client socket Eric Douglas <e.d.programmer@gmail.com> - 2015-12-02 11:47 -0800
            Re: multithread client socket Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-12-02 15:30 -0500
              Re: multithread client socket Eric Douglas <e.d.programmer@gmail.com> - 2015-12-02 12:57 -0800

csiph-web