-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[DATASTORE] Slow sync to Dynamo DB #5592
Comments
I also experienced slowness using DataStore with AppSync/DynamoDB, among other issues. I ended up using the AppSync SDK and Apollo client instead, and it is much faster and easier to use than DataStore. |
Do you notice the 3-4 second lag when you have a large number of records needing to be synced (eg. 100,000 in the code example above) or even initially when you have a few records initially. What about after your runData() is complete, if you create one more item does that also take a while to sync? Are you running with the debugger enabled or without? We will run the test above as well and look into what the issue could be. I also suspect once you reach a large amount of data, querying the entire list of posts for each iteration of the loop will be causing performance issues:
Maybe try without that and see if there is some improvement? |
I believe this is related to this one: |
Were you able to try @Ashish-Nanda 's suggestions? |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Describe the bug
A clear and concise description of what the bug is.
I am experiencing a very slow sync from my local datastore to Dynamo DB, about 1 records every 3-4 seconds. Is this expected behaviour? What steps could I use to increase this speed? I already have my Dynamo DB table on scaling capacity?
To Reproduce
Steps to reproduce the behavior:
Sync data to Dynamo DB
See slow rate of items being created on Dynamo Console
Expected behavior
A clear and concise description of what you expected to happen.
Faster Syncing
Code Snippet
Please provide a code snippet or a link to sample code of the issue you are experiencing to help us reproduce the issue. (Be sure to remove any sensitive data)
/**
*/
import React, {useEffect, useState} from 'react';
import {DataStore} from '@aws-amplify/datastore';
import {PostStatus, Post} from './src/models';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
import {Colors} from 'react-native/Libraries/NewAppScreen';
import Amplify from '@aws-amplify/core';
import awsConfig from './aws-exports';
Amplify.configure(awsConfig);
const App: () => React$Node = () => {
const [usePost, setPosts] = useState([]);
useEffect(() => {
async function runData() {
for (var i = 0; i < 100000; i++) {
await DataStore.save(
new Post({
title: 'My First Post',
rating: 10,
status: PostStatus.ACTIVE,
}),
);
}
const posts = await DataStore.query(Post);
setPosts(posts);
}
runData();
}, []);
return (
<>
Test {usePost.length}
</>
);
};
const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
engine: {
position: 'absolute',
right: 0,
},
body: {
backgroundColor: Colors.white,
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: Colors.black,
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: Colors.dark,
},
highlight: {
fontWeight: '700',
},
footer: {
color: Colors.dark,
fontSize: 12,
fontWeight: '600',
padding: 4,
paddingRight: 12,
textAlign: 'right',
},
});
export default App;
Smartphone (please complete the following information):
The text was updated successfully, but these errors were encountered: