Database technology is becoming increasingly important as the cornerstone of modern applications. This is particularly true in the gaming industry, where the growing user base and increasingly complex business demands pose numerous challenges to traditional database solutions. With their high scalability, high availability, and powerful processing capabilities, distributed databases have become the ideal choice to address these issues.

We discuss three key aspects: the initial reasons for choosing TiDB, the early stages of building TiDB application services, the significant benefits of using TiDB.

Introduction to JJ World

JJ World, established in 2007, is primarily focused on the development and operation of online games. Their flagship gaming platform, “JJ Landlords,” has amassed over 500 million registered users. In addition to promoting competitive card game culture, JJ World has expanded into self-developed mobile games, including titles such as “Dawn Heroes” and “Street Basketball Fever.” The company has also successfully hosted 16 editions of the “JJ Landlords” Championship Cup.

TiDB was first implemented at JJ World between July and August 2021.

Why JJ World chose TiDB?

Before adopting TiDB, JJ World primarily relied on a MySQL and MyCAT cluster architecture. This setup, however, brought several challenges that became increasingly difficult to manage. Storage and performance bottlenecks were a significant concern, particularly with ultra-large tables, where the concurrency capabilities were limited. The delays in read-write separation sometimes resulted in the reading of dirty data, and the MySQL MHA (Master High Availability) setup posed risks of misfailovers and even data loss during network jitters, compromising the system’s high availability.

For the MyCAT cluster, shard selection posed a critical challenge. If not properly handled before going live, it could lead to data skew, significantly reducing query performance. Additionally, aggregating data queries was extremely difficult, and there was only limited support for transactions, which added to the complexity of managing the system. Furthermore, in OLTP (Online Transaction Processing) scenarios, where MySQL clusters were primarily used, the efficiency of executing analytical queries on large datasets was notably low.

These persistent issues underscored the need for a more robust and scalable solution, eventually leading JJ World to adopt TiDB.

To address the challenges JJ World faced with their existing MySQL and MyCAT cluster architecture, the team implemented several strategies to alleviate the pressure on a single cluster and enhance overall throughput. These efforts included cluster splitting and database and table partitioning. Additionally, JJ World migrated analytical scenario data to specialized analytical databases like ClickHouse and Doris. However, these changes introduced new challenges, such as the creation of data silos, difficulties in ensuring data consistency, and increased operational complexity.

In response to these ongoing issues, JJ World initiated a comprehensive database survey at the beginning of 2021. The selection process was guided by four key criteria: alignment with business scenarios, the potential for architectural evolution, compatibility with the broader technology ecosystem and development trends, and the availability of diversified options. JJ World deliberately chose to avoid an all-in-one solution, focusing instead on a more tailored approach that could better meet their specific needs.

The Four Criteria for Database Selection

From Zero to One: How to Implement TiDB?

During the selection phase, they conducted several validation tests, including functional verification, performance stress testing, high availability testing, business integration testing, migration testing, and post-migration synchronization testing. These tests helped ensure a smooth migration process from MySQL to TiDB.

Three basic requirements for migrating from MySQL to TiDB are SQL compatibility, the ability to roll back the migration, and no performance degradation. Based on these requirements, they designed two migration processes for MySQL and MyCAT.

The first process involves cluster splitting. According to the previous architecture, when a single instance business reaches a bottleneck, they split the business by business dimension and route the upstream business to the corresponding instance. After introducing TiDB, they used DM (Data Migration) to merge the previously split instances into the same TiDB cluster. To meet the requirement of “migration rollback,” they used TiCDC to write the data synchronized to TiDB back to MySQL, ensuring that the business they switch back to the original environment at any time. For data consistency verification, we used the official tool sync-diff-inspector to ensure final data consistency before business switching.

Similarly, for the MyCAT cluster, they synchronized data from the underlying data nodes to the TiDB cluster in real time using DM, then performed reverse writing using TiCDC and used sync-diff-inspector to check data integrity.

Previously, they synchronized data from MySQL to Kafka and used Canal to capture incremental data for transmission to Kafka. After migrating to TiDB, they could seamlessly switch to Kafka using the CDC (Change Data Capture) protocol to meet the needs of downstream consumers.

Benefits of Using TiDB

After migrating to TiDB, they observed significant performance improvements.

For example, one of their use cases involves wide tables with both OLTP and OLAP requests and very complex SQL queries. After migrating to TiDB, they noticed a substantial performance boost. In MySQL, some SQL statements took more than 30 seconds to execute, but in TiDB, 95% of queries are now completed within 1 second, and even complex, high-frequency SQL queries are generally executed within 3 seconds. Previously, due to data volume limitations, they could only query data from the past six months. However, after migrating to TiDB, they can query and analyze data from the past 2-3 years.

In their company, TiDB is used for scenarios such as sharding and aggregation, high I/O operations, historical data archiving, and real-time HTAP. Currently, they have 9 clusters online with 115 nodes. The main versions they are running are 5.0 and 6.5, with plans to upgrade all clusters to version 6.5 by the end of this year.

After adopting TiDB, the integration cost has become very convenient from a development perspective. Data storage capacity has increased, aggregation query speed has improved, and data statistics and analysis have become more real-time. This allows the business team to focus more on business innovation.

From an operations perspective, they have reduced operational costs, improved cluster stability and data consistency, and enhanced operational efficiency by over 10 times through elastic scaling and host migration.

JJ World and TiDB 

In conclusion, JJ World’s journey with TiDB has proven to be a game-changer in managing large-scale data and high-concurrency scenarios. The adoption of TiDB not only resolved their initial challenges and provided a scalable, highly available, and robust database solution that supports their ever-growing user base and complex business demands. By leveraging TiDB, JJ World has enhanced its operational efficiency, maintained data integrity, and positioned itself for future growth.

If your business is facing challenges similar to those of traditional databases and you seek a powerful, scalable solution, TiDB might be the key to unlocking new potential. 

Explore how TiDB can transform your data management strategy and help you stay ahead in today’s competitive landscape. 

Elevate modern apps with TiDB.

Book a Demo