The incredible, incredible pain of fighting lag

Published February 28, 2011
Advertisement
Creating an MMO (see http://www.janthus.com) is monstrously difficult, as I've come to realize. After literally spending hundreds of hours on the core game engine as a sole developer, I've just now started to make inroads into the horrible problem of lag, and fighting it to the point where people within 250ms to 500ms delays to the server can have a reasonably good experience as those below. The huge task of creating immersive content (art, story lines, interactions, puzzles, quests, etc.) hasn't even factored in how much time I've spent at this.

Here are the major highlights of my fight:

- when fighting lag, you must consider 2 sources -- lag from your client to the server, and lag from another client viewing your actions, to the server.
- turn of Nagle's algorithm (TCP_NODELAY), I forgot to do that, and was mystified why I'd get sudden unexplicable message bursts -- because they were getting cached
- don't implement the networking scheme where you move your client, and then broadcast each individual move to the other clients; this falls down especially quick with TCP
- a better strategy is to allow the local client to stop/start motions, and send comnmands to the server to update remote clients accordingly. But you've got to have smooth adjustment logic on the remote client side to handle the case where your remote avatar has overshot, and now has to backtrack!
- definitely localized messages -- only clients within 'viewshot' of each other should see things like attacks, movements, etc.
- very definitely track the amount of lag experienced by the clients ... this will help you debug whether or not slowdown is due to lag, or just bugs in your code, when people are playing the game in the wild.
- I've found that position corrections (for your avatar on remote clients) should be done with as little "zipping around" or "teleporting" a possible. To avoid the former, corrections should be animated at walking pace, if the delta between current and actual position is under something like 2.5 seconds. To avoid the latter, animated autocorrections should be made (with the previous statement in mind).

What I've found from people playing the game is that people are willing to forgive crappy graphics, generally, if the controls are smooth and intuitive. And making sure that you got lag beat is definitely a giant factor for the former.

I'm still hacking away at it, and I think I am chipping away at the problem. It seems to be reasonably playable in its current state for people in Beijing and Australia, with the server being in the US. So I am optimistic!
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement