Tune Wowza Streaming Engine for optimal performance

This article explains methods for tuning Wowza Streaming Engine™ media server software for optimal performance on your hardware configuration.

Access Wowza Streaming Engine performance tuning


In Wowza Streaming Engine Manager, click the Server tab at the top of the page, and then click Performance Tuning in the contents panel.

The Performance Tuning page shows the server's OS architecture, amount of memory available to Wowza Streaming Engine, the number of core processors on the system, and the Java version and architecture (bitness) in use.

The contents panel also provides access to a host of performance tuning options, including Java settings, server thread pools, and virtual hosts.

Tune Java settings

By default, Wowza Streaming Engine 4.2.0 (and later) installs with a supported version of Java and is tuned to a development state optimized for the hardware on which it's running. The server can be tuned to a production level by adjusting the Java settings. Knowing that the server is running to the best of its ability makes Wowza Streaming Engine easy to deploy in a production environment. Advanced users can alter the tuning further, if required.

Note: If you're running Wowza Streaming Engine 4.1.2 or earlier, or Wowza Media Server™ 3 software, you'll get best results if you run the most recent Oracle Java Development Kit (JDK). The best option is to run a 64-bit OS with the 64-bit Java VM, which enables Java heap sizes greater than 2 GB. For details, see Manually install and troubleshoot Java on Wowza Streaming Engine.
  1. Click Java Settings in the contents panel.

The Java Settings page shows the current Java settings, including the Java Heap Size, which is the amount of memory allocated to Wowza Streaming Engine, and the Java Garbage Collection Settings.

  1. To change these settings, click Edit, and click Save after making changes to any of the following settings:

Java Heap Size

The default for the Java Heap Size is the Development level. To run a dedicated server in a production environment, change the Java Heap Size setting to the Production level.

If your server runs other services that have high memory consumption, you may want to change the Java Heap Size setting to the Custom level and enter a specific value. If you're running the 64-bit version of the Java VM and have 4 GB or more of RAM in your computer, set your Java heap size to between 3000 MB to 5000 MB. If you have at least 16 GB of RAM, set your heap size to 8000 MB. Don't set your heap size above 10 GB as this can lead to long garbage collection cycles/pauses.

Java Garbage Collection Settings

Garbage collection (GC) tuning in Java is tricky. What works best in one server setup may not work in another. Through trial-and-error and customer feedback, we recommend several approaches.

G1 (Garbage First) collector – We recommend that you use the default tuning G1 (Garbage-First) collector, which works well for many streaming situations and doesn't require modification. The G1 collector is designed for low pause time, high-throughput applications. It's a server-style garbage collector targeted for multi-processor computers with large memories, and it's fully supported in Oracle JDK 7 Update 4 and later releases.

Note: You can adjust the pause time for the G1 collector in Custom collector settings. The following is an example of a suggested custom setting:

-XX:+UseG1GC -XX:MaxGCPauseMillis=100

Concurrent collector – The Concurrent collector option is designed for applications that prefer shorter GC pauses and that can share processor resources with the garbage collector while the application is running.

Note: If you experience problems with the Java heap, such as a build-up of memory usage, you can specify custom garbage collection settings for the concurrent collector in Custom collector settings. The following is an example of a suggested custom setting:

-XX:+UseConcMarkSweepGC -XX:NewSize=512m

The NewSize value varies based on Java heap size:
 
  • If Java heap size is 5000 MB or greater, NewSize=512m.
  • If Java heap size is 3000 MB to 5000 MB, NewSize=256m.
  • If Java heap size is less than 3000 MB, NewSize=128m

NUMA-aware allocator (Custom collector settings) – A NUMA-aware allocator enables performance optimization of an application on computers with non-uniform memory architecture (NUMA) by increasing the application's use of lower latency memory. These are typically computers with multiple physical CPU sockets. By default, this option is disabled and no optimization for NUMA is made. The option is only available when the parallel garbage collector is used (-XX:+UseParallelGC).

For example, to enable NUMA optimization on a multi-CPU socket system, enter the following in Custom collector settings:

-XX:+UseParallelGC -XX:+UseNUMA

Monitor GC pause times

To monitor GC pause times, open [install-dir]/conf/Tune.xml in a text editor and then add the following <VMOption> property:

<VMOptions>
	<VMOption>-server</VMOption>
	<VMOption>-Djava.net.preferIPv4Stack=true</VMOption>
	<VMOption>-verbose:gc -Xloggc:"${com.wowza.wms.AppHome}/logs/gc_${com.wowza.wms.StartupDateTime}.log" -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime</VMOption>
</VMOptions>

Then restart the Wowza Streaming Engine server to apply the changes.

Notes:
  • This property is provided on line 33 in the Tune.xml file. You can remove the comment marks that surround the property to add it.
  • On Windows, this property creates a log file for debugging purposes and shouldn't be left running. The gc_${com.wowza.wms.StartupDateTime}.log file is only created when starting Wowza Streaming Engine in service mode or if using the command line.

Tune server thread pools


Click Server Thread Pools in the contents panel. The Server Thread Pools page shows the current Handler Thread Pool Size and Transport Thread Pool Size.



To change these settings, click Edit. When left at Set automatically, Wowza Streaming Engine calculates the Handler Thread Pool Size and Transport Thread Pool Size as follows:

Handler Thread Pool Size = 60 x Processor Cores

Transport Thread Pool Size = 40 x Processor Cores

Note: The Processor Cores value appears on the Performance Tuning page.

Tune Media Cache


Click Media Cache Tuning in the contents panel. Media Cache Tuning settings apply to VOD Edge applications. They include the current Writer Thread Pool, Readahead Thread Pool, Maximum Pending Write Request Size, and Maximum Pending Readahead Request Size.



To change these settings, click Edit. When left at Set automatically, Wowza Streaming Engine calculates the Writer Thread Pool and Readahead Thread Pool as follows:

Writer Thread Pool = 2 x Processor Cores

Readahead Thread Pool = 1 x Processor Cores

Maximum Pending Write Request Size and Maximum Pending Readahead Request Size are calculated based on the Java Heap Size.

Java Heap Size 1200 MB to 3999 MB 4000 MB to 7999 MB 8000 MB or greater
Maximum Pending Write Request Size 160 MB 500 MB 1000 MB
Maximum Pending Readahead Request Size 80 MB 250 MB 500 MB

Tune virtual host processors


Click Virtual Host Processors in the contents panel. The Virtual Host Processors page shows the number of threads used at the VHost level to service various types of connections.



To change the settings, click Edit. When left at Set automatically, Wowza Streaming Engine calculates the values as follows:
 
Net Connections Processor Count = 2 x Processor Cores

Media Caster Processor Count = 2 x Processor Cores

Idle Worker Count = 2 x Processor Cores

Unicast Incoming Processor Count = 2 x Processor Cores

Unicast Outgoing Processor Count = 2 x Processor Cores

Multicast Incoming Processor Count = 2 x Processor Cores

Multicast Outgoing Processor Count = 2 x Processor Cores

The Client Idle Frequency is the time (in milliseconds) between idle events for Adobe Flash client connections. For basic on-demand streaming, 250 ms provides the best reliability-to-performance ratio. For live, low-latency streaming, 125 to 250 ms is better. If you aren't doing low-latency streaming, Client Idle Frequency can be increased to 500, which reduces CPU usage and allows more concurrent connections. Values between 1 and 1000 are supported.

The RTP Idle Frequency value is the time (in milliseconds) between idle events for RTP connections. Values between 1 and 1000 are supported.

Tune virtual host ports


The Virtual Host Ports page shows the current open ports and the processor count associated with each port.



To change the settings, click Edit. When left at Set automatically, Wowza Streaming Engine sets the default processor counts as follows:
 
Port 1935 Processor Count = 2 x Processor Cores

Port 8086 Processor Count = 2 x Processor Cores

Tune virtual host thread pools


Click Virtual Host Thread Pools in the contents panel. Virtual Host Thread Pools are required when running multiple virtual hosts (VHosts) on the server.



If you're running multiple virtual hosts, configure the Handler Thread Pool Size and Transport Thread Pool Size to Use Server Settings. When configured to Use Server Settings, the handler and transport threads are divided equally between all of the active VHosts that are running on the server.

Additional tuning options


Optimize for low-latency chat applications

For low-latency chat applications, use smaller socket buffer sizes (16000 bytes for read and write). Socket buffer sizes are configured in [install-dir]/conf/VHost.xml:

<ReceiveBufferSize>32000</ReceiveBufferSize>
<SendBufferSize>32000</SendBufferSize>
To adjust these properties in Wowza Streaming Engine Manager:
 
  1. Click the Server tab at the top of the page.
  2. In the Server contents panel, click Virtual Host Setup.
  3. On the Virtual Host Setup page Properties tab, click Net Connctions in the Quick Links bar.
     
    Note: Access to the Properties tab is limited to administrators with advanced permissions. For more information, see Manage credentials.
  4. In the Net Connections properties area, click Edit, adjust the receiveBufferSize and sendBufferSize property values, and then click Save.
  5. Restart the virtual host when prompted to apply the changes.

CPU resource-based tuning

To tune Wowza Streaming Engine based on the available CPU resources of your server, use the following guidelines:

The [total-core-count] refers to the total number of CPU cores in your server. For example, if you have dual quad-core processors (two quad-core processors), your [total-core-count] is 8.

If your server supports hyper-threading, then use the total number of threads. If hyper-threading is available on a system with dual quad-core processors, for example, the total number of threads is:

2 processors x 4 cores x 2 threads per core = 16

With the number of cores and threads per physical processor continually growing, we suggest a maximum number of threads for each value below, which you can set in the configuration file [install-dir]/conf/VHost.xml:

HostPort/ProcessorCount: 2 x [total-core-count] (maximum of 24)

IdleWorkers/WorkerCount: 2 x [total-core-count] (maximum of 24)

NetConnections/ProcessorCount: 2 x [total-core-count] (maximum of 24)

RTP/UnicastIncoming/ProcessorCount: [total-core-count] (maximum of 12)

RTP/UnicastOutgoing/ProcessorCount: 2 x [total-core-count] (maximum of 24)

RTP/MulticastIncoming/ProcessorCount: [total-core-count] (maximum of 12)

RTP/MulticastOutgoing/ProcessorCount: [total-core-count] (maximum of 12)

HandlerThreadPool/PoolSize: (60 x [total-core-count]) (maximum of 480)

TransportThreadPool/PoolSize: (40 x [total-core-count]) (maximum of 320)
Note: Do not modify the HostPort ProcessorCount field in the Admin HostPort (/Port "8086").

These configuration calculations assume that you have at least 1 GB of memory per core or, if you have four or more total cores, that you're running the 64-bit Java VM, and that you're using the suggested memory settings above.

Tune for multiple virtual hosts

If you're running more than one virtual host (VHost), resource allocations must be distributed between each VHost. The simplest approach to running more than one VHost is to divide the settings listed in "CPU resource-based tuning," which are intended for a single VHost, and distribute the resources across each VHost on your system. The settings don't have to be evenly divided, however, the total should equal what you would allocate if you were configuring for a single VHost. If one of your VHosts is idle most of the time, you may allocate more memory than the combined total. Be careful with this setting because excessive allocations are risky. An out-of-memory error occurs if both VHosts exceed the combined, available resources.

Alternatively, in [install-dir]/conf/VHost.xml, you can set each VHost/HandlerThreadPool/PoolSize and VHost/TransportThreadPool/PoolSize property to 0, which causes the [install-dir]/conf/Server.xml settings for these properties to be used instead. This instructs Wowza Streaming Engine to manage the pool size across all VHosts.

A mixed approach can also be used with the [install-dir]/conf/VHost.xml file by setting the PoolSize properties to 0 for idle/minimal-use VHosts while using higher values for busy/high-performance VHosts with higher resource requirements.

Tune idle client system checks

If you aren't doing low-latency streaming and you have a client-side buffer of 3 or more seconds (NetStream.bufferTime), you can reduce the CPU load on the server and handle more concurrent sessions by changing the following values in [install-dir]/conf/VHost.xml:

IdleWorkers/CheckFrequency: 50
Client/IdleFrequency: 250