Repository navigation
feat: save bandwidth for clients - #395
Conversation
✅ Deploy Preview for hoppdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (7)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe change separates core user profile data from user-specific fields, updates authentication and handlers to use profile or full-user records, centralizes team-access calculation, and configures PostgreSQL connection-pool settings. ChangesUser profile and access flows
Database connection setup
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Refactor Suggested reviewers: Merge Risk: ⚪ Minimal · up to No demonstrated regression remains that should block merging after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
We had some excess egress, that we need to fix to reduce billing 👀
This PR is reading less of the users row on the endpoints the desktop app polls.
The app polls
/teammates,/calls/presenceand/userevery 10 to 30 seconds. Every one of those requests loaded the full user row prior to this change, includingsocial_metadata(about 1.3KB, I validated withpg_stat_statements_infohistorical data) andhashed_password. AlsoGetTeammatesre-fetched the current user and their team on every call.To optimize, which should drop the egress quite a lot below are the changes. Also ideally we would go to a websocket/event driven approach, but its quite a refactor for now:
UserProfilecolumns. That covers the auth helper, the websocket handshake, teammates and presence./user, onboarding and the Linux waitlist still load the full row because they need the JSON columns.GetTeammatesno longer re-fetches the current user, and it selects only profile columns for teammates.UpdateNameandChangeTeamwrite only the columns they change instead of saving the whole row.TeamAccessstruct.pg_stat_statementsas repeatedpgbouncer.get_authandDISCARD ALLqueries.unsubscribe_id, andRemoveTeammatereturns500instead of400when the database fails (also drive-by).Super rough estimate, database traffic per polled request drops from about
4.25KBavg to1.5KBavg, which takes us from around15GBto around5GBof egress a month.