Deployment Example (Server Farm)

In the previous section we deployed and ran a HyperServer instance under Linux. In this section we extend the example to support HyperServer server farm capability. Before proceeding, you may want to read the main topic regarding HyperServer server farm capabilities: https://unigui.com/doc/online_help/hyperserver-server-farm.htm

In a real-world scenario a server farm consists of several physical servers bound together to create a cluster. In this example we will create multiple instances of HyperServer on the same physical machine on different ports to emulate a server farm. In uniGUI terminology each slave HyperServer instance is called a ServerNode. We will create three ServerNodes which will be connected to a master HyperServer instance.

We will start tests in cluster mode-0 and later extend to mode-2. See Cluster Operation Modes for more details: https://unigui.com/doc/online_help/cluster-operation-modes.htm

Master HyperServer Configuration (Mode-0)

The master HyperServer instance will act only as a load balancer and won't serve web applications, so remove all references to applications in the CFG file. (If you are configuring a new instance from scratch this step is not needed.)

Before modifying the CFG file, make a backup of the existing CFG file so you can restore the settings made for the previous standalone example if needed: https://unigui.com/doc/online_help/deployment-example-(standalone.htm

First step is to set the default application to null:

[hyper_server]

binary_name=

Disable all previously configured applications by setting enabled to 0:

[application-0]

enabled=0

Next, configure slave ServerNodes:

[server-0]

enabled=1

url=http://localhost:8077

name=ServerNode-A

cluster_mode=0

token=

[server-1]

enabled=1

url=http://localhost:8078

name=ServerNode-B

cluster_mode=0

token=

[server-2]

enabled=1

url=http://localhost:8079

name=ServerNode-C

cluster_mode=0

token=

Our slave ServerNodes will run on ports 8077, 8078 and 8079. The master server runs on port 88.

For now leave the token parameter blank. You will set its value in the next step. The token is needed so the master HyperServer control panel can display slaves' control panels directly without logging in.

Slave ServerNodes Configuration

Each ServerNode will be configured to run a specific application. In this example ServerNodes will run under subfolders inside the main folder /hyper_server. Name the three folders:

  • server_node_a

  • server_node_b

  • server_node_c

Copy the executable binary named hyper_server to all of these folders. After copying, you may temporarily run each binary to automatically create the CFG file. The automatically created CFG file will contain a randomly generated token parameter which you must copy to the master hyper_server's CFG file to the corresponding token parameter. For example:

Repeat the above for each ServerNode to ensure all token parameters are properly configured.

1

ServerNode-A

ServerNode-A will run the application FishFacts as the default application. Its transport port will start on port 16484.

Copy the binary file named FishFacts to the sub-folder server_node_a.

2

ServerNode-B

ServerNode-B will run the application named paint.

3

ServerNode-C

ServerNode-C will run the application named action.

Running the Server Farm

Start by running the ServerNodes. Open a separate terminal window for each ServerNode, change to the corresponding subfolder, and run:

/hyper_server/server_node_a$ sudo ./hyper_server

(You may prefer a different way to run ServerNodes — for example, a batch file. In production, ServerNodes will run as Linux services. See Running HyperServer as a Linux Service: https://unigui.com/doc/online_help/running-hyperserver-as-a-linux.htm)

After running the ServerNodes, run the main HyperServer instance:

/hyper_server$ sudo ./hyper_server

Test the setup by opening the server control panel of the master HyperServer. Example images from the original documentation are linked below:

  • Master control panel showing all ServerNodes up and running: https://unigui.com/doc/online_help/clip0346.png

  • Control panel access via magnifier icon (Actions column): https://unigui.com/doc/online_help/clip0347.png

  • Control panel of a selected ServerNode (examples): https://unigui.com/doc/online_help/clip0348.png and https://unigui.com/doc/online_help/clip0349.png

Test the individual apps through the master server (replace as appropriate):

  • http://:88 — main page: https://unigui.com/doc/online_help/clip0350.png

  • http://:88/action — action app: https://unigui.com/doc/online_help/clip0351.png

  • http://:88/paint — paint app: https://unigui.com/doc/online_help/clip0352.png

All apps should run as expected.

You can continue to the next step: testing this setup in Mode-2 of HyperServer deployment: https://unigui.com/doc/online_help/hyperserver-server-farm-mode-2.htm