Tuesday, 14 March 2017

Implementing realtime update without using 3rd party services

I'm working on a project that needs to update in realtime.

I've been using websockets to accomplish this for the minimum viable product, but now that i'm getting to release this I'm seriously re-considering the stack.

For reference, I use Heroku for hosting this web app.

In fact I have two separate dynos: One for simply hosting content (Rails app), and the other for handling websocket connections (node.js app). I synchronize between the two using a redis pub/sub.

The reason I did it this way was because I wanted to decouple the realtime component from the core app to minimize scaling problems.

That said, I am a total newbie at this type of scaling issue and have just learned that a single Heroku dyno can support up to around 1500 connections (Websocket concurrent connections limit on Heroku)

  1. First of all, does this mean if there are say, million users looking at the website concurrently, I will need 1,000,000/1500 = 666 dynos?
  2. If this is the case, I don't think it's a good idea to take this approach. Can anyone suggest a better idea so that I can scale this easily? (Any suggestion is welcome)

Note: I'm not looking for SaaS options like Pusher or PubNub, I would like to keep it self-hosted because I want to control my own destiny. (But the main concern for this is cost as I scale this so if anyone thinks these services are actually much more cost-effective for my situation please feel free to point out)



via Vlad

No comments:

Post a Comment