NGINX RTMP broadcast optimizations

Profiling has shown the slowest part of the module is audio/video broadcasting. That was pretty obvious even before profiling but now I’ve got the numbers. To optimize the bottleneck output buffering model should have been slightly modified. Until now each output chain buffer (chunk) had it’s own reference counter. This approach suffers from a problem of re-zipping the chain (re-creating chain links) for each client which required additional per-client chain link allocations.

The new approach is much simpler than before. Each client has fixed-size output queue of chain references. Both buffer and chain links are never changed since creation. The refcounter is now associated with the whole chain and stored in -1 byte of chain link.

The work has been committed to optsend branch. It will be merged into master branch shortly.

Advertisements
  1. Leave a comment

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: