All of lore.kernel.org
 help / color / mirror / Atom feed
* how to listen() on single IP address but very many ports?
@ 2011-02-18 17:55 Chris Friesen
  2011-02-20 19:20 ` Eric Dumazet
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Friesen @ 2011-02-18 17:55 UTC (permalink / raw)
  To: netdev


I have an application team that needs to listen() for tcp connections on
many ports (and by many I mean pretty much all 64K ports).  However, the
connections are short-lived, and the number of active connections at any
given time is small.

Apparently when they tried this before on an older kernel the
performance of the naive "open 60K sockets and call listen()" solution
was not acceptable, so they used NAT with port mapping to direct all the
incoming packets to a single real port.  However, they now want to add
support for IPv6 and this solution won't work.

What's the recommended method for efficiently listening on this many
ports?  Should I be able to efficiently listen() on that many sockets
using epoll or similar?  If there isn't a way to do this, is there an
equivalent IPv6 workaround?

One possible solution that came up was to implement a PORT_ANY which
would match any incoming request that didn't already have an explicit
listener.  Even better would be a way to bind a single listening socket
to a range of ports.

Has anyone ever considered something like this?

Chris

-- 
Chris Friesen
Software Developer
GENBAND
chris.friesen@genband.com
www.genband.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: how to listen() on single IP address but very many ports?
  2011-02-18 17:55 how to listen() on single IP address but very many ports? Chris Friesen
@ 2011-02-20 19:20 ` Eric Dumazet
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2011-02-20 19:20 UTC (permalink / raw)
  To: Chris Friesen; +Cc: netdev

Le vendredi 18 février 2011 à 11:55 -0600, Chris Friesen a écrit :
> I have an application team that needs to listen() for tcp connections on
> many ports (and by many I mean pretty much all 64K ports).  However, the
> connections are short-lived, and the number of active connections at any
> given time is small.
> 
> Apparently when they tried this before on an older kernel the
> performance of the naive "open 60K sockets and call listen()" solution
> was not acceptable, so they used NAT with port mapping to direct all the
> incoming packets to a single real port.  However, they now want to add
> support for IPv6 and this solution won't work.
> 
> What's the recommended method for efficiently listening on this many
> ports?  Should I be able to efficiently listen() on that many sockets
> using epoll or similar?  If there isn't a way to do this, is there an
> equivalent IPv6 workaround?
> 
> One possible solution that came up was to implement a PORT_ANY which
> would match any incoming request that didn't already have an explicit
> listener.  Even better would be a way to bind a single listening socket
> to a range of ports.
> 
> Has anyone ever considered something like this?
> 

I really dont see how listening to 60K sockets can be "not acceptable".

It just runs OK, at exactly same speed than 1 socket, if using epoll.

Only 'problem' could be memory usage, a bit more heavy of course, but
who cares ?




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-20 19:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-18 17:55 how to listen() on single IP address but very many ports? Chris Friesen
2011-02-20 19:20 ` Eric Dumazet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.