How many connections can accept a 'binded' socket?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • billiejoex

    How many connections can accept a 'binded' socket?

    Hi,
    I'm writing a small asyncore-based server application serving a lot of
    clients. When I have to handle more than 1021 client simoultaneously
    the 'binded' socket object raises an error:

    [...]
    connections: 1018
    connections: 1019
    connections: 1020
    connections: 1021
    Traceback (most recent call last):
    File "asyncore_clien t.py", line 31, in <module>
    File "asyncore.p y", line 191, in loop
    File "asyncore.p y", line 138, in poll
    File "asyncore.p y", line 80, in write
    File "asyncore.p y", line 76, in write
    File "asyncore.p y", line 395, in handle_write_ev ent
    File "asyncore_clien t.py", line 24, in handle_connect
    File "asyncore_clien t.py", line 9, in __init__
    File "asyncore.p y", line 257, in create_socket
    File "socket.py" , line 156, in __init__
    socket.error: (24, 'Too many open files')

    I just wanna know: is there a way to know how many connections can
    accept a 'binded' socket BEFORE getting such error? Maybe
    socket.SOMAXCON N could help me?

    Thanks in advance.

  • Laurent Pointal

    #2
    Re: How many connections can accept a 'binded' socket?

    billiejoex a écrit :
    Hi,
    I'm writing a small asyncore-based server application serving a lot of
    clients. When I have to handle more than 1021 client simoultaneously
    the 'binded' socket object raises an error:
    >
    [...]
    connections: 1018
    connections: 1019
    connections: 1020
    connections: 1021
    Traceback (most recent call last):
    File "asyncore_clien t.py", line 31, in <module>
    File "asyncore.p y", line 191, in loop
    File "asyncore.p y", line 138, in poll
    File "asyncore.p y", line 80, in write
    File "asyncore.p y", line 76, in write
    File "asyncore.p y", line 395, in handle_write_ev ent
    File "asyncore_clien t.py", line 24, in handle_connect
    File "asyncore_clien t.py", line 9, in __init__
    File "asyncore.p y", line 257, in create_socket
    File "socket.py" , line 156, in __init__
    socket.error: (24, 'Too many open files')
    >
    I just wanna know: is there a way to know how many connections can
    accept a 'binded' socket BEFORE getting such error? Maybe
    socket.SOMAXCON N could help me?
    Here you get out of file descriptors, I dont think SOMAXCONN would help.

    Under Linux (maybe Unix), there is ulimit -n nnn to setup the maximum
    number of files descriptors. I don't know its upper limit (maybe a
    kernel compile time information).


    Comment

    • Alex Martelli

      #3
      Re: How many connections can accept a 'binded' socket?

      Laurent Pointal <laurent.pointa l@limsi.frwrote :
      billiejoex a écrit :
      Hi,
      I'm writing a small asyncore-based server application serving a lot of
      clients. When I have to handle more than 1021 client simoultaneously
      the 'binded' socket object raises an error:

      [...]
      connections: 1018
      connections: 1019
      connections: 1020
      connections: 1021
      Traceback (most recent call last):
      File "asyncore_clien t.py", line 31, in <module>
      File "asyncore.p y", line 191, in loop
      File "asyncore.p y", line 138, in poll
      File "asyncore.p y", line 80, in write
      File "asyncore.p y", line 76, in write
      File "asyncore.p y", line 395, in handle_write_ev ent
      File "asyncore_clien t.py", line 24, in handle_connect
      File "asyncore_clien t.py", line 9, in __init__
      File "asyncore.p y", line 257, in create_socket
      File "socket.py" , line 156, in __init__
      socket.error: (24, 'Too many open files')

      I just wanna know: is there a way to know how many connections can
      accept a 'binded' socket BEFORE getting such error? Maybe
      socket.SOMAXCON N could help me?
      >
      Here you get out of file descriptors, I dont think SOMAXCONN would help.
      >
      Under Linux (maybe Unix), there is ulimit -n nnn to setup the maximum
      number of files descriptors. I don't know its upper limit (maybe a
      kernel compile time information).
      A shell command

      ulimit -Hn

      should report on the hard-limit of the number of open file descriptors;
      just ulimit -n should report on the current soft-limit.

      If you're going to pass the fd's to select, as asyncore does by default,
      a separate limit of 1024 is unfortunately likely to apply anyway; so,
      once that ulimit is raised, you may want to pass argument use_poll as
      true to asyncore.loop. The performance of poll with a huge number of
      sockets may however not be all that shiny. Better mechanisms, such as
      epoll or kqueue, I believe, are not available for asyncore, even if your
      OS supports them; to serve thousands of open sockets with good
      performance, you may need to switch to Twisted (which offers many more
      implementations of the abstract Reactor interface -- you don't _have_ to
      use Twisted's higher layers if you don't want to).


      Alex

      Comment

      • John Nagle

        #4
        Re: How many connections can accept a 'binded' socket?

        billiejoex wrote:
        Hi,
        I'm writing a small asyncore-based server application serving a lot of
        clients. When I have to handle more than 1021 client simoultaneously
        the 'binded' socket object raises an error:
        When you ask questions like this, please specify what
        operating system you're using. Thanks.

        John Nagle

        Comment

        • billiejoex

          #5
          Re: How many connections can accept a 'binded' socket?

          On 20 Mar, 17:44, John Nagle <n...@animats.c omwrote:
          When you ask questions like this, please specify what
          operating system you're using. Thanks.
          That was a Linux Ubuntu 6.10. I submitted a bug report on sourceforge:



          Alex Martelli wrote:
          A shell command
          ulimit -Hn
          should report on the hard-limit of the number of open file descriptors;
          just ulimit -n should report on the current soft-limit.
          Thank you, I'll try it.

          Comment

          Working...