Reputation: 7729
I have one variable pool
, shared by all clients, that stores all remaining enemies in a game. When a client starts a game, he gets some enemies from pool
. When he finishes, enemies that he did not kill are put back into pool
. The game also checks to see if all the enemies have been killed (i.e., pool
is empty).
What is the best way to implement pool
? I'm concerned about the 5 updates per second limit on a datastore entity.
Upvotes: 1
Views: 73
Reputation: 16243
How often do expect a game to be started/finished? If the answer is definitely less than 5 per second, then just use a single entity to represent pool
and use transactions to atomically get and update it as games start and finish.
If you're really expecting so many clients to share a single pool
that it will be updated at a sustained rate of more that 5 times per second, then consider sharding pool
into multiple pieces. When the client starts a game, remove entities from just one of the shards. To test if the sharded pool
is empty, just retrieve all the shards and see if they are all empty. (When modifying a shard, you'll still need to use a transaction.)
Upvotes: 2