expand my client code by goroutine, but failed

Showing 1-4 of 4 messages
expand my client code by goroutine, but failed dlin 11/10/11 6:01 PM
The full source on the attachment file. (See README.html on browser).
I've tried to add all error check on my code, but it occurs runtime error.

Here is my develop steps:

1. Create a server which could handle multiple connections by goroutine.
2. Build a client which works fine with simple protocol.
3. Expand the client to simulate multiple clients (with option -n=1000 clients as default)

I found this code is very unstable contains with three problems:

1. launch 1000 clients, one of them occurs a  EOF when reading from server.
2. launch 1050 clients, got too many open files soon (No any clients opened).
3. launch 1020 clients, got runtime error with long trace stacks.

        Start pollServer: pipe: too many open files
        panic: runtime error: invalid memory address or nil pointer dereference

        [signal 0xb code=0x1 addr=0x28 pc=0x4650d0]

Re: [go-nuts] expand my client code by goroutine, but failed Kyle Lemons 11/10/11 6:22 PM
1. launch 1000 clients, one of them occurs a  EOF when reading from server.

It's possible the server couldn't handle that many, or you filled up the server's accept buffer and the OS couldn't allow the connection to succeed
 
2. launch 1050 clients, got too many open files soon (No any clients opened).

I think this can happen if you open/accept too many connections too fast.  Normally you don't need a file descriptor per connection because of the pollserver, but certain operations do use a file descriptor along the way.
 
3. launch 1020 clients, got runtime error with long trace stacks.

Probably the same as #2. 
Re: [go-nuts] expand my client code by goroutine, but failed dlin 11/10/11 11:24 PM
Kyle, thanks your kindly reply.

> It's possible the server couldn't handle that many, or you filled up the server's accept buffer and the OS couldn't allow the connection to succeed

To modify this, I try to find listen(backlog), but can not find. 

So, I changed the client's code, let it delay for a while, it works. 

About Q2 and Q3 is there any method to let client prevent such error?
Re: [go-nuts] expand my client code by goroutine, but failed Kyle Lemons 11/11/11 4:06 PM
I have yet to see it happen in real usage cases, and I don't know what the best solution is if it does.
~K