Load Balancing
Last updated
Last updated
The features described on this page may not be available for all Wisej.NET Server license editions. For more details, please review the .
Wisej.NET applications are standard web applications that work seamlessly with load balancers.
However, Wisej.NET goes a step further and gives you additional features to manage the load across several servers. You can configure each server running a Wisej.NET application to accept a a maximum number of sessions, or to be available for the load balancer only if the CPU load is below a certain percentage and/or the memory usage is below a certain level.
Wisej.NET applications use WebSocket connections, which may require configuring your load balancer for TCP rather than HTTP routing. More details below.
Preparing Wisej.NET apps for load balancing mainly involves configuring healthcheck parameters. These determine when a server instance should return an error code signaling the load balancer to route requests elsewhere.
To configure healthcheck:
Use Add New Item and select Healthcheck from templates, or
Copy the configuration settings below, or
Download the default HealthCheck.json
Place the file in your application's root folder and set "Copy to Output Directory" to "Copy if newer". The file must be in the /bin
directory to be recognized.
Wisej.NET requires client requests to route consistently to the same server instance. Configure your load balancer to use either:
Sticky Sessions
Other routing that ensures user-server instance consistency
Some load balancers need TCP mode configuration for WebSocket connections. Reverse proxies like NGINX have built-in WebSocket support - see NGINX as a WebSocket Proxy.
Wisej.NET requires load balancer session affinity: each user/session must route to the same server. This typically uses:
Sticky session cookies
Client IP hash
Other consistent routing methods
Load balancers periodically verify server instance availability using a "healthcheck" URL. Options:
Custom HTML/ASPX page
healthcheck.wx
to verify Wisej.NET routing component status
Wisej.NET applications automatically respond to initial Default.html
(or subapplication URL) requests by either returning the page or returning "503 Service Unavailable" (configurable in HealthCheck.json
).
The following properties in HealthCheck.json
control server availability. Wisej.NET uses all configured properties in this order:
Maximum live sessions a Wisej.NET server can accept before refusing more. Returns "503 Service Unavailable" (or HTML page from Default.json
) to new users instead of risking server overload.
Set to 0
to disable this check.
Maximum memory percentage before returning "503 Service Unavailable". Example: Value 70
means the server returns 503 when memory usage is 70% or higher during main page request.
Set to 0
to disable this check.
Maximum CPU load percentage before returning "503 Service Unavailable". Example: Value 100
means the server returns 503 when CPU usage is 100% during main page request.
Set to 0
to disable this check.
HTTP status code returned by /healthcheck.wx
when server can't accept new sessions. Default is 503. See Status Code Definitions.
503: The server is currently unable to handle the request due to temporary overloading or maintenance. This condition should be temporary. If known, the delay length MAY be indicated in a Retry-After header. Without Retry-After, the client SHOULD handle the response as a 500 response.
Minutes value for the Retry-After
header sent with "503 Service Unavailable" response.
Note: Most load balancers currently ignore this header.
You can install a custom static method called by the healthcheck handler. Return true
if the server should be available to the load balancer, false
to return 503 (unavailable).
The IsServerAvailable
method can check any values to determine server availability: