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

Performance Optimization for Followers/Following Page Load Times #37

Closed
wants to merge 1 commit into from

Conversation

petecheslock
Copy link
Contributor

Context

The followers page has been experiencing significant slowdowns in production, leading to a poor user experience. Initial analysis pointed to multiple potential issues, including inefficient database queries, the N+1 query problem, and suboptimal data handling during rendering.

Improvements Made

Database Queries Optimization: Implemented indexing on the users and relationships tables to speed up query execution. This change was guided by the observation of slow database access patterns for follower data retrieval.

Eager Loading to Combat N+1 Queries: Modified the data-fetching logic to use .includes for eager loading associations. This change directly addresses the N+1 query problem observed in our AppMaps, where each follower's details were fetched in separate queries.

Rendering Efficiency: Improved the rendering process by introducing partials and collection rendering for followers. Additionally, implemented caching strategies for parts of the page that are less dynamic, significantly reducing the server's work during page rendering.

Pagination Implementation: Implemented pagination for the followers list to limit the number of records fetched and rendered on each page request. This approach not only speeds up the page load but also improves the user experience by not overwhelming them with too much data at once.

Benchmarking and Monitoring

Utilized Rails' built-in benchmarking tools to measure the performance improvements, with a noticeable decrease in page load times and query execution times. Monitoring will continue to ensure that the changes remain effective under varying loads.

Next Steps

Future considerations include further optimizing the cache strategy and exploring additional areas in the app where similar performance improvement techniques can be applied.

Copy link

AppMap runtime code review

Summary Status
Failed tests ✅ All tests passed
API changes 0️⃣ No API changes
Security flaws ✅ None detected
Performance problems ✅ None detected
Code anti-patterns ✅ None detected
New AppMaps 0️⃣ No new AppMaps

@petecheslock petecheslock deleted the feat/fix-n1-follow-followers-page branch March 12, 2024 20:48
@petecheslock petecheslock restored the feat/fix-n1-follow-followers-page branch March 13, 2024 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant