calebmer / connect

10 stars 2 forks source link

Direct Messaging #2

Open calebmer opened 5 years ago

calebmer commented 5 years ago

Who wants to own the direct messaging backend? Here are my current thoughts on what the backend looks like:

Here’s another thought…do we even need Direct Messaging? I don’t think we need it for an MVP.

baruchadi commented 5 years ago

I was going to suggest Socket.io just b/c i have experience w/ it :P didn't know RabbitMQ/Kafka were a thing. Socket.io is more generic though, so if they specialize in it they might be a better solution.

As for notifications, AWS has some kind of service for that. That would unite web/mobile by using one end point. other than that, if we use expo we could use the expo services, but that would be mobile only and we will need a different solution for web.

calebmer commented 5 years ago

Socket.io would be the “frontend” to the real-time architecture if that makes sense. RabbitMQ/Kafka answers the question of “how do you get new messages to your Socket.io server at scale.”

So the way the architecture I’m envisioning works is like this:

  1. I send a new message.
  2. The message is sent to an API server (like a POST request or GraphQL mutation)
  3. The message is stored in Postgres (for retrieval later)
  4. The message is sent to RabbitMQ/Kafka
  5. A Socket.io notification server receives the message from RabbitMQ/Kafka
  6. If the recipient is online use web sockets to push them the message.
  7. If the recipient is not online, send them a push notification.

There can’t be one Socket.io server at scale so you need some way to share messages between the entire backend. That’s what RabbitMQ/Kafka are for.

calebmer commented 5 years ago

Good to know AWS has a notifications service.