Cluster Extension deployment
Extension deployment in SmartFoxServer 2X is managed in a very simple way: pack your Extension code in a jar file and upload it to the server via the AdminTool. The server will either auto-reload the code or wait for a manual trigger. Very straightforward.
However when working in a cluster environment things become more complicated due to the multiple servers to update. Let's consider this scenario, based on the multi-game example we have already used:
- We have the Lobby Node running its own Extension for login and other user profile services.
- There are multiple Game Nodes each supporting different games, hence multiple Extensions are available to be loaded at runtime for every Game Room.
- We have server snapshots containing the disk image to be used when launching new Game Nodes.
As you can see there are many aspects that come into play when it's time to update the server-side code. Let's check them one by one and find out a good strategy to update our cluster.
Updating the Lobby Node Extension is as easy as in standalone mode: we can upload the new jar file which replaces the old code and then trigger the update. This can be done in the Extension Manager module of the AdminTool.
Where things get a bit more complicated is with the global update of all Game Nodes in the system: here we presumably have thousands of games already running, and those can't be stopped.
Ideally we should be able to let the old games run until the end while we update the Extension. When this is done, new Game Rooms will load the latest server code and, for a while, we will have a mix of old and new games running side by side.
The concept of old and new Extension coexisting while old Game Rooms complete their life-cycle is not new in SmartFoxServer. In fact it is common in many server solutions, clustered or not. In the specific case of the Overcast Cluster we must keep in mind that new Game Nodes are spun up from an existing server snapshot, which also needs to be updated, otherwise new instances will join the cluster running the code.
Updating the Game Extensions in the Overcast Cluster entails two main steps:
- Update the current Game Node snapshot:
- Launch a Game Node with the current server snapshot, and flag it as standalone so that it doesn't join the cluster.
- Update the Game Extensions on the standalone server.
- Create a new snapshot from the modified server.
- Point the Cluster Lobby to the new snapshot just created.
1. Update the current Game Node snapshot
We want to start from the current snapshot and update it with our new Extension code. To do so we need to create a separate server that doesn't join the cluster. This is described in the previous Launching a cluster chapter.
An even better solution is to create the server once and leave it up so that it's ready at any time we need to update our snapshots without the need to launch a server every time.
Next we update our Extension(s) on the standalone server via the AdminTool, as with every other SmartFoxServer instance. If you need help with this step we recommend checking the SFS2X official documentation.
Once the changes have been applied to the standalone server, it's time to create a new snapshot. Finally we can associate the Lobby with the new snapshot by going to the server list, clicking the [Actions] icon near the Lobby Node and selecting the Edit option.
From this dropdown select the newly created snapshot and apply the changes.
2. Update live servers via the AdminTool
When running in a cluster, the SFS2X AdminTool provides new tools to manage the system, including a multi-deploy tool that helps updating any number of servers at once.
After having logged in the Lobby Node you will find three new icons on the top navigation. Click the Extension Deployer icon.
Here we can upload a zip file containing all the jar and resources to the main extensions/ folder of each selected server. We can also choose a destructive vs non-destructive upload: the former replaces the content of existing subfolders entirely while the latter merges them, which is the default.
For more information on how the Extension Deployer works we recommend consulting the dedicated Administration section.