Closed WcaleNieWolny closed 1 year ago
Further price calculation would require data from @riderx (Number of apps, price for supabase, number of devices that are overwritten in any way, number of devices, perhaps even active uses of all apps, request to the updates endpoint per day)
Also AB testing / progressive deploy is an interesting issue. This is not easy to implement however it would allow capgo to scale more efficiently
I have implemented further PoC for this. I have modeled the redis data in the following way:
This allows for a very efficient caching of data.
When someone uploads a new version we invalidate (remove) all of the ver_*
keys from this hash (hash is just an object in redis AFAIK)
When someone overwrites a device we remove said device from the cache thus allowing the cache keys to stay between version uploads. The way I see this is that we can have the ver_*
keys with an infinite TTL and the device_*
keys with a TTL of 3 days (for example 3 days)
Further information on this:
I will not be using lua. Lua is pointless, sure it might reduce the overall reads but it adds complexity and a potential bottleneck. In the PoC I managed to avoid lua.
Another thing is that I think that in the final impl the old endpoint will get removed and replaced with an internal JS call (Thus avoiding the entire network stack allowing for faster caching)
Redis also add a lot of options for improving the stats
endpoint as it adds the pub/sub
(allowing for batch SQL updates) or potentially moving stats from supabase to redis
I am strongly in favor of using zod for the new edge functions to avoid manual parsing.
Please let me know if the usage of zod
is acceptable
For provider, I was more thinking of this: https://upstash.com/docs/redis/overall/pricing it's more made for serverless. What do you think ? For zod, i'm not sure why you need it, can you elaborate more ?
I used zod as it allowed for quick and easy prototyping. It reduced the complexity of the code and decreased the potential for undefined errors.
I believe zod is not necessary for this, however migrating the manual parsing in all of the edge fns to zod might increase the overall error quality in our product
Currently the update url does not use any caching. I propose we add redis to reduce the load on the postgress db My proposal is to do the following:
cached_updates
urlupdates
url, (require API_KEY making it internal)cached_updates
getapp_id
,device_id
,version_name
from the requestThis script should have the following logic: (pseudo code)
This new endpoint would handle communication between redis and the old endpoint. A simple PoC can be seen here
We would also create new endpoint for invalidating cache (for example when new version is uploaded or device is overwritten)
As for the costs, it is hard to say how much we would save. I included a price calculation for redis with my current data but I am not sure how much load we can remove from supabase and how much supabase currently costs.
Given that we have 7M request per day (data from martin, not sure how accurate) and would probably fit in some of these fixed plans (redis enterprise)
I strongly believe that with a strong caching we can reduce the load on supabase by at least 50-80% making the extra cost worth it