How can I multiple read() through multiple threads?

How can I multiple read() through multiple threads?

Post by Hongki Le » Sat, 18 Dec 1999 04:00:00



I have some socket questions about socket reading performance.

Is it possible below? (This is my first question.)

1. Two or more select() with each having a area socket id.

   1 thread has select() with socketid range 3~500
   2 thread has select() with socketid range 501-1000

2. 1 select() with multiple reading threads.

   1 thread has select() with whole socketid range(eg. 3-1024)

   2,3 threads have each reading operation from socketid queue
   that 1 thread put the socket id into it when select() occurs
   a reading event.

   (kind of thread pool.)

Finally, I wonder which method is faster.

   1. 1 thread reading with select()
   2. above no .1
   3. above no .2

   or another socket implementation methods that you know.

--
Hongki Lee.1107071-50071.http://www.chonga.pe.kr/

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

How can I multiple read() through multiple threads?

Post by Dan Kege » Sat, 18 Dec 1999 04:00:00



> I have some socket questions about socket reading performance.
> Is it possible below? (This is my first question.)

Welcome aboard...

Quote:> 1. Two or more select() with each having a area socket id.
>    1 thread has select() with socketid range 3~500
>    2 thread has select() with socketid range 501-1000

> 2. 1 select() with multiple reading threads.
>    1 thread has select() with whole socketid range(eg. 3-1024)
>    2,3 threads have each reading operation from socketid queue
>    that 1 thread put the socket id into it when select() occurs
>    a reading event. ...   (kind of thread pool.)

> Finally, I wonder which method is faster.
>    1. 1 thread reading with select()
>    2. above no .1
>    3. above no .2
>    or another socket implementation methods that you know.

A few thoughts:
On a multi-processor machine, you probably want to have more than
one thread (else you won't be using all the processors).
If you'll need to access the disk to serve the clients, you
probably want to have more than one thread (else you'll have
to wait for disk reads).
On some Unixes, poll() may be faster than select().
On Linux, you can go even faster by using SIGIO and asking for
extended signal info.  
See http://www.kegel.com/c10k.html

- Dan

--
(The above is just my personal opinion; I don't speak for my employer,
 except on the occasional talk show.)

 
 
 

1. Solution: multiple Apache log files, multiple args to env=, multiple conditions to CustomLog directive

Here is a solution to a problem I had a little while ago.  I wanted to
have Apache keep 3 separate log files: 1 for requests from me, a 2nd
for nimda virus attacks, and a 3rd for everything else.

The key to the solution was to use "!" to unset environment variables
in certain cases.  Joshua Slive pointed this out for me.

I'm posting this here because I can't find a way to use Google to
reply to those old posts of mine.

Here's an example that will log requests from a specific IP address
(presumably the webmaster's) to one file, and log nimda virus attacks
to another file.  A third log file will hold all the remaining
requests.

#========================================================================#
SetEnvIf Remote_Addr "w\.x\.y\.z" localaccess=1
SetEnvIf localaccess 1 dontlog

# Here, !localaccess will keep nimda requests out of the localaccess
log.
SetEnvIf Request_URI "^/scripts" nimda=1 !localaccess
SetEnvIf Request_URI "^/c/winnt" nimda=1 !localaccess
SetEnvIf Request_URI "^/_mem_bin" nimda=1 !localaccess
SetEnvIf Request_URI "^/_vti_bin" nimda=1 !localaccess
SetEnvIf Request_URI "^/MSADC" nimda=1 !localaccess
SetEnvIf Request_URI "^/msadc" nimda=1 !localaccess
SetEnvIf Request_URI "^/d/winnt" nimda=1 !localaccess
SetEnvIf nimda 1 dontlog

CustomLog logs/localaccess.log combined env=localaccess
CustomLog logs/nimda.log combined env=nimda
CustomLog logs/everythingelse.log combined env=!dontlog
#========================================================================#

I've received a couple emails about this problem, so I figure this
will help someone out.

-Anthony
www.nodivisions.com

2. Warning message when use new fonts in Netscape

3. Multiple r/w, Multiple read?

4. SuSE Xserver dead after install?

5. multiple threads read() problems

6. Changed ethernet address

7. multiple thread read() problems

8. continuous file transfers with FTP?

9. Linux gateway box hosting internet connection thru PPP for multiple machines

10. multiple OS's on multiple partitions

11. multiple NICs, multiple IP addresses?

12. multiple hosts and multiple ports in apache 1.1.1

13. How to control multiple server in multiple machines with a queue