Resource Broker API Example 2
This example is a simple client/server program that demonstrates Resource
Broker's ability to increase throughput by load-balancing multiple servers.
The servers produce "units" at a configurable rate. The clients consume these
"units" at a configurable rate until they have obtained a specified amount. The
"units" can represent any real resource (compute power, transactions to a
database, memory, On-Demand video, etc). The method by which the client chooses
a server to request units from is configurable. It can do so by randomly
choosing a server, using Resource Broker to choose the best server (evaluated
on each call or every Nth call).
To build this example program, you must have DEC C++ V5.3 or greater.
If your workgroup includes both VAX and OpenVMS ALPHA systems in an OpenVMS
cluster, you need to build the example once for each platform, in a
directory which is commonly named, but is unique to each platform.
The easiest method is to build directly in the sys$examples location,
as shown:
Build on VAX:
$ set default sys$common:[syshlp.examples.rb.api.example2]
$ @Makefile_test2
Build on Alpha:
$ set default sys$common:[syshlp.examples.rb.api.example2]
$ @Makefile_test2
This will build the executables:
rb_consumer - the client program
rb_producer - the server program
Next, configure the Resource Broker services using the following command. (This
step only needs to be done on one platform, from the commonly named location.)
Note that you must have Resource Broker administrator privileges in order to
configure the services:
@rb_register rb_producer
You can run this application by simply running the client executable
(rb_consumer.exe) and this will cause a server to be started with default
values. Or, you can independantly start one or more servers and clients, using
the parameters described below to vary the behavior.
You should start at least two servers in order to allow Resource Broker to do
load balancing between the servers. The servers must be on different hosts. The
client can be started on the same node as a server or on a different host node.
Note: If you want to start servers or clients on other platforms, you must also
execute the platform-specific instructions to build the images on those
platforms and customize the service definition for those platforms.
Manual/detailed start instructions:
1) Start the server(s).
A server must be started by someone with the ability to make
Resource Broker configuration changes. It can be started by
simply typing "rb_producer" and default values will be used for all
variables. Otherwise, all variables must be entered on the
command line in the order shown below. The value in brackets
after each variable is the default.
$ rb_producer [interval] [amount_per_interval] [max] [update_mode]
interval: how often server creates new units (in seconds) [10]
amount_per_interval: how many units server creates each interval [10]
max: maximum number of units that can be available on server [100]
update_mode: if "manual" the server will update Resource Broker
data after every change. If "continuous" Resource Broker
will update automatically every 15 seconds. [manual]
2) Start the client(s).
Can be started by simply typing "rb_consumer" and default values will
be used for all variables. Otherwise, all variables must be
entered on the command line in the order shown below. The value
in brackets after each variable is the default.
$ rb_consumer [interval] [amount_per_interval] [desired] [threads] [method] [n]
interval: how often client requests units (in seconds) [5]
amount_per_interval: how many units client requests each interval [10]
desired: how many units client will try to obtain in total [500]
threads: how many client threads to start (a single executable
can be used to represent the load of multiple consumers) [1]
method: if "best" choose best server using resource broker.
if "random" choose server randomly. [Best]
n: Choice of server is re-evaluated after n calls [1]
After starting the desired number of clients and servers, you can use the
Resource Broker graphical user interface, rbgui, to monitor the load
balancing. Select the service "examples/api_test2" in the left pane of rbgui
and click on the monitor button. This will show a bar graph of all the servers
and how many units are avaliable on each. If your clients are configured to use
Resource Broker selection these bars will be load-balanced because a client
request is always handled by the best server.
You can also monitor how many insufficient units requests each server has had
by using rbgui to monitor the service "examples/api_test2_insufficient." The
bar graphs of this service represent the number of times that a server has not
been able to provide the clients with the number of units requested. Using
Resource Broker selection instead of random selction will reduce the size of
these bars.
Name Created Size Description
API2_SERVICES.TXT 17-Oct-1996 14:21 541 plain text
API_TEST2.H 5-Sep-1996 13:49 3,918 C header
MAKEFILE_TEST2.COM 21-Oct-1996 10:02 2,525 DCL procedure
RB_CONSUMER.CXX 16-Sep-1996 15:43 6,568 C++ source
RB_PRODUCER.CXX 2-Oct-1996 15:19 7,085 C++ source
RB_REGISTER.COM 4-Oct-1996 11:48 1,979 DCL procedure
README 9-Oct-1996 14:36 5,341 plain text
SKSTREAM.CXX 5-Sep-1996 13:27 8,992 C++ source
SKSTREAM.H 4-Sep-1996 10:09 2,537 C header
TIMER.H 17-Oct-1996 13:17 2,304 C header