graphql-engine icon indicating copy to clipboard operation
graphql-engine copied to clipboard

Configure Event Polling Interval

Open raphaeltm opened this issue 6 months ago • 5 comments

Is your proposal related to a problem?

For context, we're using Hasura Cloud with a Vercel Postgres instance. As I understand it Hasura's eventing system uses a poller. That means it needs to be continuously connected to the database. That isn't ideal in a serverless environment, where the pricing is based on very granular compute time. In our case, we only use eventing for a scheduled process which uses a fan-out architecture. It doesn't really matter if events run hours after the actual operation in our case. It's a small side project, which is starting to cost more than some of our small production applications because of this combination we're testing out.

Describe the solution you'd like

I would like to be able to configure the polling interval. In our case, maybe every hour. I would also like to be able to better understand and configure how many events would be processed at a time when the poller runs.

Describe alternatives you've considered

Using a different database provider. That would be fair, but this setup is quite nice if we can make it work.

We could also just run a cron ourselves or using a different queueing mechanism, but then we would lose some of Hasura's benefits.

raphaeltm avatar Dec 19 '23 05:12 raphaeltm

I would also like to clarify something: if we don't have any events in Hasura, does the poller turn off, and will our database usage drop down? My assumption is yes. But I don't know if Hasura does other things that might be problematic and keep the database awake in a serverless database environment.

raphaeltm avatar Dec 19 '23 05:12 raphaeltm

@raphaeltm you can configure the event polling interval by setting HASURA_GRAPHQL_EVENTS_FETCH_INTERVAL env var.

More details - https://hasura.io/docs/latest/event-triggers/observability-and-performance/#performance-tuning

if we don't have any events in Hasura, does the poller turn off

Yes. If there are no events, then the event poller is not started.

ecthiender avatar Dec 20 '23 10:12 ecthiender

@ecthiender amazing, thanks! I don't know why I had so much trouble finding that. It's quite clear.

raphaeltm avatar Dec 20 '23 14:12 raphaeltm

@raphaeltm you can configure the event polling interval by setting HASURA_GRAPHQL_EVENTS_FETCH_INTERVAL env var.

More details - https://hasura.io/docs/latest/event-triggers/observability-and-performance/#performance-tuning

if we don't have any events in Hasura, does the poller turn off

Yes. If there are no events, then the event poller is not started.

@ecthiender FYI, I tried to configure this in Hasura Cloud and it won't let me. The value shows up in red and the "add" button is disabled as you can see in the following screenshot (I don't know if this comment should be in another location):

CleanShot 2024-01-15 at 10 41 17@2x

raphaeltm avatar Jan 15 '24 18:01 raphaeltm

@raphaeltm ah! Support for this env var is missing on the cloud dashboard. Let me get back to you on this.

But you should be able to use it in your local dev or self-hosted instances, till we add support for this on the cloud dashboard. I'll keep you posted on it.

ecthiender avatar Jan 17 '24 08:01 ecthiender