I’m working on a backbone rails application that needs to poll the server to sync collections and models that may have changed. The prototype I have built works by continuously running the fetch() method on a collection of (JSON) packets with javascript’s setTimeout.
This works fine but I’m wondering how it would scale and how much maintenance overhead this requires. I’m thinking that I need to build a custom protocol much like http where the rails API sends packets to the client and the client responds with information about if it received the packet etc. Currently, the application receives packets that expire in a short time which isn’t very robust or efficient.
Are there any protocols I could leverage or what steps would I take to build my own simple protocol. I want to abstract this out into something that requires little effort for other developers to understand. Best practice.
As someone who has personally “been there, done that”, I think you are pre-optimizing. That is to say, looking for a problem so you can create a solution. I would stick with the standard protocols for now, and if or when it becomes a problem, then look at optimizing techniques. I can almost guarantee, it will take way more time, debugging, etc. to develop a protocol as robust and simple as HTTP. HTTP can be a very lightweight protocol.
But if you don’t want to heed my advice, XMPP is a good lightweight messaging protocol.
Good luck.