Load Balancing sample (Delphi)
Overview
This sample demonstrates the usage of the Load Balancing and Fault Tolerance features. Both features are based on the client channel's ability to seamlessly switch the target server host, choosing one from the list of servers exposing the same remote service.
Getting Started
- Compile both projects.
- Launch four server applications (use the menu command
Tools -> Remoting SDK -> Launch Server Executable
) and activate different servers, e.g.Alfa Server
for the 1st server,Beta Server
for the 2nd and so on. - Ensure that
LoadBalancingClient
is the selected project and run it. - Fault tolerance: Deactivate some servers and see the client using another active server for remote requests.
- Load balance: Perform a remote request operation several times and see that every call is routed to a different active server.
- Server probing: Cause some server activity and probe a server (by clicking one of the
Probe
buttons) to check the server's availability and adjust the available servers list accordingly.
Examine the Code
-
Look for examples of using properties of the channel responsible for setting up Load Balancing and Fault Tolerance:
- DispatchOptions
- ProbeServers
- ProbeFrequency
- and especially ServerLocators.
procedure TClientForm.chkFaultToleranceClick(Sender: TObject);
begin
if chkFaultTolerance.Checked then
ROChannel.DispatchOptions :=
ROChannel.DispatchOptions + [doFaultTolerant]
else
ROChannel.DispatchOptions :=
ROChannel.DispatchOptions - [doFaultTolerant];
end;
procedure TClientForm.chkLoadBalancingClick(Sender: TObject);
begin
if chkLoadBalancing.Checked then
ROChannel.DispatchOptions :=
ROChannel.DispatchOptions + [doLoadBalanced]
else
ROChannel.DispatchOptions :=
ROChannel.DispatchOptions - [doLoadBalanced];
end;