IAX2 Performance

As a part of the latest Asterisk security release, the IAX2 channel driver in Asterisk got various changes to make it more difficult to abuse IAX2 in Asterisk in a traffic amplification attack. IAX2 uses call numbers to specify which packets are associated with which call. One of the changes that I made for the security issue was to have Asterisk randomly choose call numbers where it previously chose the lowest one that it could.

This change had an unfortunate side effect. It highlighted a part of chan_iax2 that was extremely inefficient. The higher the call number, the worse this piece of code performed. By choosing a very high call number, the performance of the server would plummet. On a small embedded platform, this may have meant that it couldn’t handle a single call. On my Intel Core 2 Duo machine @ 2.33 GHz, this meant that I couldn’t handle much more than about 16 IAX2 channels. That is terrible.

So, this got me motivated to fix up this code once and for all. I reworked some of the IAX2 code in Asterisk to index calls in a hash table in such a way that the lookup that previously had such terrible performance could be performed very quickly.

Testing my new code against chan_iax2 with my security fixes yielded a 3600% concurrent IAX2 channel increase! However, even when compared with the code before the security fixes, the IAX2 channel driver is still able to handle a lot more calls. On my machine, the most recent code can handle 55% more concurrent IAX2 channels than the code could handle before the security changes.

Asterisk 1.4.20 will contain these changes. Normally I would not put enhancements like this in the 1.4 release version of Asterisk. However, this was a special situation. So, enjoy!

There has been criticism of IAX2 performance in the past. However, during the 1.4 release series, I have put a lot of work into re-doing a lot of data structure management. Most of the changes were inspired by bugs that came up, but had nice performance impacts as a beneficial side effect.

At this point, I can not see any reason that the IAX2 channel driver in Asterisk would perform any worse than SIP. It would be interesting to do some more IAX2 versus SIP comparisons with the most recent code. In Asterisk trunk, a lot of work has gone into the data structures supporting both protocols. All critical data structures have been carefully converted to be indexed in hash tables using the astobj2 object model. Not only are lookups much faster with the hash tables, but the astobj2 object model has a lot of very nice locking features which provide even more performance improvements.

Anyway, thank you all for your continued support of Asterisk!

3 thoughts on “IAX2 Performance

  1. Pingback: Asterisk Released

  2. IAX2 in Asterisk 1.4 is _VASTLY_ different than it is in Asterisk 1.2. None of the changes referred to here affect Asterisk 1.2.

    For anyone having IAX2 performance issues, please try the latest releases of Asterisk 1.4, or Asterisk 1.6 before giving up on it. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.