0

I'm using Firebase's PHP API to update a Reporting/Dashboard AngularJS app as users do things through our application. The problem is sometimes when I do things too fast Angular app doesn't receive the new data from Firebase immediately. Then all of a sudden it receives a ton of new objects all at once instead of getting them one at a time as they happen.

Is firebase throttling the number of requests to their API? Is this a architecture design flaw?

Laravel framework http://laravel.com/

As you can see nothing special happening here.

$fb = new firebase(Config::get('firebase.url'), Config::get('firebase.token'));
$fb->push("/" . Config::get('firebase.reports_feed') . "/" . Auth::user()->account_user_id, array(
    'createdAt' => Date::timezone(Date::sql(), "UTC", Auth::user()->account()->timezone),
    'message' => Auth::user()->name . " activated a '{$record->card->name}' system.",
    'user' => array(
        'id' => Auth::user()->id,
        'name' => Auth::user()->name,
    ),
    'reload' => false,
    'processed' => false,
    'record' => to_json($record),
));

The card object is shallow.

enter image description here

Update

I have two computers I'm testing this on.

  • A cheap touchscreen acer - Windows7
  • An older compaq - ElementaryOS

I noticed the compaq tends to update before the acer does. Maybe this is a RAM issue with javascript vars being to large? I currently have an array of 225 objects in an activity feed.

Update 2

  1. I did an action in my app
  2. it posted to firebase
  3. Forge went green as it added the records
  4. Nothing happened with my listener.
  5. I did the action one to three more times and my app would update all of a sudden.

controllers.controller('ReportsCtrl', function($scope, angularFire) { var ref = new Firebase($scope.main.firebaseUrl + "/" + $scope.main.accountUserId); $scope.feedItems = []; angularFire(ref, $scope, "feedItems");

$scope.$watch('feedItems', function(newVal, oldVal) {
    _.each($scope.feedItems, function(item) {
        if (!item.processed) {
            toastr.info(item.message); // alert message that pops up
            item.processed = true;

            if (item.reload)
                $scope.loadGoalStats();
        }
    });

    $scope.feedItemsLength = _.toArray($scope.feedItems).length;
}, true);

});

4

1 回答 1

0

刚刚将我们的应用程序投入生产,可以肯定的是,瓶颈在于 PHP 做了一些它不应该做的事情。我通过重新组织代码并尽可能将 angularjs 中的所有内容保存到 firebase 来解决这个问题。

在我的情况下,我反复对许多 curl 请求进行 waaaay。因此,将其偏移到客户端而不是服务器端,它的工作效果要好得多。(出于显而易见的原因)

于 2013-09-19T01:01:47.277 回答