views:

26

answers:

1

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.

+2  A: 

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.)

David Underhill
+1 You could optimize a little by only retrieving a subset of shards to see if a shard still has enemies, and thus the pool is not empty.
Jason Hall