Photo by Chen Hu on Unsplash.
At Setter we have a 2nd generation API server that handles:
API requests coming in from internal software
API re...
For further actions, you may consider blocking this person and/or reporting abuse
I looked into postgres and loved the concept, but in practice, I was using pgbouncer as a connection pool with aggressive connection sharing, and I think pgbouncer did not support the notify/listen commands, and even if it did, I think keeping transactions open was required which meant all the waiters would need separate real connections to the db, which ate up resources and created more problems. That's not to say I couldn't have overcome that barrier but at the time I considered it too risky to try or research further.
Like you, I prefer being able to debug and fix my own applications vs worry about configuration / the learning curve of other software, particularly when my needs are specific. I just rolled my own notifications, of 2 types:
Some things to keep in mind:
Wow, first of all don't do it.
Second, a nice way to decouple the 3 steps you said is with "functions, serverless", it fits your example very well ( async events that triggers 2 separate functions).
First point again, a few notes:
PS: I may be wrong, I'm not deeply familiar with PostgreSQL
PS2: there is no such thing as zero dependency, if you guys do this system in house you are creating a new project (in project), that requires your attention, tests, time and resources. Also the system is dependent on your business logic, infrastructure and database (things that can be mitigated by using a PaaS / cloud PUB/SUB))
I like this idea quite a bit. We actually have a postgres based setup at work plus a rabbitmq and it would be nice to try to eliminate a moving piece (rabbit) if I can. I love rabbit but I love minimalism even more. The only disadvantage I can think of is giving all the nodes access to the database which I may not want to due to security considerations.
Agreed, opening up access to all nodes is a serious drawback to this approach but I am sure that there are ways to go around this.
How are you and your colleagues liking RabbitMQ. We too are big fans of minimalism. Have there been some unexpected downsides to to introducing rabbit (besides having an additional moving piece)?
I'm a big fan of rabbit. Used it in production on several occasions for rather large (hundreds of messages per second) deployments and it worked really well for me. It's very easy to setup and it just sort of works.
Minimalist would be a simple Redis, like other said. You can get also persistent storage (from time to time), performance and scaling (if needed).
Slack devs are also reticent to new dependencies and avoids adding new tech in their stack, you can read about their Job Queue system here, which is exactly what you need too (more or less). The old system is on redis (previous version, probably is enough for your needs)
Why don't you use a Redis task queue to see how it goes?
You can create a dedicated database user that has access to certain tables.
Classical
Pub/Sub
might not be a best fit, some of the reasons Adrian outlined pretty nicely for you in his comment.May I propose to consider
Event Sourcing
pattern? You don't really remove or modify any records -- you just append them. Usually this pattern is being used withCQRS
pattern -- it brings really nice scaling advantages later on into your project.I think the requests and the results (process and email) are ephemeral, so they do not need to be kept indefinitely. Event sourcing solves the problem when you need to keep all the previous states of the entities (kind of), I don't think this is the case. The requests are unique and do not change either need to be kept for longer period of time.
Hey Gio, great post!
Just my two cents on this topic.
Apparently, your problem is one I was facing in my previous company: how to deal with scale.
It also appears that the first step to decouple your application was taken: boundaries have been defined for third party systems and completely removed from your core business logic.
There are some contenders out there to PostgreSQL that are minimal and perform quite well.
I'm a big fan of Nats. I mean, dead simple, blazing fast, and Just Worksβ’ out of the box. It's also under the CNCF, so it shows a lot of promise.
Having that well defined boundary around this kind of dependency should make it trivial to use. It needs some special care, e.g. defining your own request/response mechanism in order to achieve at-least-once semantics, but in my opinion this extra step is well worth it.
thanks, nice example of postgres pub sub
If you are on AWS I would recommend going with SNS/SQS for pub sub. As another user mentioned, Event Sourcing might be a good alternative. In that case I would look at AWS Kinesis / DynamoDB