1

Simple console timing shows that fb loads much slower than desired (just 50 chat items).

load: 171.226ms
fbload: 1723.570ms 

load: 182.672ms
fbload: 2143.836ms

The normal load is from my mongodb and fbload is firebase. Despite my mongo being not denormalized fb is order of magnitude slower.

  1. Is there something I can do to increase performance?

  2. I'm using angularfire and I can load the initial from my own database and then replace it with the fb data. For this solution is there some way I can get the fb data to sync and bind onto existing dom elements as to avoid repainting the layout?

Code This is how I'm benching the fb time.

console.time('fbload')
$scope.chatLog = $firebase(fb.child('view/r/' + id).endAt().limit(50));
$scope.chatLog.$on('value', function () {
    console.timeEnd('fbload')
})

Edit:

My guess is that this is due to the websocket handshake. Firebase should initially just use xhr to get the data and only rely on websockets after connection. Still this needs a solution. Any ideas?

Harry
  • 52,711
  • 71
  • 177
  • 261
  • Perhaps you should show how you are binding currently in your question, which might give others something to work with. – Neil Lunn Apr 29 '14 at 02:05
  • @NeilLunn Added a bit of code thanks. – Harry Apr 29 '14 at 02:19
  • Those times seem extremely uncharacteristic for Firebase. What version of Firebase are you working with? Also, have you tried cutting out angularFire from the equation? Have you attempted to access the data via any other means (i.e. a GET request) to have a baseline? Where are you accessing the data from? Where is that in relation to your mongo instance and your Firebase instance? What version of what browser are we working with? Is it behind a Firewall or proxy? More due diligence is needed here before anybody could hope to make an educated guess as to where your latency is. – Kato Apr 30 '14 at 20:53
  • @Kato thanks, I'm using version 1.0.11. Get requests return in about `150-200ms`, which is what it should be. Using angularFire and no angularFire is about the same `(1.5s - 2s)`, it doesn't look like angularFire is responsible for any slowdowns. Getting new refs on firebase is about `400ms-600ms` after connection, still slower than I'm expecting going from the GET speeds. I'm testing on chrome 34. No firewall or proxy. – Harry May 01 '14 at 03:21
  • @Kato thanks for your help, please tell me if there's anything else I should consider. I'm expecting the initial connection to be slower than subsequent connections, it's not surprising. Does firebase do anything to counteract that problem? Though the initial load is only 1 load it's also the most important load. Thanks man. – Harry May 01 '14 at 03:23
  • @Kato what do you see here? Here's a benchmark using my production db: http://jsfiddle.net/5pyy4/1/ – Harry May 01 '14 at 03:40
  • It is the initial connection that is taking so long. I am seeing around 450-500ms using that fiddle, and sometimes 700ms on the first load (when it caches the scripts). However, if I make [a slight adjustment](http://jsfiddle.net/katowulf/6dSA7/) to start times after connection is established, times drop to 200ms. – Kato May 01 '14 at 06:09
  • Thanks for taking the time to dig in a bit! – Kato May 01 '14 at 06:15
  • @Kato umm, yes I know. The question is how to fix that. That's what I've been saying. This is a solved problem in socket.io so I was surprised to find it in firebase. The console.time really needs to go before the connection to accurately get the times as is relevant from the user's perspective. – Harry May 01 '14 at 06:16
  • @Kato do you work for firebase? The solution as I've generally seen is to use xhr to get the data for first initially and upgrade to websockets only after the connection is confirmed. Do you know if it's possible to do that with firebase? For example I'm not seeing a way to do limit with the rest api. But if it is possible it should be built into angularfire. – Harry May 01 '14 at 06:23
  • I put in a task for the dev team to profile connection times and see if there are any improvements to make. – Kato May 01 '14 at 16:49
  • @Kato it's also not just for performance, ajax is also an easy way to figure out when an initial load has happened for phantomjs and prerendering. – Harry May 03 '14 at 10:10
  • @Harry the comment thread on SO isn't the greatest place to debate pros and cons of various approaches. Your thoughts here are well formed and your experience on the topic shines through. But there is always a great deal more to implementation than "just do it this way because it's best." If you'd like to chat with the the dev team, you can visit (virtually or physically) during office hours. I'm sure they would greatly appreciate your insights and obvious experience on the topic. Cheers. – Kato May 05 '14 at 15:53
  • Do you store any images in your data at all? Is your data just text characters? – Nick Lewis May 28 '14 at 11:41

0 Answers0