FAQ
I am trying to debug an issue with my TCP server that it seems it's only
able to accept 1K connections, and after that it can't accept more and
disconnects all connections, and starts going into this weird state.

I wrote a small app (another Go app) that spawns clients and connects to
the server running on localhost. Everything goes well if the number of
clients are < 1K. However, once I bumped it up, it starts failing right
around 1020, which is suspiciously close to 1024. I need to know if it's
my code, which seems more likely, or some weird bug with Go TCP, but at
this point my code hasn't done anything yet.

This is the simplified version of my TCP server:
http://play.golang.org/p/_EJ9oNZ0Cv

It's very simple. It listens to a port, new connection comes in, store the
net.TCPConn object in an array.

I wrote another go program that spawns clients
http://play.golang.org/p/fsEirFIUqR

Now, run the server, run the clients, and notice connections will start
failing around 1020.

Could somebody please explain why this is the case?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Dump Hole at Sep 3, 2015 at 4:18 am
    Server Output

    ...
    New conn: 127.0.0.1:45571. Total connections: 1004
    New conn: 127.0.0.1:45572. Total connections: 1005
    New conn: 127.0.0.1:45573. Total connections: 1006
    New conn: 127.0.0.1:45574. Total connections: 1007
    New conn: 127.0.0.1:45575. Total connections: 1008
    New conn: 127.0.0.1:45576. Total connections: 1009
    New conn: 127.0.0.1:45577. Total connections: 1010
    New conn: 127.0.0.1:45578. Total connections: 1011
    New conn: 127.0.0.1:45579. Total connections: 1012
    New conn: 127.0.0.1:45580. Total connections: 1013
    New conn: 127.0.0.1:45581. Total connections: 1014
    New conn: 127.0.0.1:45582. Total connections: 1015
    New conn: 127.0.0.1:45583. Total connections: 1016
    New conn: 127.0.0.1:45584. Total connections: 1017
    New conn: 127.0.0.1:45585. Total connections: 1018
    Error accepting new conn


    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Dustin at Sep 3, 2015 at 4:26 am
    What OS are you using? Some (like certain versions of Windows) have
    settings which by default limit the max # of connections.
    On Wednesday, September 2, 2015 at 9:16:07 PM UTC-7, Dump Hole wrote:

    I am trying to debug an issue with my TCP server that it seems it's only
    able to accept 1K connections, and after that it can't accept more and
    disconnects all connections, and starts going into this weird state.

    I wrote a small app (another Go app) that spawns clients and connects to
    the server running on localhost. Everything goes well if the number of
    clients are < 1K. However, once I bumped it up, it starts failing right
    around 1020, which is suspiciously close to 1024. I need to know if it's
    my code, which seems more likely, or some weird bug with Go TCP, but at
    this point my code hasn't done anything yet.

    This is the simplified version of my TCP server:
    http://play.golang.org/p/_EJ9oNZ0Cv

    It's very simple. It listens to a port, new connection comes in, store
    the net.TCPConn object in an array.

    I wrote another go program that spawns clients
    http://play.golang.org/p/fsEirFIUqR

    Now, run the server, run the clients, and notice connections will start
    failing around 1020.

    Could somebody please explain why this is the case?
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Dave Cheney at Sep 3, 2015 at 4:29 am
    Check ulimit -a, are there any limits set to 1k?

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Dump Hole at Sep 3, 2015 at 4:40 am
    Yup. open files

    open files (-n) 1024
    On Wednesday, September 2, 2015 at 9:28:55 PM UTC-7, Dave Cheney wrote:

    Check ulimit -a, are there any limits set to 1k?
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Gyu-Ho Lee at Sep 3, 2015 at 5:29 am
    sudo vi /etc/security/limits.conf;

    And add the following lines

    * soft nofile 120000
    * hard nofile 120000

    And log out and log in.
    This should increase the maximum number of open files in Ubuntu.
    But not sure about other OS.
    On Wednesday, September 2, 2015 at 9:40:01 PM UTC-7, Dump Hole wrote:

    Yup. open files

    open files (-n) 1024
    On Wednesday, September 2, 2015 at 9:28:55 PM UTC-7, Dave Cheney wrote:

    Check ulimit -a, are there any limits set to 1k?
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Buschini Edouard at Sep 3, 2015 at 7:10 am
    Hi,

    Try that thread [1] I had the same issue and it worked for me.
    I had to increase the ulimits from the security.conf and then tell directly
    the program to take as much as he can.

    [1]:
    http://stackoverflow.com/questions/17817204/how-to-set-ulimit-n-from-a-golang-program
    On Sep 3, 2015 7:29 AM, "Gyu-Ho Lee" wrote:

    sudo vi /etc/security/limits.conf;

    And add the following lines

    * soft nofile 120000
    * hard nofile 120000

    And log out and log in.
    This should increase the maximum number of open files in Ubuntu.
    But not sure about other OS.
    On Wednesday, September 2, 2015 at 9:40:01 PM UTC-7, Dump Hole wrote:

    Yup. open files

    open files (-n) 1024
    On Wednesday, September 2, 2015 at 9:28:55 PM UTC-7, Dave Cheney wrote:

    Check ulimit -a, are there any limits set to 1k?
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 3, '15 at 4:16a
activeSep 3, '15 at 7:10a
posts7
users5
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase