ScuffleTV / scuffle

Live streaming platform
https://scuffle.tv
224 stars 25 forks source link

Dataloaders #67

Closed TroyKomodo closed 1 year ago

TroyKomodo commented 1 year ago

Proposed changes

Dataloaders allow us to batch queries across requests which in turn make it very optimized at scale. Using the WHERE id IN ANY($1) SQL feature allows us to combine many queries into a single query which makes it very efficient at high concurrency requests.

We should also investigate how we can take advantage of redis caching to speed up results. The main issue with redis caching is how do we uncache stale data. Results need to be fresh always, that is a MUST there is no way we can serve stale data. So redis caching becomes a complex mess because invalidating cached data is very hard.

Types of changes

What types of changes does your code introduce to Scuffle? Put an x in the boxes that apply

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

codecov[bot] commented 1 year ago

Codecov Report

Merging #67 (9529c13) into main (5a0e6bf) will increase coverage by 0.46%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #67      +/-   ##
==========================================
+ Coverage   82.34%   82.80%   +0.46%     
==========================================
  Files          41       44       +3     
  Lines        1393     1442      +49     
==========================================
+ Hits         1147     1194      +47     
- Misses        246      248       +2     
Impacted Files Coverage Δ
backend/api/src/api/v1/gql/auth.rs 88.67% <100.00%> (-0.91%) :arrow_down:
backend/api/src/api/v1/gql/mod.rs 94.87% <100.00%> (+0.13%) :arrow_up:
backend/api/src/api/v1/middleware/auth.rs 90.24% <100.00%> (+0.24%) :arrow_up:
backend/api/src/dataloader/session.rs 100.00% <100.00%> (ø)
backend/api/src/dataloader/user.rs 100.00% <100.00%> (ø)
backend/api/src/global/mod.rs 100.00% <100.00%> (ø)