Wednesday, November 8, 2017

[google-cloud-sql-discuss] Re: Migrate from Cloud SQL to DataStore

As previously stated the choice of how you want to migrate your kinds over is completely up to you. If you expect traffic like that of Facebook or Instagram then yes you may run into contention issues due to the write limit on entity groups. 

In this case you may want to just have your User kind a parent of Post kind (since a single user cannot make more than one post in a second). Then your Comment and Like kinds simply have a 'post_id' property. 

No matter what API call you make to Google it is always recommended to perform error handling to catch any possible exceptions such as a contention error. Once you catch these 5xx error responses in your code, you should perform exponential backoff retry in order to retry the comment or like again after a small exponential delay. The idea is to have your clients backoff until their requests eventually succeed. Of course in your UI you will show the new comment or like right away, but behind the scenes your client will retry until it truly succeeds.

Additionally if you are using the Google Cloud Client Libraries Google will automatically perform exponential backoff for you for most requests. As a side note I went ahead and did a test where I had a thousand individual comment entities created under a single Post parent via a script. There were no contention errors returned from the Datastore and all of the entities were committed. This shows that the Datastore actually replicates and scales quickly, but that these limits are documented as best practices to protect both the Datastore and your application from potential issues. 

 

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/75b9dd1e-f30c-4eb5-ae04-05ab88205ce1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment