8Dromeda Blog
Soilnar July Update Part 2: Network Optimization
Having dealt with scaling, I was poking around in the game and looked at a network monitor graph. The game was causing more traffic than I would've expected.
I fired up [tcpflow -p -c -i lo port 8081] and moved around.
Every movement step caused the transfer of a whole 20x20 tile chunk around the ship. Why? Well, because every time the ship moved, it added track traces to the tile underneath. This lead the network system to see that the 20x20 chunk was modified, and it happily proceeded to send it, every time.
Information flow in the Soilnar Entity-Component Framework is based on events. Systems emit events when something is modified, and other systems listen for events that they need to act on.
The network system simply listens for modification of anything, and when anything is modified, it determines who should hear about that modification, finally sending the modification to all the appropriate game clients.
First I thought something like "oh dog, this is going to go so spaghetti tier!", until the glorious truth hit me. The thing is actually fairly well designed! I needed to add an optional field to the value modification event that can contain a network-transferrable description of the change from the previous state to the current one, and make the tile chunk system always fill it in.
Before: struct ValuesModifiedEvent { vector<string> changes; }; After: struct ValuesModifiedEvent { struct ChangedValue { string name; MinorChange *minor_change; }; vector<ChangedValue> changes; };
All of the existing event listeners will work just like before, but the network system is extended to transfer the minor modification description instead when it is provided.
Before, when moving with a fast-moving ship, the network consumption was 50KB/s. Now it is 12KB/s, and if we leave out transferring newly visible tile chunks, it is 2KB/s.
To be continued...
As noted in the previous post, I have way too much stuff for a single post.
- A of 8Dromeda
Soilnar July Update Part 2: Network Optimization: http://t.co/Jn2BLQgEOB
— 8Dromeda Games (@8dromeda) July 24, 2013
All Posts
- 2015-09-15: Developing Soilnar: Part 5 (days 37-54)
- 2015-03-23: Implementing things #4 (days 10-36)
- 2015-02-28: Implementing things #3 (days 6-9)
- 2015-02-23: Implementing things #2 (days 3-5)
- 2015-02-21: Implementing things
- 2015-02-19: The Soilnar plan of 2015
- 2015-02-12: What the fuck?
- 2013-11-24: Random Dev Notes #1
- 2013-10-26: Soilnar Progress
- 2013-10-11: Third Iteration: Intrusion Underground
- 2013-10-02: Check Twitter
- 2013-08-09: Scaling: The MMO Kind Of
- 2013-07-27: Soilnar July Update Part 4/4
- 2013-07-26: Soilnar July Update Part 3: Bitaeli
- 2013-07-24: Soilnar July Update Part 2: Network Optimization
- 2013-07-23: Soilnar July Update Part 1: Scaling
- 2013-06-20: Miscellaneous Questions
- 2013-06-16: Ternadim Progress
- 2013-04-01: Soilnar April Update
- 2013-02-02: Project Soilnar
- 2013-01-31: First Post!