cloudspannerecosystem/spanner-gaming-sample

[Workloads] Improve logic for getting games to close in matchmaking workload

Opened this issue · 0 comments

dtest commented

The query to get a random open game to be closed looks something like this:

query := fmt.Sprintf("SELECT gameUUID FROM (SELECT gameUUID FROM games WHERE finished IS NULL ORDER BY created DESC LIMIT 10) TABLESAMPLE RESERVOIR (%d ROWS)", 1)

These random queries are too expensive in terms of CPU, especially as the games table grows. Additionally, this is called very frequently.

It would be better to improve the generator logic to get a list of 100-1000 open games to store in a queue. When the queue is empty, another call to get more games to close is issued to the backend.