Press enter to see results or esc to cancel.

Pusher for Rails

image

Modern web apps require tremendous amount of data exchange between client-server side, it needs some architecture that can handle such thing. There are 3 methods that we already implemented to handle real-time sync between front end and back end.

  • Javascript setIntervall poll

We implemented this to create real-time effect, so basically all we need to do is we write javascript poll function which check to the server and update front end respectively, and we create intervall to always call this poll function. simple.

  • Push from server using forever loop

The problem of using poll is it is very expensive CPU Utilization (we did benchmark using amazon EC2). So we move to this architecture. We create poll function in javascript, which check to the database, but the different is we also create check function inside this database:

  • Using Pusher

Push from server looks promising, everything work and CPU Utilization also quite low. But there is a problem after we move to Heroku. Push from server like we did in previous one is quite bad because every single user will create a thread which will terrible if there are, say, 1k user who post at the same time. Luckily Heroku provide adds on called Pusher (actually it is different product with Heroku, and we can use without on Heroku). It is very simple to implement and it seems very scalable because we don’t need to care the pusher server ourself, instead there are 3rd party who we can rely on.

Comments

Leave a Comment

Show Buttons
Hide Buttons