[asterisk-dev] Asterisk Performance as a B2BUA

Simon Perreault simon.perreault at viagenie.ca
Fri Nov 23 08:08:20 CST 2007


On Friday 23 November 2007 05:28:50 Vadim Lebedev wrote:
> I believe that it amounts to the same....
> When you use aio you simply using kernel-provided threads instead of you
> own threads.

I think you are confusing things. There are generally two ways of using 
threads:

1) A single thread handles all I/O. Nonblocking I/O is used for sockets, but 
disk I/O can still block.
2) One thread for each SIP socket. Blocking I/O is used. Cannot wait on 
multiple I/O at the same time.

To fix #1, you either use aio, or offload disk I/O to a secondary thread. In 
Asterisk's chan_sip, currently, we're in situation #1 and disk I/O (e.g. for 
logging) is offloaded to a secondary thread. If there was a lot of disk I/O 
(hint: there is not) it may not be 100% efficient because that single thread 
for disk I/O cannot queue multiple requests at the same time. That's why aio 
is superior: it can queue all I/O requests at the same time. And we cannot 
achieve the same performance as aio in user-space because we'd have to 
allocate one thread per disk I/O request, which would be very slow.

As I understood it, the proposition for creating a pool of threads handling 
SIP requests was to switch to situation #2, which has been proven by many 
sources (e.g. W. Richard Stevens, "UNIX Network Programming") to not be as 
efficient as #1.



More information about the asterisk-dev mailing list