Add guide for building a scalable notifications center using Ably#2985
Add guide for building a scalable notifications center using Ably#2985splindsay-92 wants to merge 33 commits intomainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
166f898 to
627366b
Compare
GregHolmes
left a comment
There was a problem hiding this comment.
Nice guide! Just a few comments left.
1908488 to
f57d1bf
Compare
m-hulbert
left a comment
There was a problem hiding this comment.
Added a few comments and questions, but this is looking good.
|
|
||
| Clients may not always be online when a notification arrives. Ably provides multiple mechanisms to ensure they receive important notifications: | ||
|
|
||
| ### Short-term message history |
There was a problem hiding this comment.
I'm not sure this can really be classified as a method for handling offline notifications, as you'd need to know the duration each client has been offline for in order to ensure no notifications were missed.
There was a problem hiding this comment.
I don't think tracking duration is a prohibitive problem, but perhaps this section would be better renamed to Temporary disconnections and focus only on connection recovery for short term?
|
|
||
| The right integration depends on your throughput, ordering requirements, and infrastructure: | ||
|
|
||
| **AWS Lambda / Serverless Functions:** |
There was a problem hiding this comment.
This section is a bit overwhelming in terms of bold and bullets.
There was a problem hiding this comment.
I've reworked this to use small paragraphs instead of the bullet/bold approach. I have kept the Recommended when: as I think its good to bring attention to this.
| }); | ||
|
|
||
| // Retrieve notifications received while offline | ||
| const historyPage = await inbox.history({ limit: 50, untilAttach:true }); |
There was a problem hiding this comment.
Wouldn't this require some way of knowing which notifications they've previously seen or acknowledged?
There was a problem hiding this comment.
Good point, I'll add in some detail around using the message.id field to check if a message has been handled.
| This is common in internal systems where notifications might inform clients of completed processes, | ||
| status updates, or system alerts that can be reviewed when a client connects. | ||
|
|
||
| ### Push notifications for critical alerts |
There was a problem hiding this comment.
What do you think about discussing;
- Direct vs channel publishing to matching up with your inbox vs general inbox pattern above?
- Web push in certain scenarios.
There was a problem hiding this comment.
I've tried to keep this diving too much into the push notifications guide, since this I think is all covered there. I've linked to that guide here too, although the link won't work until push notifications guide is merged.
f4e39f7 to
bcfe837
Compare
0fe5e16 to
82ee806
Compare
|
|
||
| Delivering notifications in realtime is critical for user engagement. Ably's [serverless architecture](/docs/platform/architecture) eliminates the need to manage websocket servers. It automatically scales to handle millions of concurrent connections without provisioning or maintenance, while handling all edge-cases around delivery, failover, and scaling. | ||
|
|
||
| For notifications that need to reach users even when they're offline, Ably integrates seamlessly with push notification services like [Apple Push Notification Service (APNS) and Firebase Cloud Messaging (FCM)](/docs/push), ensuring your users never miss important updates. |
There was a problem hiding this comment.
Should also include web push here
|
|
||
| When designing your notification center, consider the following channel structure: | ||
|
|
||
| <Code> |
There was a problem hiding this comment.
I'm not sure this needs to be a code snippet
|
|
||
| The decision comes down to cost and frequency: | ||
|
|
||
| * **Individual inboxes:** are best when broadcast notifications are infrequent. You pay per message published and per user receiving it. |
There was a problem hiding this comment.
I think we're missing a key aspect here - what about when only one person should receive a notification? Notifications specific to a given user shouldn't be sent to everyone.
There was a problem hiding this comment.
The caveat above this on line 65 states,
For notifications that need to reach all clients, you have two architectural options:`
So we are only talking about the cases where you want to talk to all users. Perhaps this section isn't clear enough, though? I could change the title to Handling broadcasts?
| </Code> | ||
|
|
||
| **History capability:** | ||
| Including the `history` capability allows clients to retrieve notifications they might have missed while offline. |
There was a problem hiding this comment.
Isn't this also something push would handle?
There was a problem hiding this comment.
I've reworked this whole section to focus on push, history is now only briefly mentioned.
| * Publish 1 notification to the general channel | ||
| * 10,000 clients are subscribed to the general channel | ||
| * Cost: 1 inbound message + 10,000 outbound messages = **10,001 messages** | ||
| * Plus: Channel attachment cost for 10,000 clients subscribed to the general channel |
There was a problem hiding this comment.
This is the same in Option 1 and 2. The billing dimension is connections, not attachments.
| * Cost: 1 inbound message + 10,000 outbound messages = **10,001 messages** | ||
| * Plus: Channel attachment cost for 10,000 clients subscribed to the general channel | ||
|
|
||
| If clients are connected for an average of 4 hours per day: |
There was a problem hiding this comment.
The channel minutes are based on the channel being active, not who's connected to it.
| * Channel minutes per client per day: 4 × 60 = 240 minutes | ||
| * Total channel minutes per month: 10,000 clients × 240 minutes × 30 days = **72,000,000 channel minutes/month** | ||
|
|
||
| #### Cost comparison |
There was a problem hiding this comment.
Given my comments above, I'll skip the remainder of the cost section for now
|
|
||
| ### Push notifications for critical alerts | ||
|
|
||
| For user-facing applications where notifications require attention even when the app is not running, push notifications can be used. These are particularly useful for social interactions, time-sensitive alerts, or critical updates that users should act upon immediately. |
There was a problem hiding this comment.
I'd personally like to see this session moved up and given more prominence - I think push is a key feature for notifications (more so than annotations). I would have expected it to form a core part of the solution.
…pecifically extended.
…o a single paragraph
… production checklist.
5484fad to
df84cdb
Compare
|
|
||
| Delivering notifications in realtime is critical for user engagement. Ably's [serverless architecture](/docs/platform/architecture) eliminates the need to manage websocket servers. It automatically scales to handle millions of concurrent connections without provisioning or maintenance, while handling all edge-cases around delivery, failover, and scaling. | ||
|
|
||
| For notifications that need to reach users even when they're offline, Ably integrates seamlessly with push notification services like [Apple Push Notification Service](https://developer.apple.com/notifications/) (APNS), [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) (FCM)] and [web push](https://developer.mozilla.org/en-US/docs/Web/API/Push_API), ensuring your users never miss important updates. |
There was a problem hiding this comment.
Extra square bracket after FCM
Description
Add a guide that focuses on building a notifications center with Ably pubsub using Ably integrations to perform pre-processing on outbound notifications.
FF-164
TODO: There are a few diagrams/images that might be useful, I will ask design once we are happy with the content.
Checklist