Tencent Games

How Tencent Games unified real-time and batch game analytics with StarRocks

Tencent Games moved from separate real-time and batch systems to StarRocks as the single entry point for real-time data and the query layer over an Apache Iceberg lakehouse. Joins at query time replaced denormalization in Hive and raised development efficiency by 50%.

50%

higher development efficiency

From running JOINs on the fly instead of denormalizing data in advance

44s

JOIN of 14 billion and 1 billion rows

In production on a 300-node cluster, with other queries running at the same time

1hour

sink interval to the data lake

Data lands in StarRocks in real time and is written to the data lake every hour

CompanyTencent Games
Use caseUnified real-time and batch game analytics
Previous solutionLambda architecture (Hive, Spark, Druid, Redis, MySQL, PostgreSQL)
Employees3,000+
ReplacedSeparate real-time and batch data systems

Originally published at: StarRocks Blog

About Tencent Games

Tencent Games is the gaming division of Tencent. According to the original post, it owns and manages some of the most popular franchises in the industry, including League of Legends, and serves 200 million users around the world.

Denormalizing data in Hive locked each metric into a single view, so every change meant rebuilding pipelines and backfilling data. With JOINs at query time, metrics can change without either.

Key takeaway · Query-time joins replace denormalization

The original post was published on the StarRocks blog without a named author. Its evaluation and architecture sections are written from the Tencent Games team's perspective.

Tencent's games are built and run by many studios, and each studio kept its own data. The company wanted to measure every title against one shared set of metrics.

The challenge

The existing platform combined Hive, Spark, Druid, Redis, MySQL and PostgreSQL. Logs came in through TDBank (Apache InLong) or batch sync jobs and landed in HDFS. Spark jobs built a data warehouse, Storm and Druid handled real-time data feeding Redis and MySQL, and a data mart of config and result tables served front-end queries.

Diagram of the original architecture: Log, MySQL and File sources flow through TDBank (Apache Inlong) and Batch Sync into HDFS; a Compute (Spark) layer holds Storm/Druid to Redis/MySQL, a data warehouse and ETL jobs; a Data Mart of config and result tables serves front-end queries
Tencent Games' original architecture

This setup created three problems:

  • Data in many places. Game logs sat in HDFS, application data in transactional databases such as MySQL and PostgreSQL, and real-time data in Druid. Besides the cost of running all of these stores, the split made data hard to use and slowed access to important information.
  • Two parallel systems. The Lambda architecture used one path to process real-time data and a second path for offline batch processing. Running both was complex and expensive.
  • A long pipeline. Before anything could be queried, it had to be pre-aggregated and denormalized in Hive, then moved to PostgreSQL for reports and dashboards. The process used extra compute and storage, and it fixed the data into one view. Any schema change meant reconfiguring the pipeline and backfilling data.

The solution

Evaluation

Tencent Games compared several database systems. The criteria were query performance, elasticity, lakehouse integration, support for data updates, licensing, integration options and ease of use.

ProductData updateEase of useIntegrationLicense
ClickHouseUpdates only through merge-on-read; query performance not stableHard to maintain; lacks a cluster management toolInternal storage only; no data lake supportOpen source
StarRocksSupports real-time ingestion and updatesEasy to manage and useStrong as a query engine on the data lakeOpen source
PrestoIngestion through SQL only; no real-time updatesNo local storage; comparatively easier to manageConnects well to many data sourcesOpen source
SnowflakeSupportedSaaS; no infrastructure to manageDepends on S3; proprietary formatsCommercial
DatabricksSupportedUI is complex, though use is fairly easyDelta Lake onlyCommercial

The team chose StarRocks for three reasons:

  • Query performance. The team credited StarRocks' MPP architecture, cost-based optimizer and vectorized execution for fast single-table and multi-table queries. In their tests, StarRocks also showed strong query latency on Apache Iceberg, which supported their lakehouse and data governance plans. In production, on a 300-node cluster with other workloads running, a JOIN of a 14-billion-row table with a 1-billion-row table finished in 44 seconds.
  • Data updates. The primary key table handles real-time changes to data. This let the team move most metrics that had been computed offline to real time, so decisions and insight into user behavior and system performance are based on current data.
  • Licensing. StarRocks is an Apache-licensed project under the Linux Foundation, which matched the team's preference for community-driven software.

New architecture

All data now lives in the data lake, and StarRocks is both the entry point for real-time data and the single query layer. TGlog events (log-ins, missions and other events) are ingested into StarRocks in real time. Hive datasets such as revenue, SDK and user behavior data are batch-ingested into object storage. StarRocks writes its data to Apache Iceberg tables in object storage once an hour and queries them there. A MySQL metastore tracks the metadata. Service-level tables, such as user and user behavior tables, are transformed in StarRocks.

This design gives users real-time data and keeps a single source of truth in the data lake, which helps governance.

Diagram of the new data lakehouse: TGlog and Hive sources feed StarRocks through real-time ingestion and object storage through batch ingestion; StarRocks clusters handle data transformation for Service A and Service B, query the object store and periodically sink data to Apache Iceberg; a MySQL metastore receives metadata flows
Tencent Games' new architecture
StarRocksApache IcebergObject storageMySQL (metastore)Apache Hive

The results

With StarRocks as one analytics platform for real-time and batch data, Tencent Games runs fewer systems. That lowers maintenance cost and leaves fewer components that can fail, which improved stability and availability.

Diagram of the analytics platform inside StarRocks: batch data (user property, payment event, game properties) and real-time data (user activity, payment event, log in) feed datasets such as payment amount by registration and by payment channel, real-time new user count, real-time LTV and a churn analysis dataset, which serve a paid dashboard, a real-time dashboard and agile analysis in the data platform
Tencent Games' analytics platform

The change also affected how teams work with data:

  • Real-time metrics. All game logs are now analyzed in real time, which gives the team insights they could not get before.
  • No denormalization. StarRocks runs JOINs at query time, so data no longer has to be denormalized first. Tencent reports a 50% improvement in development efficiency from this.
  • Easier metric changes. Without denormalized tables, changing a metric no longer requires reconfiguring the pipeline or running costly backfills.
  • Ad hoc analysis. Because aggregations and JOINs happen at query time, datasets are available through fixed SQL templates. Users can change dimensions or statistical logic on their own as their analysis needs shift.

What's next

  • Build richer datasets in StarRocks by game genre and feature, for detailed game analysis and operations.
  • Improve query performance on the data lake by using StarRocks materialized views to cache data locally, and by optimizing how Iceberg metadata is stored in StarRocks to speed up filtering and cut serialization overhead.
  • Add compute node clusters for data ingestion, to remove bottlenecks and reduce load on the main cluster.
  • Continue contributing to StarRocks. Tencent has already contributed to the compute node and helped develop Iceberg V2 table support in the StarRocks external catalog.