# Dual instances with loadbalancing

**URL:** <https://community.wowza.com/t/dual-instances-with-loadbalancing/39409>\
**Category:** Wowza Streaming Engine\
**Created:** [July 22, 2014, 6:56pm UTC](https://community.wowza.com/t/dual-instances-with-loadbalancing/39409 "2014-07-22T18:56:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Olsson](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@Christian\_Olsson](https://community.wowza.com/u/Christian_Olsson)\
**Post date:** [July 22, 2014, 6:56pm UTC](https://community.wowza.com/t/dual-instances-with-loadbalancing/39409/1 "2014-07-22T18:56:50Z")

</div>

We have a server with a 10Gb nic and we want to fully utilize that capacity by using two instances of wowza streaming engine, but my question is regarding how to do it.

To start with i want to have one of the instances to have an origin application with loadbalancerlistener and transcoding enabled + an edge application with loadbalancersender pulling from the origin application on the same instance.

Then i want the second instance to just have an edge application with loadbalancersender pulling from the origin on the first instance.

So i am wondering do i have to have separate ip addresses for the instances since the loadbalancer addon communicates via port 1934 or can it be done in another way?

And the second question is do i still have to copy smil files to the second instance even though everything is on the same physical server, and is there a way to automatically generate a SMIL file when a stream is published to the server?

Also, which way is best to use loadbalancer with Jw player when you are only streaming though HLS: “Get least loaded server using http” or “Get least loaded server using Netconnection redirect”?

And is there any example code of how to use the loadbalancer while using Jw player?

thanks in advance!

---

<div class="post-metadata">

**Author:** ![Matt\_Young](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/matt_young/32/389_2.png) [@Matt\_Young](https://community.wowza.com/u/Matt_Young)\
**Post date:** [July 23, 2014, 3:46am UTC](https://community.wowza.com/t/dual-instances-with-loadbalancing/39409/2 "2014-07-23T03:46:14Z")

</div>

If you run [multiple instances](https://www.wowza.com/docs/how-to-run-multiple-instances-of-wowza-media-server-on-one-computer)on one server you will want to split them up by IP address of which you can designate within your VHost.xml configuration file on each respective instance. Your load balancer configuration setup seems sound and you can have both instances report (as a sender) to the first instance load balancer listener over 1934.

To obtain the least loaded edge via http, you might checkout [this forum post](https://www.wowza.com/forums/showthread.php?36691-Please-share-Load-Balancer-code-snippet&p=138147#post138147) for some guidance.

Thanks,

Matt

---

<div class="post-metadata">

**Author:** ![Christian\_Olsson](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@Christian\_Olsson](https://community.wowza.com/u/Christian_Olsson)\
**Post date:** [July 30, 2014, 11:36am UTC](https://community.wowza.com/t/dual-instances-with-loadbalancing/39409/3 "2014-07-30T11:36:07Z")

</div>

okay so i ran into a problem with the setenv.bat file, when running 2 instances you have to modify this file but i dont quite understand how to do it.

The code looks like this:

@echo off

set \_EXECJAVA=java

rem Setting of JAVA\_OPTS has moved to conf/Tune.xml

set EXECCSCRIPT=cscript

if not exist “%SystemRoot%\SysWOW64\cscript.exe” goto skip64bitcscript

set EXECCSCRIPT="%SystemRoot%\SysWOW64\cscript.exe"

:skip64bitcscript

set WMSENVOK=“false”

rem Guess WMSAPP\_HOME if not defined

set CURRENT\_DIR=%cd%

if not “%WMSAPP\_HOME%” == “” goto gotAppHome

set WMSAPP\_HOME=%CURRENT\_DIR%

if exist “%WMSAPP\_HOME%\bin\startup.bat” goto okAppHome

cd …

set WMSAPP\_HOME=%cd%

cd %CURRENT\_DIR%

:gotAppHome

if exist “%WMSAPP\_HOME%\bin\startup.bat” goto okAppHome

if “%~1”==“service” (

echo setenv.bat: The WMSAPP\_HOME environment variable is missing or not defined correctly: “%WMSAPP\_HOME%”. This environment variable is needed to run the server. \>\> batch.log

) else (

%EXECCSCRIPT% “displaymsg.vbs” “The WMSAPP\_HOME environment variable is missing or not defined correctly (%WMSAPP\_HOME%). This environment variable is needed to run the server.”

)

goto end

:okAppHome

rem Guess WMSCONFIG\_HOME if not defined

set CURRENT\_DIR=%cd%

if not “%WMSCONFIG\_HOME%” == “” goto gotConfigHome

set WMSCONFIG\_HOME=%WMSAPP\_HOME%

if exist “%WMSCONFIG\_HOME%\conf\Server.license” goto okConfigHome

cd …

set WMSCONFIG\_HOME=%cd%

cd %CURRENT\_DIR%

:gotConfigHome

if exist “%WMSCONFIG\_HOME%\conf\Server.license” goto okConfigHome

if “%~1”==“service” (

echo setenv.bat: The WMSCONFIG\_HOME environment variable is missing or not defined correctly: “%WMSCONFIG\_HOME%”. This environment variable is needed to run the server. \>\> batch.log

) else (

%EXECCSCRIPT% “displaymsg.vbs” “The WMSCONFIG\_HOME environment variable is missing or not defined correctly (%WMSCONFIG\_HOME%). This environment variable is needed to run the server.”

)

goto end

:okConfigHome

if “%~1”==“service” (

if “%JAVA\_HOME%”=="" (

echo setenv.bat: JAVA\_HOME is not set. “%JAVA\_HOME%” \>\> batch.log

goto end

)

if NOT EXIST “%JAVA\_HOME%\bin\java.exe” (

echo setenv.bat: JAVA\_HOME is set incorrectly?. “%JAVA\_HOME%” \>\> batch.log

goto end

)

echo setenv.bet: JAVA\_HOME is: “%JAVA\_HOME%” \>\> batch.log

) else (

%EXECCSCRIPT% “checkjavahome.vbs” //Nologo

if not %errorlevel% == 0 goto end

)

set WMSENVOK=“true”

set \_EXECJAVA=%JAVA\_HOME%\bin\java.exe

:end

and as i understand it i want to change WMSAPP\_HOME and WMSCONFIG\_HOME so it points to the new instance (C:\Program Files (x86)\Wowza Media Systems\Wowza Instance 2). how exactly do i do that?

i have read this guide: [https://www.wowza.com/docs/how-to-run-multiple-instances-of-wowza-media-server-on-one-computer](https://www.wowza.com/docs/how-to-run-multiple-instances-of-wowza-media-server-on-one-computer) but as i said i dont quite understand how to change theese two pointers anyway

thanks in advance

---

<div class="post-metadata">

**Author:** ![Christian\_Olsson](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@Christian\_Olsson](https://community.wowza.com/u/Christian_Olsson)\
**Post date:** [July 30, 2014, 8:02pm UTC](https://community.wowza.com/t/dual-instances-with-loadbalancing/39409/4 "2014-07-30T20:02:47Z")

</div>

yes thank you, that worked great, now i am having some trouble with the wowza streaming engine manager though, this guide is outdated with regards to it: [https://www.wowza.com/docs/how-to-run-multiple-instances-of-wowza-media-server-on-one-computer](https://www.wowza.com/docs/how-to-run-multiple-instances-of-wowza-media-server-on-one-computer) is it possible to run 2 separate managers, one for each instance? if so, how do i configure that, i have tested but i only get one to work myself?

---

<div class="post-metadata">

**Author:** ![Christian\_Olsson](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@Christian\_Olsson](https://community.wowza.com/u/Christian_Olsson)\
**Post date:** [August 1, 2014, 3:38pm UTC](https://community.wowza.com/t/dual-instances-with-loadbalancing/39409/5 "2014-08-01T15:38:36Z")

</div>

Never mind, solved it, when i tried to assign them to specific ip addresses it gave me lots of java errors, so i kept the “\*” for the ip address property and gave them unique ports instead

---

<div class="post-metadata">

**Author:** ![Matt\_Young](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/matt_young/32/389_2.png) [@Matt\_Young](https://community.wowza.com/u/Matt_Young)\
**Post date:** [July 30, 2014, 5:56am UTC](https://community.wowza.com/t/dual-instances-with-loadbalancing/39409/6 "2014-07-30T05:56:13Z")

</div>

You will want to define something similar to the following at the top of that script under “@echo off” as follows:

```auto
@echo off
set WMSAPP_HOME=C:\Path\to\WowzaMediaserver-instance2
set WMSCONFIG_HOME=C:\Path\to\WowzaMediaserver-instance2
... Rest of .bat file to follow...

```
