A use-case study of why Tencent uses ScyllaDB as the state store of our Proxima Beta gaming platform's service architecture. How we leverage multi-datacenter replication for global data distribution and governance, as well as time window compaction strategy (TWCS) to power a distributed queue-like event store specialized to our scenario.
Computer 10: Lesson 10 - Online Crimes and Hazards
How Level Infinite Implemented CQRS and Event Sourcing on Top of Apache Pulsar and ScyllaDB
1. How Level Infinite
Implemented CQRS and Event
Sourcing on Top of Apache
Pulsar and ScyllaDB
Zhiwei Peng, Senior Software Engineer
Zhihao Chen, Senior Software Engineer
Lei Shi, Principal Software Engineer
2. About Proxima Beta & Level Infinite
■ Proxima Beta aka Tencent Interactive Entertainment Group Global
■ We are part of Tencent Games and in charge of global publishing under the
brand - Level Infinite
■ At this moment, we are running several well-known titles, such as PUBG
Mobile, Arena of Valor, and Tower of Fantasy
■ Everything we do at Level Infinite centers around supporting our teams and
studios to bring unique, exhilarating games to millions of players around
the world
3. ■ Quick recap of our service architecture.
■ Why do we choose ScyllaDB as an event store?
■ What are extra benefits we could get by using ScyllaDB?
Agenda
See Also
https://streamnative.io/blog/case/2022-11-15-how-proxima-beta-implemented-cqrs-and-event-sourcing-on-top-of-apache-pulsar-and-scylladb/
5. Event
Processors
Game Servers Command APIs
Service Architecture
Table
Table
Query APIs
Query
Query
X Y
Y1 Y2
1 2
Y
X
Query Y
Bulk
Batch X
Batch Y
X Y Topic X Y
Topic X Y
Topic X Y
Consume
Produce
Topic
Topic X Y
Y1 Y2
Consume
Update
■ Clients keep sending activity events to
Apache Pulsar through Command APIs.
■ Each type of event has a corresponding
topic.
■ Event processors selectively subscribe
topics to consume activity events and
produce data points of metrics and findings.
■ Data points of metrics and findings are
synchronized into tables as records.
■ Clients periodically query against ScyllaDB
through Query APIs to get results.
7. Partition
Time-Series Events
■ Partitioning by sessions and using TimeUUID as
event identifiers.
■ Enabling Time-Window Compaction strategy.
CREATE TABLE IF NOT EXISTS events (
session_id uuid,
event_id timeuuid,
payload blob,
PRIMARY KEY(session_id, event_id)
) WITH gc_grace_seconds = 60 AND
default_time_to_live = 300 AND
compaction = {
'compaction_window_size': '1',
'compaction_window_unit': 'MINUTES',
'class': 'TimeWindowCompactionStrategy'
};
History Future
Phantom-Window
True Present
Pseudo Now
■ Tracking current position at client side
■ Beware of phantom read problem
Smaller EventId Greater EventId
9. DC1
DC3
Global Tables
CREATE KEYSPACE "global"
WITH REPLICATION = {
'class' : 'NetworkTopologyStrategy',
'AP_SOUTHEAST_1' : 3, // Datacenter 1
'US_EAST_1' : 3, // Datacenter 2
'EU_CENTRAL_1' : 3, // Datacenter 3
'SA_EAST_1' : 3, // Datacenter 4
};
■ Read and write locally, access data globally.
■ No cloud vendor lock-in.
■ Making global configuration management easier.
DC2 DC4
10. ■ Abstracting complex
configurations and regulations
away from apps.
■ Improving the testability of
complex data distributing
problems by separation of duties.
Keyspaces as Data Containers
DC2 - Region B
DC1 - Region A
Apps
Commands
Queries
Clients
11. ■ When using ScyllaDB to handle time series data, don't
forget TimeWindowCompactionStrategy.
■ Try using keyspaces and data replication as a tool to
separate the duty of data distribution.
Takeaways
12. Thank you
Stay in touch
Lei Shi https://github.com/shileiyu
lei-shi-b72a0033/
Zhihao Chen
Zhiwei Peng zhiwei-peng-17255694/ https://github.com/zeewinpeng
zhihao-chen-75754713a/ https://github.com/haorenqq