Golang server, the problem of socket write timeout encountered during game beta, is also the design problem of the game frame.

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

Problem Description:

Game Beta, there are about hundreds of players. Run for a short period of time, about 20 minutes or up to half an hour, the service end is stuck. Get stuck for a long time and then become normal for a little while

Check the problem process:

After the analysis of the running log, the program executes to the client socket to write data will be stuck, and then error, the specific errors have been forgotten, presumably write timeouts and so on.

Baidu query, that is, the server in a closed socket to write data to cause the error, and this "shutdown" in the server actually think that there is no shutdown. The client initiated the close request, but the server did not handle the request correctly, causing the service side to always assume that the socket was normal until it timed out.

So the framework design is this: A player's operation will be synchronized to other players, this is directly to the other player's socket to send data, if there is a player client write timeout, then all the players will be waiting for the exception of the write timeout. Cause all the clothes are jammed. That is, a player's socket exception causes all players to be abnormal.

The problem arises from the fact that the socket mechanism is not fully understood. The frame design is unreasonable. It is not possible for a player's exception to cause full-service to be stuck.

Resolution process:

The socket mechanism problem is temporarily not processed. The socket exception should be a direct disconnection, without the processing of a re-connection. Although the customer experience is not friendly.

The framework is designed to: if you want to send data to each player, then the player's socket is responsible for communication, because each player's socket processing is a go, if a player stuck, then just stuck to the player, the loss is minimized.

Thus, the frame design can be summed up. Each player is only dealing with their own problems, if there is any impact on other players of the data, then can only be handed to the affected players to process their own data.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.