Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does pg_net fit into the overall supabase architecture? #73

Closed
psteinroe opened this issue Sep 28, 2022 · 4 comments · Fixed by supabase/supabase#9803
Closed

How does pg_net fit into the overall supabase architecture? #73

psteinroe opened this issue Sep 28, 2022 · 4 comments · Fixed by supabase/supabase#9803
Labels
documentation Improvements or additions to documentation

Comments

@psteinroe
Copy link

Hey,

we are making quite heavy use of pg_net, mainly to make a request to an external api from within a trigger. For some of these, we will now migrate to a postgres-based queue (postgraphile-worker / pg-boss) to have better observability.

During the migration, I began to wonder how pg_net fits into the supabase architecture, for what use-cases it is supposed to be used and what its limitations are, especially regarding performance.

As an example, we are using segment to collect usage data and want to track events from within the database. One option would be to use pg_net to make a request to the Segment API. We created a simple segement.track function which makes the request using pg_net. When our usage grows, we might get a few events per seconds. How much requests is pg_net supposed to handle? As an alternative, we could either send the requests batch-wise or use a queueing solution and drop pg_net. Further, a webhook or queuing plugin for realtime would probably be a more scalable alternative.

Is there any official guidance on the scalability and intend of pg_net?

Best
Philipp

@psteinroe psteinroe added the documentation Improvements or additions to documentation label Sep 28, 2022
@steve-chavez
Copy link
Member

How much requests is pg_net supposed to handle?

Right now it's configured at 200 requests per second, you can check this with show pg_net.batch_size.

pg_net.batch_size can be increased but doing so will make the pg_net worker have a higher CPU usage - we expect to reduce this with #62.

for what use-cases it is supposed to be used
intend of pg_net?

It's used for webhooks. You can read more about the intend on https://supabase.com/blog/supabase-functions-updates#hooks-technical-design-pg_net-v01

@psteinroe
Copy link
Author

Thanks for the reply!

It's used for webhooks.

What is the reason for Webhooks still being in beta?

Maybe we could add a few common usage examples in the docs? I encountered a few people already that were having problems with using pg_net, e.g. for sending a request from within a trigger. Doing as much as sending them this gist already helped. Common questions that should be answered in the docs:

  • How many req/s can pg_net handle?
  • Linking or copying parts of the blog post about Webhooks
  • How to use the authorisation of the current user in the request?
  • How to use pg_net from within a trigger?

I think this would help people a lot.

@steve-chavez
Copy link
Member

What is the reason for Webhooks still being in beta?

Once pg_net hits 1.0, Webhooks should be stable. For this we'd need to close #62 and #49.

Development on pg_net stagnated for a while but since #68 (a revert of a previous change) we're able to pick up dev again. So I expect pg_net to hit 1.0 for next launch week tops.

Maybe we could add a few common usage examples in the docs?

Absolutely, thanks for the suggestions. The interface will change a bit when #62 is done so I'll keep this issue open for now.

@liaujianjie
Copy link

So I expect pg_net to hit 1.0 for next launch week tops.

This is very exciting news. I have the exact same use cases and concerns as as @psteinroe—we wish to make API calls to Segment and are worried about limits and failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants