Live data from Hacker News

Show HN: Skor – Drop-in microservice to get Postgres changes as JSON webhooks

github.com

31–39 of 39 posts

Re: Show HN: Skor – Drop-in microservice to get Postgres changes as JSON webhooks

#31
post #5

Looks cool. Seems like a good alternative if you can’t use listen/notify for some reason. I’ve used listen/notify with triggers for a while with good success. The flexibility of my apps controlling what they want to listen for instead of having that config elsewhere. Downside to l/n is that if you aren’t listening you aren’t getting changes. Seems like the same is true if the webhook fails here since there isn’t a re…

Unfortunately, most of these LR programs don't work in AWS (RDS) land, since they require PG plugins, and RDS LR only supports the built-in test decoder. I wrote a similar program that uses LR to stream changes to AWS's Kinesis[1], using a mini library that parses the output of the default test decoder[2] as a result, in case anyone else is in RDS and has the same limitation. [1] https://github.com/nickelser/pg_kines…

RDS supports wal2json.

Re: Show HN: Skor – Drop-in microservice to get Postgres changes as JSON webhooks

#32
post #11
post #5

Looks cool. Seems like a good alternative if you can’t use listen/notify for some reason. I’ve used listen/notify with triggers for a while with good success. The flexibility of my apps controlling what they want to listen for instead of having that config elsewhere. Downside to l/n is that if you aren’t listening you aren’t getting changes. Seems like the same is true if the webhook fails here since there isn’t a re…

Hi I did use Debezium in a Kubernetes cluster to stream Postgres changes into Kafka and then through a custom application that can send them to clients via HTTP or WebSockets. But the entire system had multiple points of failure. So we then decided to write our own thing that connects to the LR slot and sends over WebSockets. Working on open sourcing that too!

can you talk more about the points of failure? and is there a place I could sign up for more information when you open source your websocket solution?

Re: Show HN: Skor – Drop-in microservice to get Postgres changes as JSON webhooks

#34

Cool! Does this handle rate limiting or retries?

Currently there is no support for rate limiting or retries of webhook calls. I've opened an issue ( https://github.com/hasura/skor/issues/7 )

Cool - I didn't expect this, but was curious.

Re: Show HN: Skor – Drop-in microservice to get Postgres changes as JSON webhooks

#35

This looks cool, and another approach is pg_amqp_bridge to send events like this into rabbit. A nice feature is that the triggers don't block: https://github.com/subzerocloud/pg-amqp-bridge You can then push to websockets from rabbit with STOMP https://www.rabbitmq.com/web-stomp.html

> pg_amqp_bridge

Thanks for posting this. Can already see a couple of weekends burned trying to drive celery from pg.

Do you know if it is used in production somewhere; how battle-tested is it?

Re: Show HN: Skor – Drop-in microservice to get Postgres changes as JSON webhooks

#36

Earlier quoted context omitted.

100 webhook calls as the trigger is executed whenever a row is modified. Postgres's per statement triggers don't let you capture the rows that are modified and skor doesn't do any sort of batching currently.

> Postgres's per statement triggers don't let you capture the rows that are modified They do these days. Since 10 you can specify: REFERENCING { { OLD | NEW } TABLE [ AS ] transition_relation_name } [ ... ] ] in a FOR EACH STATEMENT ... AFTER trigger.

That's great news ! So the trigger can use json_agg to compose the notification with all the modified rows. We'll document it (https://github.com/hasura/skor/issues/8).

Re: Show HN: Skor – Drop-in microservice to get Postgres changes as JSON webhooks

#37

This looks cool, and another approach is pg_amqp_bridge to send events like this into rabbit. A nice feature is that the triggers don't block: https://github.com/subzerocloud/pg-amqp-bridge You can then push to websockets from rabbit with STOMP https://www.rabbitmq.com/web-stomp.html

> pg_amqp_bridge Thanks for posting this. Can already see a couple of weekends burned trying to drive celery from pg. Do you know if it is used in production somewhere; how battle-tested is it?

I've used it in a couple production deployments and it's solid. It's only ~300 lines of Rust code, so I'm confident it is simple and even if I had a problem, would be easy to understand.

Re: Show HN: Skor – Drop-in microservice to get Postgres changes as JSON webhooks

#38
post #11

Earlier quoted context omitted.

Hi I did use Debezium in a Kubernetes cluster to stream Postgres changes into Kafka and then through a custom application that can send them to clients via HTTP or WebSockets. But the entire system had multiple points of failure. So we then decided to write our own thing that connects to the LR slot and sends over WebSockets. Working on open sourcing that too!

can you talk more about the points of failure? and is there a place I could sign up for more information when you open source your websocket solution?

Hi. Sorry for the late reply.

Well the system had Postgres -> Debezium -> Kafka -> CustomApp -> Client. If data stopped flowing through the system, I would have to examine each component to figure the issue out. They'd mostly turn out to be Kubernetes network issues such as Kafka brokers not being able to talk to each other, or Debezium not being able to contact Kafka. This was too painful to run when all we wanted was notifications of changes on Postgres.

If you drop me a note with your email, I'll make sure to get in touch with you when our solution using Postgres LR exposed over WebSockets (and more) is out :)

Re: Show HN: Skor – Drop-in microservice to get Postgres changes as JSON webhooks

#39

This problem is one of my biggest needs with postgres, although its certainly not limited to pg. listen/notify is fragile - you either have a single point of failure or you run multiple workers and have to deal with de-duping. Logical replication might one day be an answer, but not likely to ever work completely and without issue on cloud hosted instances. (maybe im wrong about this... see debezium comments elsewhere…

`table -> trigger to log table -> trigger to notify` is exactly the right solution here. You can even use the same stored proc to replay old logs.
Post reply on HN