I've been working a bit harder on TogetherLoop, my social network. As I've said before, I don't know if it's a business, and right now that's not the point. Once I got the basics in place, I decided to tackle notifications. It's not my first time tackling something like this, as I implemented something similar in POP Forums a few years ago.
It's a pretty classic example of doing asynchronous, distributed work. When someone makes a like or a comment, the system shouldn't be hanging out and doing all of the work while the user waits. So it fires off a message to a queue saying that the event happened, and an Azure Function ("serverless") handles it. That function saves all of the data about the notification, and figures out who needs to see it. This is the part where the user can't wait for the work, which is why it happens in the background. If a hundred people need to be notified about a comment, it has to generate a hundred notifications, and then send each one.
The notification hits a Redis topic, where the backend API happens to be listening. That backend then uses a websocket connection to send each notification to the owning user, assuming that they're even online. That's a lot of bouncing around, but it pretty reliably delivers the notifications without bogging down the user.
Incidentally, I did try to have the AI design something, but even when I suggested that it should be an async process, it suggested a lot of patterns that were not particularly robust, or would be slow. But when I scaffolded everything out, using comments as pseudocode, it did things almost exactly as I wanted.
No comments yet.