3

I have an Entity that represents a Payment Method. I want to have an entity group for all the payment attempts performed with that payment method.

The 1 write-per-second limitation is fine and actually good for my use case, as there is no good reason to charge a specific credit card more frequently than that, but I could not find any specifications on the max size of an entity group.

My concern is would a very active corporate account hit any limitations in terms of number of records within an entity group (when they perform their 1 millionth transaction with us)?

Alex
  • 5,141
  • 12
  • 26

1 Answers1

7

No, there isn't a limit for the entity group size, all datastore-related limits are documented at Limits.

But be aware that the entity group size matters when it comes to data contention, see Keep entity groups small. Please note that contention is not only happening when writing entities, but also when reading them inside transaction (see Contention problems in Google App Engine) or, occasionally, maybe even outside transactions (see TransactionFailedError on GAE when no transaction).

IMHO your usage case is not worth the risk of dealing with these issues (fairly difficult to debug and address), I wouldn't use a single entity group in this case.

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • I was hoping to make use of entity-groups here to prevent multiple requests/threads from charging a user at the same time. Currently I have separate entity I call the 'payment lock' which shares the same Key id as the account it is locking. Before attempting payment, I try to mark the account as 'locked' in a transaction, I then perform the payment and then unlock in a transaction. I have noticed contention errors from time to time. What would be the best way to do this then? – Alex Sep 25 '17 at 19:11
  • You shouldn't normally need an explicit lock, the very presence of the transaction environment should take care of that. Unless the duration of the transaction is unacceptable. By transaction here I mean a datastore transaction, not a charge transaction. Try mapping them 1:1. – Dan Cornilescu Sep 25 '17 at 19:51
  • If you limit your entity group ancestor to the payer then you can scale the system and still achieve the transaction capability of transaction groups unless you can come up with a reason why a single card will be paying multuple concurrent payments ;-) – Tim Hoffman Sep 26 '17 at 10:19