LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-14-2010, 07:56 AM   #1
dorian33
Member
 
Registered: Jan 2003
Location: Poland, Warsaw
Distribution: LFS, Gentoo
Posts: 591

Rep: Reputation: 32
handling mass simultaneously connections


1. I wrote the tcp client which forks 100 times.
Each subprocess holds on pause(...) waiting for signal.
Afer receiving SIGHUP it continues and
a) connects to the server
b) sends 10 bytes
c) receives data form sockets
d) closes the sock

2. On the other side (another host) I wrote the server which does the following:
a) prepares listening socket
b) calls epoll_create(...) and epoll_ctl(...,EPOLL_CTL_ADD, listening_sock,...)
c) starts the infinite loop where the rest of tcp connetion(s) is done using epoll_wait(....)

The whole server code is similar to the sample from http://zhoulifa.bokee.com/6081520.html with translation from: http://translate.google.com/translat...m/6081520.html

The problem is that at the client host I can see a lot of sockets with 'SYN_SENT' status
but on the server side after fast receving (and servicing) about 40 requests the server "sometimes" handles the next one(s).
"Sometimes" means 2-3 requests per seconds.

If I decrease the number of forked clients to 10 averything is ok.
I'm am stuck now. I don't know where to look the reason...

Last edited by dorian33; 04-14-2010 at 08:09 AM. Reason: typo
 
Old 04-14-2010, 09:20 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
It's really probable a better idea to "accept()" your connections one at a time, in a single thread.

Once the connection is established, *then* you can fork off a separate process or spawn a separate thread.

Handling multiple connections in parallel is OK. Trying to parallelize the "accept()" itself probably isn't.

IMHO .. PSM

PS:
Double-check the "backlog" parameter in your server's "listen()". But I doubt "backlog" is either the problem, or changing it the solution:
Quote:
http://linux.die.net/man/2/listen

The behaviour of the backlog parameter on TCP sockets changed with Linux 2.2. Now it specifies the queue length for completely established sockets waiting to be accepted, instead of the number of incomplete connection requests. The maximum length of the queue for incomplete sockets can be set using the tcp_max_syn_backlog sysctl. When syncookies are enabled there is no logical maximum length and this sysctl setting is ignored. See tcp(7) for more information.
PS:
This is off-topic, but my sincere condolences to you, and all your fellow Poles for the tragedy that happened this weekend.

Last edited by paulsm4; 04-14-2010 at 09:21 AM.
 
Old 04-14-2010, 10:54 AM   #3
dorian33
Member
 
Registered: Jan 2003
Location: Poland, Warsaw
Distribution: LFS, Gentoo
Posts: 591

Original Poster
Rep: Reputation: 32
I've made some checks using different techniques:
a) server with preforked processes
b) server with select
c) server with epoll_wait.

For the first time both server and client(s) were working on the same host on 127.0.0.1.
I've measured the execution time of the request-answer for each client and.
The most important for me was the maxtime - the execution time of the slowestly handled request.

The results are below.
1. the best results were with epoll_wait
2. all processes finished with resonable max time and looked like the epoll_wait worked as expected (no "hanging" client's SYN_SENT existed)

Next I transferred the server program to another host and ... the problems appeared.

Same was with server based on preforked processes. (Thread techniques was not tested by me but I believe it shows the same problems).

So, in my opinion the problem is somewhere else rather than in the program concept.

The backlog value used in listen is 2000 and the /proc/sys/net/core/somaxconn is 10000.

Now I am testing 1000-times-forked client and the problem still exists.

Any other suggestions?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ethernet internet and wireless adhoc printer connections simultaneously RVF16 Linux - Networking 4 11-18-2011 01:25 AM
use simultaneously two network connections nima0102 Linux - Networking 4 10-28-2007 05:47 PM
Two users on 1 PC simultaneously (with X) technobeast Linux - Newbie 1 07-10-2004 06:24 AM
Handling several USB mass storage devices? KlaymenDK Mandriva 3 06-30-2004 11:04 AM
How do I open a second X simultaneously? bruno buys Linux - Software 12 04-05-2004 12:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration