且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

根据条件将流量路由到多个节点服务器

更新时间:2023-09-19 11:35:52

有很多方法可以解决您的问题,以下是根据您的描述提供的两个建议.

There are many ways to adress your problem, here are two suggestions based on your description.

1-使用路由器服务器,该服务器将向区域服务器"调度玩家查询:在此拓扑中,所有客户端查询都将到达您的路由服务器,该服务器用唯一的ID标记每个查询,并将其调度到正确的区域服务器,区域服务器将处理查询并将其发送回路由服务器,路由服务器将从唯一标记中识别该查询并将响应发送回客户端.

1 - Use a router server which will dispatch players queries to "Area servers" : in this topology all clients queries will arrive to your route server, the server tag each query with a unique id and dispatch it to the right area server, the area server handle the query and sendit back to the route server which will recognize it from the unique tag and send back the response to the client.

此解决方案将分派CPU/内存负载,但不会分派带宽!

this solution will dispatch the CPU/memory load but not the bandwidth !

2-使用身份验证服务器将客户端重定向到负载较小的服务器:在这种情况下,您将有多个相同的服务器和一个身份验证服务器,当客户端进行身份验证时,将发送可用服务器的url和auth令牌客户端的身份验证票证和服务器的身份验证票证. 客户端然后连接到将使用auth toekn/auth票证进行识别的服务器.

2 - Use an authentication server which redirect client to the servers with less load : in this case, you'll have multiple identical servers and one authentication server, when a client authenticate, send the url and an auth token of available server to the client and an authentication ticket to the server. the client then connect to the server which will recognize using the auth toekn/auth ticket.

此解决方案将分派所有CPU/内存/带宽,但可能不适用于所有游戏,因为每个连接都可以将您发送到不同的服务器,并且如果不在同一区域,您将看不到同一区域的玩家.同一台服务器.

this solution will dispatch all CPU/Memory/Bandwidth, but might not be suited to all games since you can be sent to different server each connection and you'll not see the players in the same area if you are not on the same server.

这些只是两个简单的建议,您可以将两种方法混合使用,也可以添加其他内容(例如,内部通信区域服务器等)来解决上述问题,但会增加复杂性.

those are only two simple suggestions, you can mix the two approaches or add other stuff (for example inter-communication area servers etc) which will solve the mensioned issues but will add complexity.