djbalinD
Convex Community14mo ago
4 replies
djbalin

Bandwidth usage multiplied by piping arguments?

Hellooo!

I noticed that one of my daily cron jobs is incurring rater high bandwidth usage. We have a video streaming app, and this cron job collects all watch events within the past 24 hours (using the _creationTime index) and populates three aggregates with these documents.

My specific question is this: Let's say I query 1 MB worth of data and call four functions with this as an argument:
const obj = await ctx.db.query("watchSessions").collect() // 1 MB of data
fn1(obj)
fn2(obj)
fn3(obj)
fn4(obj)


Would this already incur +4 MB of bandwidth usage? As far as I can tell, objects are passed by reference as arguments to functions in JS, so I suppose not? What if instead of regular JS functions, I schedule/run four Convex functions:

const obj = await ctx.db.query("watchSessions").collect() // 1 MB of data
await ctx.runMutation(api.mut1,{obj})
await ctx.runMutation(api.mut2,{obj})
await ctx.runMutation(api.mut3,{obj})
await ctx.runMutation(api.mut4,{obj})
Was this page helpful?