* Socket Server breaks after 1000 client requests
@ 2009-12-31 19:11 Dragoslav Zaric
2009-12-31 19:22 ` Ben Greear
0 siblings, 1 reply; 3+ messages in thread
From: Dragoslav Zaric @ 2009-12-31 19:11 UTC (permalink / raw)
To: netdev
Hi,
I wrote C++ Socket class. This class wraps methods both for client and server,
so you can create server or client depending what methods you call.
Anyway, all in all, problem is:
I have 3 small programs. One is server that listens in loop on port 30000.
Second is client program that sends one message to the server.
The third one on is small program (called spawn) that forks and
executes client program in limited for loop. So , idea is to simulate
a lot of connections to the server and see how many he can handle and
how.
So, at first I start server, execute spawn, and server gets client
messages. First I try 10 clients, then 100, then 1000 and it worked
Then I tried 10000 clients, and then it breaks just above 1000
clients, plus minus 100 !! So then I tried to put in server code 5
threads and mutex, but the result is same around 1000 clients and
breaks. Then I put semaphore, but then i realized that in this
scenario semaphores are of no use, because you can not sync with
random client events.
I also tried to change value in listen() method, but then I read
somewhere that maximum is 5 connections, which is default.
Does this problem requires some change in kernel code, or tcp/ip
stack, or the solution is simple, like reset server when it has first
break. I tried this last solution, but nothing happens.
So , does anyone have any idea?
Please help, I am working on this for days
thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Socket Server breaks after 1000 client requests
2009-12-31 19:11 Socket Server breaks after 1000 client requests Dragoslav Zaric
@ 2009-12-31 19:22 ` Ben Greear
2010-01-08 17:24 ` Dragoslav Zaric
0 siblings, 1 reply; 3+ messages in thread
From: Ben Greear @ 2009-12-31 19:22 UTC (permalink / raw)
To: Dragoslav Zaric; +Cc: netdev
On 12/31/2009 11:11 AM, Dragoslav Zaric wrote:
> Hi,
>
> I wrote C++ Socket class. This class wraps methods both for client and server,
> so you can create server or client depending what methods you call.
>
> Anyway, all in all, problem is:
This is likely some bug with your code..as I have code that easily handles
10k connections.
> I have 3 small programs. One is server that listens in loop on port 30000.
> Second is client program that sends one message to the server.
> The third one on is small program (called spawn) that forks and
> executes client program in limited for loop. So , idea is to simulate
> a lot of connections to the server and see how many he can handle and
> how.
Use non-blocking IO and poll() instead of forking for each client. 10k processes
are going to take almost any machine to it's knees.
>
> So, at first I start server, execute spawn, and server gets client
> messages. First I try 10 clients, then 100, then 1000 and it worked
> Then I tried 10000 clients, and then it breaks just above 1000
> clients, plus minus 100 !! So then I tried to put in server code 5
> threads and mutex, but the result is same around 1000 clients and
> breaks. Then I put semaphore, but then i realized that in this
> scenario semaphores are of no use, because you can not sync with
> random client events.
>
> I also tried to change value in listen() method, but then I read
> somewhere that maximum is 5 connections, which is default.
No, you can easily make this bigger, and default is 128 for somaxconn
echo -n "Increase somaxcon to 10000......................................... "
echo 10000 > /proc/sys/net/core/somaxconn
echo "DONE"
You should also let us know what you mean by 'it breaks'. What exactly breaks?
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Socket Server breaks after 1000 client requests
2009-12-31 19:22 ` Ben Greear
@ 2010-01-08 17:24 ` Dragoslav Zaric
0 siblings, 0 replies; 3+ messages in thread
From: Dragoslav Zaric @ 2010-01-08 17:24 UTC (permalink / raw)
To: Ben Greear; +Cc: netdev
Thanks Ben,
The error was definitely in my code. I used c++ functions for send and receive.
Now I am using write() and read() system calls to write and read
directly to sockets and
it works flawlessly ;)
When I am sending 100 000 messages in loop from client to server it goes for few
seconds.
regards,
dragoslav zaric
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-08 17:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-31 19:11 Socket Server breaks after 1000 client requests Dragoslav Zaric
2009-12-31 19:22 ` Ben Greear
2010-01-08 17:24 ` Dragoslav Zaric
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).