Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Match Making using GAE + ndb

I have a game in which users contact a server to find a user of their level who wants to play a game. Here is the basic architecture of a game request.

enter image description here

I am using ndb to store a waiting queue for each user level in the Google DataStore.

I am accessing these queues by their keys to ensure strong consistency (per this article). The entities are stored in the queue using a repeated (list of) LocalStructuredProperty.

Questions:

  1. An entity is deleted from a waiting queue because it is matched to a request. The transaction is committed but not yet applied. That same entity is matched with another request and deleted. Will this throw an error?
  2. These strongly consistent accesses are limited to ~1 write/sec. Is there a better architecture that would eliminate this constraint?

One thing I've considered for the latter question is to maintain multiple queues (whose number grows and shrinks with demand).

like image 451
Alex Avatar asked Sep 25 '26 05:09

Alex


1 Answers

Not sure about your first question, but you might be able to simulate it with a sleep statement in your transaction.

For your second question, there is another architecture that you could use. If the waiting queue duration is relatively short (minutes instead of hours), you might want to use memcache. It will be a lot faster than writing to disk and you can avoid dealing with consistency issues.

like image 155
Brent Washburne Avatar answered Sep 26 '26 19:09

Brent Washburne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!