Tuesday, October 31, 2017

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

I'm creating App where I need to make Post Feeds. Right now I'm using App Engine Standard and Cloud SQL instance db-n1-standard-1 which is based on MySQL But I notice it is very expensive. App is under production mode and In first month price is much higher than my expectation. Most costly thing in Cloud SQL is instance hours rate So, I decide to migrate it on datastore.


I have three tables, 1- users 2- posts 3- comments And Every Table has round about 10 BillionsRows. Posts and Comments table are growing very fast 100 of millions rows are expected.


Users Table


user_id         name        email           phone  --------------------------------------------------  u123            Abc         abc@m.com       123456  u124            Cde         cde@m.com       789065  u786            Qwe         qwe@m.com       754599   .               .              .               .   .               .              .               .   .               .              .               .


Posts Table


post_id         user_id         type        src                 date  ------------------------------------------------------------------------  p098            u123            img         path/to/file        13-3-17  p456            u123            vid         path/to/file        14-3-17  p239            u124            img         path/to/file        15-3-17   .               .               .              .                   .   .               .               .              .                   .   .               .               .              .                   .


Comments Table


cmnt_id         post_id         user_id         comment  --------------------------------------------------------  m392            p098            u123            Some Text  m234            p098            u786            Some Text  m324            p456            u123            Some Text   .               .               .                .   .               .               .                .   .               .               .                .


As you can see User can post one or more posts and single post has one or more comments

I need to get posts data along with post comments I know I need to use JOIN for this. And I can easily use it in Cloud SQL because it's based on MySQL.

These three tables have relation between them and As I know Cloud SQL is relational database but DataStore is not.


I have idea in my mind to convert these tables in DataStore


1- Create Entity as Users and save all users records there 

2- Create Entity as Posts and save all posts records there 

3 - Create Entity as Comments and save all comments records there


Post id is always I know for which post I need to get data


For example I need post data about id p098 I'm using Java I decide to create two threads First thread get post data from Posts Entity and second thread get comment data from CommentsEntity. Then I merge these two data set by using java to generate same result as JOIN Like MySQLBecause I think DataStore is not allow JOINS


Here I need some Suggestions.

  1. 1 - Is it a good way to do that ?
  2. 2 - Which Provide the best Performance in this Situation ?
  3. 3 - If Billions of User(Large Number of Users) is accessing Posts and Comments data as same time which one can handle it better ?
  4. 4 - What about Pricing Effect if I migrate from Cloud SQL to DataStore in this situation ?
  5. 5 - If your App need continuous database then SQL instance run continuous which make it high cost, isn't it ? For example in my App every user when open  app  need to show Posts if there is large number of users then I think SQL instance never shutdown. Which means it run 730 hr in a month.
  6. Any recommendation ?

--
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/43740116-ed32-45a8-bb3b-19447877bb6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

I'm creating App where I need to make Post Feeds. Right now I'm using App Engine Standard and Cloud SQL instance db-n1-standard-1 which is based on MySQL But I notice it is very expensive. App is under production mode and In first month price is much higher than my expectation. Most costly thing in Cloud SQL is instance hours rate So, I decide to migrate it on datastore.


I have three tables, 1- users 2- posts 3- comments And Every Table has round about 10 BillionsRows. Posts and Comments table are growing very fast 100 of millions rows are expected.


Users Table


user_id         name        email           phone  --------------------------------------------------  u123            Abc         abc@m.com       123456  u124            Cde         cde@m.com       789065  u786            Qwe         qwe@m.com       754599   .               .              .               .   .               .              .               .   .               .              .               .


Posts Table


post_id         user_id         type        src                 date  ------------------------------------------------------------------------  p098            u123            img         path/to/file        13-3-17  p456            u123            vid         path/to/file        14-3-17  p239            u124            img         path/to/file        15-3-17   .               .               .              .                   .   .               .               .              .                   .   .               .               .              .                   .


Comments Table


cmnt_id         post_id         user_id         comment  --------------------------------------------------------  m392            p098            u123            Some Text  m234            p098            u786            Some Text  m324            p456            u123            Some Text   .               .               .                .   .               .               .                .   .               .               .                .


As you can see User can post one or more posts and single post has one or more comments

I need to get posts data along with post comments I know I need to use JOIN for this. And I can easily use it in Cloud SQL because it's based on MySQL.

These three tables have relation between them and As I know Cloud SQL is relational database but DataStore is not.


I have idea in my mind to convert these tables in DataStore

1- Create Entity as Users and save all users records there 

2- Create Entity as Posts and save all posts records there 

3 - Create Entity as Comments and save all comments records there


Post id is always I know for which post I need to get data


For example I need post data about id p098 I'm using Java I decide to create two threads First thread get post data from Posts Entity and second thread get comment data from CommentsEntity. Then I merge these two data set by using java to generate same result as JOIN Like MySQLBecause I think DataStore is not allow JOINS


Here I need some Suggestions.

  1. 1 - Is it a good way to do that ?
  2. 2 - Which Provide the best Performance in this Situation ?
  3. 3 - If Billions of User(Large Number of Users) is accessing Posts and Comments data as same time which one can handle it better ?
  4. 4 - What about Pricing Effect if I migrate from Cloud SQL to DataStore in this situation ?

  5. If your App need continuous database then SQL instance run continuous which make it high cost, isn't it ? For example in my App every user when open app need to show Posts if there is large number of users then I think SQL instance never shutdown. Which means it run 730 hrin a month.

  6. Any recommendation ?

--
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/bedaf7d1-2a4c-424c-b8f5-040fce12c735%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.