Thursday, April 16, 2015

Considerations for Global Mobile Games (5) - Text Compression

In global mobile game development, reducing the size of static data sent from servers can significantly optimize resource usage, particularly in terms of network bandwidth. Here's how text compression helps:


Key Insight

  • Trade-off: CPU utilization increases as network bandwidth decreases.
  • Global Network Optimization: In a global setting, saving network resources by slightly increasing client CPU usage is a beneficial trade-off.

Static text resources like configuration files and language packs should be compressed before transmission.


Requirements for Compression Algorithms

  1. Universality: Widely supported and easy to implement.
  2. Compression Ratio: High compression efficiency.
  3. Decompression Speed: Fast decompression to minimize client-side delays.

Compression Algorithm Comparison

AlgorithmCompression RatioDecompression SpeedImplementation Complexity
GZIPHighFastEasy
BrotliHigherModerateModerate
LZ4ModerateVery FastEasy

GZIP is often chosen for its balance between compression ratio and decompression speed while being universally supported.


Example: GZIP Compression

JSON Example:

Original JSON string:

{ "name": "real", "ableWeekRankBtn": true, "ablePeriodSell": false, "specialPurchaseTap": false, "majorVersion": 1, "minorVersion": 56, "gameUrl": "http://qwer-game.asdfghjkl.com/", "patchUrl": "http://qwer.gcdn.asdfghjkl.com/rfvt/patch/", "rankingUrl": "http://qazwsxeapi.asdfghjkl.net/", "logUrl": "http://qazwsxedclog.asdfghjkl.net" }
  • Original Size: 352 bytes.
  • Compressed Size (GZIP): 209 bytes.

This demonstrates a compression rate of ~40%, significantly reducing the payload size for transmission.


Simulation Tool

To experiment with compression techniques, you can use tools like:


Benefits

  • Reduced Data Transfer Costs: Essential in regions with costly or limited network bandwidth.
  • Faster Load Times: Compressed data reduces latency in data delivery.
  • Improved User Experience: Lower data usage can lead to better accessibility for users with constrained data plans.

Summary

Compressing static text resources before sending them to clients is a highly effective strategy in global mobile game development. Using tools like GZIP ensures a good balance of compression efficiency and decompression speed, ultimately saving network resources while maintaining client performance.