We’re designing a backbone application, in which each server-side collection has the potential to contain tens of thousands of records. As an analogy – think of going into the ‘Sent Items’ view of an email application.
In the majority of Backbone examples I’ve seen, the collections involved are at most 100-200 records, and therefore fetching the whole collection and working with it in the client is relatively easy. I don’t believe this would be the case with a much larger set.
Has anyone done any work with Backbone on large server-side collections?
- Have you encountered performance issues (especially on mobile devices) at a particular collection size?
- What decision(s) did you take around how much to fetch from the server?
- Do you download everything or just a subset?
- Where do you put the logic around any custom mechanism (Collection prototype for example?)
Yes, at about 10,000 items, older browsers could not handle the display well. We thought it was a bandwidth issue, but even locally, with as much bandwidth as a high-performance machine could throw at it, Javascript just kinda passed out. This was true on Firefox 2 and IE7; I haven’t tested it on larger systems since.
We were trying to fetch everything. This didn’t work for large datasets. It was especially pernicious with Android’s browser.
Our data was in a tree structure, with other data depending upon the presence of data in the tree structure. The data could change due to actions from other users, or other parts of the program. Eventually, we made the tree structure fetch only the currently visible nodes, and the other parts of the system verified the validity of the datasets on which they dependent independently. This is a race condition, but in actual deployment we never saw any problems. I would have liked to use
socket.iohere, but management didn’t understand or trust it.Since I use Coffeescript, I just inherited from Backbone.Collection and created my own superclass, which also instantiated a custom
sync()call. The syntax for invoking a superclass’s method is really useful here: