On 2 February 2011 22:59, Brian Hurt <[email protected]> wrote:
>
>
> On Wed, Feb 2, 2011 at 5:51 PM, John Cowan <[email protected]> wrote:
>>
>> On Wed, Feb 2, 2011 at 5:47 PM, Robert Fischer <[email protected]>
>> wrote:
>>
>> > Wait—let me get this straight.  Even if you close a socket, you've
>> > still consumed a port number, and there's no way to free the port
>> > numbers for re-use?
>>
>> No, not at all.  If the socket has been closed long enough, the kernel
>> will free the port number, and it can be reallocated.  I was simply
>> speculating that the OP was opening ports faster than he was closing
>> them, but apparently not.
>
> I'm looking into this.  It's possible, even probable, that my "rate of
> socket opening" does increase shortly before I hit the problem.  It's not
> wrapping the port numbers that are the problem, it's wrapping them too fast.
>
> This is especially relevant because it looks like the problem goes away
> after a second or two.  So this is making sense.  Thanks.


Just some other general observations:

Your application seems to be pushing the TCP protocol kind of close to
its limits. You can mess with the TIME_WAIT setting and the problem
will go away but TIME_WAIT is there for a reason and it's possible
that you will encounter very rare, irreproducible failures (it may
also make you more vulnerable to malicious attack). You might consider
binding multiple IP adresses to your NIC and spreading the load over
them. This would give you a nice way of scaling the number of server
sockets available to you (30K * the number of IP adresses).

Opening and closing a server socket is quite expensive (both
computationally and in terms of network packets). If you are
transferring small amounts of data you might want to consider using
Datagrams. Datagrams have very low overhead but, of course, have
unreliable delivery semantics so you would have to be able to tolerate
(e.g. have idempotent protocols) or detect and correct delivery
failures.

Apologies if this is telling you things you know already:)

John Wilson

-- 
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en.

Reply via email to