In this article we are going to explore several ways to use the open source HAProxy load balancer in conjunction with SFS2X, to increase the scalability and availability of a multiplayer project.
We are going to show different configurations for TCP and Websocket connections and several ways to setup the system for common use cases.
To get the most out of this tutorial we require a basic knowledge of what a Load Balancer is and how it works, and some familiarity with the basics of networking and the OSI Model.
For those interested in running multiple SFS2X instances on the same machine we have a short guide on how to setup each server correctly avoiding port conflicts.
In particular since SFS2X 2.14 we have switched from Jetty to Tomcat for the HTTP-related services and our previous article on the same topic no longer applies.
We have a new white paper available for download in our documentation website, called “SmartFoxServer 2X and Hazelcast integration“.
This is an advanced paper discussing how to integrate an in-memory data grid with multiple SmartFoxServer instances to create a fault tolerant system. The paper takes our classic Tris game example and explores ways of scaling it horizontally with multiple servers and a centralized data store.
Additionally we discuss ways to tackle the load balancing and how to restart interrupted games.
We highly recommend that you’re already familiar with how the Tris game example works and also with out previous paper, SmartFoxServer 2X Server Architecture.