Developer Documentation Library > Interviewer - Server > Architecture > HTML players > Load balancing
 
Load balancing
When the Web Service needs to choose an interviewer session engine to run an interview, it asks two questions:
1 Is there a session engine available that already has this project loaded in memory? The general term for allocating interviews to engines in this way is project affinity.
2 Which engine has the lowest load percentage? (Project affinity is taken into account when calculating percent loaded.)
If project affinity is enabled (see Load balancing settings) and there is an engine with the project loaded in memory, the Web Service allocates the interview to this engine regardless of its loading. The reason is this. Each project takes a certain amount of memory, and each interview takes some additional amount of memory. If a project takes XMb of memory then if that project is loaded on only one server, it takes up only XMb of memory over the whole cluster. If that same project was loaded on two servers, it takes two lots of XMb over the whole cluster, leaving less memory for other projects.
If project affinity is not enabled, the Web Service starts each new interview using the interviewer session engine with the lowest load percentage at that time.
If the load percentage for all the registered session engines is greater than or equal to 100 percent, the Web Service issues an error message saying that the server is busy.
The Web Service uses the ISessionEngine interface to get the load percentage value from the session engine. You can customize the algorithm that calculates the load percentage by changing the load balancing script. See Load balancing interviewing engines for further details about session engine load balancing.
If a session engine fails while an interview is running on it, the Web Service reallocates the interview to the session engine with the lowest load percentage. An error is generated if there are no other session engines available.
Notes
External load balancing should be used in front of the servers (see Web Service tier). The web service tier is stateless, so requests can failover between web service tier instances. You can setup load balancing with an external load balancer by using URLs that depict different virtual directories, rather than simply using IP addresses for the different web sites. For example, you could load balance multiple mriWeb virtual directories by configuring the external load balancer to balance the load between http://server1/mrIweb1, http://server1/mrIWeb2, and so on.
UNICOM Intelligence automatically load-balances requests to the Interview Service tier for web surveys (load balancing). Failover is supported on the Interview tier, so if an interview tier server fails, the survey will automatically failover to the next least loaded interviewing engine.
See also
HTML players