-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customize ds_pk on Delta Sync table created by Amplify #2780
Comments
Hey @naveenkoduri , 👋 thanks for raising this! I'm going to transfer this over to our Android repository for better assistance 🙂. |
@naveenkoduri - can you please provide the following?
Thank you! |
@naveenkoduri - there is currently a PR out that changes the delta table partition key format for better sync performance with models having custom primary keys. New attributes are added to mutations and sync query resolvers to notify AppSync to use the newly improved data format. Once this PR has been merged, the delta sync performance will be improved to better utilize the custom primary keys that you are using. |
@david-mcafee, the PR you mentioned seem to be applicable for models having custom primary key. Just so you are aware our model does not have a custom primary key as you can see in the schema we are not using @PrimaryKey directive. Below is the information you asked for.
Sync Expression
Datastore
Cloud Formation generated for delta table with latest Amplify CLI 12.2.5
Also, I just want to reassure you that there is no issue related to syncing data on User's device. If the user has 10 messages, the user's AmplifyDatastore.db always has only 10 messages, and RCU is significantly lower whenever Base query is done. The inefficiency is only with the Delta query where there is no option to query records by a PK expression to begin with unless I am missing something. I happen to find this in AppSync Sync operation documentation, but, not sure what we have to do on Amplify Schema to have the mentioned "deltaIndex" generated by Amplify.
|
Adding sample request received by AppSync and the transformed request to DynamoDB for Base Query and Delta Query. For both of these queries there is not much change in how GraphQL query looks like, but, the transformed request changes Base QueryAppSync Query:
TransformedTemplate:
Delta QueryAppSync Query:
TransformedTemplate:
|
@naveenkoduri - it looks like you tried both a 27 hour TTL for the delta table, as well as a 30 minute TTL. Have you tried experimenting with a TTL configuration in between those values? If not, I would recommend starting with a 2 hour TTL to see if that helps. I also wanted to follow up on your other comments:
If updating the TTL does not help and / or custom primary keys are not an option for you, please let me know! Thanks! |
@david-mcafee, Thanks for looking further into it. Currently, we have 30 min for one table and 5 min for another table. With these TTL settings itself, we are see Datastore/DeltaSync table consuming more RCU compared to the Base table for the traffic we have. The one option we know will make it better is going further down to 5min on the other table as no. of records in DeltaSync table will decrease and thereby fewer records to query for Delta Query. However, this would pose another problem in the future as we grow where we will see a lot of Sync requests going to the Base table that will return up to 25000 records. Regarding the primaryKey, we do need it to be auto-generated UUID as the PK identifies a specific text message between two parties. |
Amplify CLI Version
10.6.2
Question
Currently, we have an Android Amplify app that does Selective Sync from the backend and uses a specific GSI on the base table. So, the base query which uses the base table during the sync is all fine and good.
Now, with respect to delta sync using its Delta Sync table, whenever our app users are most active, this Delta Sync table is just getting throttled despite being an on-demand table as it is designed to use only two keys (for instance, keys are foo-table-2023-07-27 and bar-table-2023-07-27). Keeping the throttling issue aside, the RCU cost incurred for this delta sync table was always huge when the TTL was 27 hours and consumed 99% of our Dynamo DB cost. We reverted the TTL back to 30 min which again triggered the bug which is again cost prohibitive and we worked around that bug. This means we are back to doing a lot of base queries.
That begs the question, Is there a way we can customize the default pk and sk created by Amplify for this Delta Sync table that aligns with our access pattern related to Selective Sync
The text was updated successfully, but these errors were encountered: