- Newest
- Most votes
- Most comments
Hi,
one potential issue with React generating such amount of calls is unnecessary re-rendering: see https://dev.to/femi_dev/how-to-prevent-unnecessary-react-component-re-rendering-3c08 for all details.
You can trace re-rendering by following this post: https://jsramblings.com/how-to-check-if-your-component-rerendered-and-why/
Best,
Didier
This is very interesting situation! The fact that you see different DynamoDB read usage between Postman and your React App suggests that the difference is likely in how the requests are being made or handled, rather than anything intrinsic to DynamoDB itself.
Here are a few possible causes to consider:
-
Frequency of Requests: If your React App is making more requests per second than Postman, this could account for the increased read usage.
-
Parallelization of Requests: If your React App is making multiple requests in parallel, this could cause a spike in read usage. Postman typically sends requests one at a time.
-
Data Volume: If the React App is fetching more data (more items or larger items) than Postman, this would result in more read capacity unit usage. Remember, DynamoDB charges read capacity units based on item size, with one unit representing one read per second for items up to 4 KB.
-
Consistency: DynamoDB has two read types: eventually consistent and strongly consistent. Strongly consistent reads use twice the read capacity units as eventually consistent reads. Check if there's a difference in the consistency model between your Postman and React App requests.
To debug this, I would recommend you start by logging detailed request and response information in both Postman and your React App. Compare the logs to identify any differences in the frequency of requests, the size of the data being fetched, or the request parameters. AWS X-Ray can also be useful for tracing requests and identifying bottlenecks or differences in request handling.
Hope this helps !!
Thank you for your response! It actually turned out that I forgot to use a dependency list for my useEffect hook in my React App, which essentially caused it to call the DB multiple times, resulting in the spike.
Relevant content
- asked 10 months ago
- asked 5 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated a year ago
You are absolutely right! I didn't not have a dependency list in my useEffect hook where I made the HTTP request, and I should know better than that. Once I declared the dependency list, no rerender, no spike!
Happy that you found the root cause of your issue! Didier