Skip to content
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

Closed
PatrickLambert1101 opened this issue Apr 28, 2020 · 5 comments · Fixed by #5942
Closed

[DATASTORE] Slow sync to Dynamo DB #5592

PatrickLambert1101 opened this issue Apr 28, 2020 · 5 comments · Fixed by #5942
Labels
DataStore Related to DataStore category React Native React Native related issue

Comments

@PatrickLambert1101
Copy link

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):

  • Device: Custom Android 7 With React Native
@PatrickLambert1101 PatrickLambert1101 added the to-be-reproduced Used in order for Amplify to reproduce said issue label Apr 28, 2020
@Lovecannon
Copy link

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.

@Amplifiyer Amplifiyer added the DataStore Related to DataStore category label Apr 28, 2020
@Ashish-Nanda Ashish-Nanda added the React Native React Native related issue label Apr 28, 2020
@Ashish-Nanda
Copy link
Contributor

Ashish-Nanda commented Apr 28, 2020

Hi @PatrickLambert1101

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:

const posts = await DataStore.query(Post);
setPosts(posts);

Maybe try without that and see if there is some improvement?

@rpostulart
Copy link

I believe this is related to this one:

#5434

@manueliglesias
Copy link
Contributor

Hi @PatrickLambert1101

Were you able to try @Ashish-Nanda 's suggestions?

@github-actions
Copy link

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 *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
DataStore Related to DataStore category React Native React Native related issue
Projects
None yet
6 participants