#Does Convex count updates from query as function calls?

18 messages · Page 1 of 1 (latest)

raw mantle
#

For example, if we call query function and it triggers 10 updates (there's 10 mutations happening that cause the query to send updates to clients), would this incur cost as 1 function call or 10?

I presume that the cost is only 1 function call so it doesn't matter how many times this websocket connection sends updates.

still pondBOT
#

Thanks for posting in #1088161997662724167.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.

    - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
    - Use [search.convex.dev](https://search.convex.dev) to search Docs, Stack, and Discord all at once.
    - Additionally, you can post your questions in the Convex Community's #1228095053885476985 channel to receive a response from AI.
    - Avoid tagging staff unless specifically instructed.

    Thank you!
elder ferry
#

Yes, every update is a function call. A large amount of this is typically cached, and the team has mentioned treating cached responses differently than non-cached for billing purposes in the future, but currently they're treated the same.

#

I don't fully understand the details of the example case you shared - queries won't ever trigger updates, only mutations will - but in the simplified case where 10 app users are on a page with the same query and the underlying data changes, that'll cause 10 function calls to the query. I assume 9 or 10 of these would be cached, but that goes beyond my understanding.

brittle star
#

for a subscription to a query, indeed each mutation function that changes it , unless they happen very quickly together, in which case they could be combined, does trigger a new query call.

#

Caching pays off when you have multiple clients subscribed to the same query, or repeatedly request a query or subscribe/unsubscribe on one client

brittle star
#

If this isn't desirable, you can choose not to subscribe! Often the writes in applications are rarer than the reads and this update live behavior is what you want, but you can always treat convex like an api server and refresh data when you want to, eg every few minutes or whenever the user refreshes the page.

elder ferry
#

Adding a note from Jamie for posterity, cached calls count as function calls but don't use bandwidth: #general message

raw mantle
#

Doesn't this mean Convex is quite expensive if we have lots of free users?

#

Basically every time a user sees updates in the webpage due to mutations, we can count it as 1 function call right?
Example: see likes number go up, see new comment, etc

still wave
#

But yeah they stated in a podcast that convex SHOULD be used on projects that are making money

uneven stump
tight star
#

any update on whether or not a cached query avoids using a function call @brittle star or @elder ferry ? maybe I'm thinking of it wrong but would seem a bit egregious if you have heartbeat-like queries e.g. to show how many total users are online, if you have 1,000 users online at all times and give updates every 5 minutes, that's 1k function calls every 5 min, 12k/hour, so 8mm calls / month just from this. If caching didn't charge the dev using convex, it would be 1 function call every 5 min, 12/hr, 8k calls / month which is much more palatable

elder ferry
#

Each individual subscribed client does make a function call when changes occur, so if you have a lot of users it's a lot of function calls. Your scenario of 8m function monthly function calls would cost $15 per month for function call overage, which feels pretty reasonable (imo) for servicing 1,000 active users.

#

I think 8m just feels like a big number, but Convex is sort of designed to run lots of small operations, and to try to make it relatively cost effective to do so. A high traffic app is just going to have a lot of function calls. Having really effective caching to avoid database bandwidth charges makes this generally tenable.

elder ferry