Does Convex count updates from query as function calls?
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.
7 Replies
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 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!
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.
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
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.
Adding a note from Jamie for posterity, cached calls count as function calls but don't use bandwidth: https://discord.com/channels/1019350475847499849/1019350478817079338/1374042998274261092
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
You can use server components if you want to prevent the data from being refreshed, and refresh the page with next invalidate route
But yeah they stated in a podcast that convex SHOULD be used on projects that are making money
Pays off in terms of bandwidth, or also function calls? Do I understand correctly, that even if the query is cached, it still consumes the function call?
I couldn't really find information about this in the docs and that's how I stumbled upon this thread. Just wanted to clarify, because function calls seem to be one of highest possible costs for my app.