• How to run multiple instances of Wowza Media Server on one computer

    Sometimes it's better to run multiple instances of Wowza Media Server™ on a single computer rather than running one large instance with multiple virtual hosts. For example:

    • Available resources are wasted because they can't be used by a single instance.

    • Your streaming workflow involves a custom design that won't work using a single instance.

    • You're testing a multiple-server deployment on a single computer.

    This article describes how to run multiple instances of Wowza Media Server on one computer. All Wowza Media Server instances must be properly licensed.

    Note: For more information about how to install different versions of Wowza Media Server on the same computer, see How to install different versions of Wowza Media Server on one computer.

    Overview


    When running multiple instances of Wowza Media Server, each instance runs in its own Java Virtual Machine and is completely independent of the other instances. Each instance requires a license, either a Subscription license or Perpetual license. An instance is defined as a single copy of a running Wowza Media Server. You can use a Subscription license key for multiple instances and each instance will be counted separately and reflected in your bill.

    Note: If all that's required is to use separate virtual hosts (VHosts), then it's better and easier to do that than to configure multiple instances of Wowza Media Server. VHosts can be started and stopped on a running Wowza Media Server instance without affecting other VHosts. Each VHost uses its own configuration. For more information about how to configure multiple VHosts, see the "Virtual Hosting" chapter in the Wowza Media Server User's Guide.

    When running multiple instances of Wowza Media Server, each instance has its own memory allocation and like running multiple VHosts on a single instance, each VHost in each instance must be configured to bind to specific IP addresses or use unique ports. To get the required separation, we'll be making a copy of the entire current installation. Only a few files must be modified in order to to share common folders between installations using symbolic links (symlinks).

    This article assumes that you have a single installation of Wowza Media Server installed and configured. For more information about how to install and configure Wowza Media Server, see the Quick Start Guide.

    Configuration


    Note: The following procedure is based on a Linux Red Hat Package Manager (RPM) installation. Where it varies a great deal from a Windows installation, the differences are noted.

    1. Make sure that you're operating as root user and cd to the /usr/local directory.
      $ su root
      Password:
      # cd /usr/local
      # ls -al
      total 52
      drwxr-xr-x. 13 root  root  4096 Mar 29 11:39 .
      drwxr-xr-x. 14 root  root  4096 Mar  2 00:33 ..
      :
      :
      lrwxrwxrwx.  1 root  root   33 Mar 29 11:39 WowzaMediaServer -> /usr/local/WowzaMediaServer-3.6.1
      drwxr-xr-x. 14 root  root 4096 Mar 29 11:39 WowzaMediaServer-3.6.1 
      #
    2. Make a copy of your existing Wowza Media Server installation folder. Make sure that you copy the actual installation folder and not the symlink.
      # cp -r WowzaMediaServer-3.6.1 WowzaMediaServer-instance2
      
      #ls -al
      total 56
      drwxr-xr-x. 13 root  root  4096 Mar 29 11:39 .
      drwxr-xr-x. 14 root  root  4096 Mar  2 00:33 ..
      :
      :
      lrwxrwxrwx.  1 root  root   33 Mar 29 11:39 WowzaMediaServer -> /usr/local/WowzaMediaServer-3.6.1
      drwxr-xr-x. 14 root  root 4096 Mar 29 11:39 WowzaMediaServer-3.6.1
      drwxr-xr-x. 14 root  root  4096 Apr 24 16:09 WowzaMediaServer-instance2
      #
    3. In the existing installation, open the [install-dir]/conf/VHost.xml file in a text editor and configure each <HostPort> to use a unique IP address/port combination.
      # vi WowzaMediaServer/conf/VHost.xml
      #
      		<HostPortList>
      			<HostPort>
      				<ProcessorCount>4</ProcessorCount>
      				<IpAddress>192.168.1.119</IpAddress>
      				<!-- Separate multiple ports with commas -->
      				<!-- 80: HTTP, RTMPT -->
      				<!-- 554: RTSP -->
      				<Port>80, 443, 554, 1935</Port>
      				<SocketConfiguration>
      :
      			<!-- Admin HostPort -->
      			<HostPort>
      				<ProcessorCount>1</ProcessorCount>
      				<IpAddress>192.168.1.119</IpAddress>
      				<Port>8086</Port>
      				<SocketConfiguration>
    4. In the new installation, make the following changes:

      1. Make the same changes as above to [install-dir]/conf/VHost.xml and use a different IP address or different ports.
        		<HostPortList>
        			<HostPort>
        				<ProcessorCount>4</ProcessorCount>
        				<IpAddress>192.168.1.120</IpAddress>
        				<!-- Separate multiple ports with commas -->
        				<!-- 80: HTTP, RTMPT -->
        				<!-- 554: RTSP -->
        				<Port>80, 443, 554, 1935</Port>
        				<SocketConfiguration>
        :
        			<!-- Admin HostPort -->
        			<HostPort>
        				<ProcessorCount>1</ProcessorCount>
        				<IpAddress>192.168.1.120</IpAddress>
        				<Port>8086</Port>
        				<SocketConfiguration>
      2. Open the [install-dir]/conf/Server.xml file in a text editor and change the port number for the CommandInterface/HostPort. The port must be changed because this HostPort binds to all IP addresses.
                <Server>
                        <CommandInterface>
                                <HostPort>
                                        <IpAddress>*</IpAddress>
                                        <Port>18083</Port>
                                </HostPort>
                        </CommandInterface>
      3. If JMXRemoteConfiguration is enabled, change the ports for RMIConnectionPort and RMIRegistryPort. The port must be changed because JMX binds to all IP addresses.
                        <JMXRemoteConfiguration>
                                <Enable>true</Enable>
                                <IpAddress>localhost</IpAddress> <!-- set to localhost or internal ip address if behind NAT -->
                                <RMIServerHostName>localhost</RMIServerHostName> <!-- set to external ip address or domain name if behind NAT -->
                                <RMIConnectionPort>18084</RMIConnectionPort>
                                <RMIRegistryPort>18085</RMIRegistryPort>
      4. If necessary, open the [install-dir]/conf/Server.license file in a text editor and add a Subscription or Perpetual license key value to the list of license keys.

      5. Delete the files Admin.guid and Server.guid in [install-dir]/conf. These are unique identifiers that will be created automatically the first time that you start this Wowza Media Server instance.

      6. Open the [install-dir]/bin/setenv.sh file in a text editor and edit the settings for the WMSAPP_HOME and WMSCONFIG_HOME environment variables to point to the current installation.
        WMSAPP_HOME=/usr/local/WowzaMediaServer-instance2
        WMSCONFIG_HOME=/usr/local/WowzaMediaServer-instance2
        Note: On Windows operating systems, the file is named setenv.bat and the values are commented-out by default. Uncomment the values and set to the current installation path.
        set WMSAPP_HOME=C:/WowzaMediaserver-instance2
        set WMSCONFIG_HOME=C:/WowzaMediaserver-instance2

    5. Refer to the Performance Tuning Guide to tune each instance. Each instance must be tuned independently. Be sure to divide the CPU core count and memory evenly between each instance. For example, if running two instances, each instance should be tuned as if the server has 1/2 of the actual CPU cores and memory.


    If you're only going to run this second instance as a standalone server, then this is all that needs to be done. You can start your original instance of Wowza Media Server using ./startup.sh in the WowzaMediaServer/bin directory and you can start the second instance in a separate terminal window using ./startup.sh in the WowzaMediaServer-instance2/bin directory.

    Start both instances in separate terminal windows and check for errors. Bind errors are likely to occur if you have an IP address or port conflict.

    Running the new instance as a service

    To configure the new instance to start and run as a service, you must modify a copy of the service script:

    1. Make a copy of the existing service script.
      # cp /etc/init.d/WowzaMediaServer /etc/init.d/WowzaMediaServer-instance2
    2. Edit the new script file to reference the new installation.
      # define vars
      RETVAL=0
      WMSBASE_NAME=WowzaMediaServer-instance2
      #WMSCONFIG_SCRIPT="/etc/WowzaMediaServer/$WMSBASE_NAME.conf"
      WMSCONFIG_SCRIPT="/usr/local/WowzaMediaServer-instance2/bin/setenv.sh"
      WMSLICENSE_FILE="/usr/local/WowzaMediaServer-instance2/conf/Server.license"
    3. If the new instance should automatically start on reboot, run the following command to enable this.
      # chkconfig WowzaMediaServer-instance2 on

    Note: To configure the new instance to start and run as a service on Windows, you must update the service configuration in the [install-dir]/bin/WowzaMediaServer-Service.conf file:

    1. Open the WowzaMediaServer-instance2/bin/WowzaMediaServer-Service.conf file in a text editor and make the following changes.
      #********************************************************************
      # Wrapper Windows NT/2000/XP Service Properties
      #********************************************************************
      # WARNING - Do not modify any of these properties when an application
      #  using this configuration file has been installed as a service.
      #  Please uninstall the service before modifying this section.  The
      #  service can then be reinstalled.
      
      # Name of the service
      wrapper.ntservice.name=WowzaMediaServer-instance2
      
      # Display name of the service
      wrapper.ntservice.displayname=Wowza Media Server Instance 2
      
      # Description of the service
      wrapper.ntservice.description=Wowza Media Server Instance 2
      
      # Mode in which the service is installed.  AUTO_START or DEMAND_START
      wrapper.ntservice.starttype=DEMAND_START
    2. Install the service by double-clicking or running the WowzaMediaServer-instance2/bin/InstallWowzaMediaServer-Service.bat batch file.

    Originally Published: 05-14-2013.

    If you're having problems or want to discuss this article, post in our forum.