Results 1 to 6 of 6

Thread: changing maximum socket connecitons (SOMAXCONN)

  1. #1
    Join Date
    Feb 2009
    Beans
    15
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Question changing maximum socket connecitons (SOMAXCONN)

    Hi,
    I have a PHP socket server running on my UBUNTU server.

    I noticed that when I echo SOMAXCONN using PHP I get a result of 128, means that only 128 user can connect my chat server. With a google search I found

    sudo sysctl -a | grep somaxconn

    This command also prints out 128

    I tried to change max connectin capacity by sudo sysctl -w net.core.somaxconn=1024

    than I again sudo sysctl -a | grep somaxconn and saw that it looks ok and updated max conn number.

    STRANGE thing is when I try to echo SOMAXCONN with in PHP it still prints out 128 ?#!%&?


    What does this mean? May I beleive in linux or PHP? Which one is the real connection limit?

    I cannot try to connect with over 128 clients.

  2. #2
    Join Date
    Jun 2009
    Beans
    470
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: changing maximum socket connecitons (SOMAXCONN)

    somaxconn should be maximum parrallel opened sockets that the kernel will server at one time (correct me if I am wrong).

    the sysctl -w option take effect instantly, but you may need in some cases to restart
    the application server to observe the chages since sometimes they are cached

    Please note that after a reboot the value you have set using -w will be lost, in order
    to make the changes persistent you should add at the end of
    /etc/sysctl.conf this line: net.core.somaxconn=65535

    Note to developers: I have to admin that 128 is a low value for a server !

  3. #3
    Join Date
    Aug 2009
    Beans
    2

    Re: changing maximum socket connecitons (SOMAXCONN)

    this thread is so old i know but same problem i got here!

    i tried the sudo sysctl -w net.core.somaxconn=1024 and it works fine.

    but still PHP says SOMAXCONN = 128!
    echo SOMAXCONN
    print out 128

    any idea?

  4. #4
    Join Date
    Sep 2010
    Beans
    2

    Re: changing maximum socket connecitons (SOMAXCONN)

    Hallo if anyone steps over this comming from google like i did, here is the solution:

    php sets SOMAXCONN at the time it is compiled.

    1) apt-get install build-essentials
    2) vi /usr/include/bits/socket.h

    change
    #define SOMAXCONN 128
    in
    #define SOMAXCONN 2048

    3) compile new Version of php

    I have written a more substantial documentation
    in german language here:

    http://foobar.lamp-solutions.de/howt...mpilieren.html


  5. #5
    Join Date
    Aug 2009
    Beans
    2

    Re: changing maximum socket connecitons (SOMAXCONN)

    Quote Originally Posted by lygie View Post
    Hallo if anyone steps over this comming from google like i did, here is the solution:

    php sets SOMAXCONN at the time it is compiled.

    1) apt-get install build-essentials
    2) vi /usr/include/bits/socket.h

    change
    #define SOMAXCONN 128
    in
    #define SOMAXCONN 2048

    3) compile new Version of php

    I have written a more substantial documentation
    in german language here:

    http://foobar.lamp-solutions.de/howt...mpilieren.html


    lol! after 1 year i received a reply at this topic!
    thank youuuu!!!!

  6. #6
    Join Date
    Nov 2011
    Beans
    38

    Re: changing maximum socket connecitons (SOMAXCONN)

    Hello

    I use ubuntu 11.10 64 bit

    I increased net.core.somaxconn using sysctl

    but I can't see /usr/include/bits/..

    is that suppose to do change the value into socket.h ?

Tags for this Thread

Bookmarks

Posting Permissions

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