83932

How the Connection is calculated in Firebase

Question:

How are the connections are being calculated?

Let's assume that I have a web app which one load sends a message to all connected clients, and let's say I have 5 connected clients. Does it means that as long as the browser tab with the web app is open it will count as 1 connections, which means that I will have 6 concurrent connections and that's count towards what you define as "Connection" in the pricing page?

If not, please explain how you calculate the "Connection". Thanks

Answer1:

This question was bugging me ever since I ran through the thinkster.io angular+firebase tutorial and I saw my firebase analytics tab showing a peak concurrent of 6 even though I only remember having the one page open. I looked back at the code and thought it could be to do with how the tutorial has you create a new Firebase(url) for each location in your firebase.

I wanted to test the difference between creating a new Firebase(url) vs taking the root reference and then accessing the .child() location. My theory was that new Firebase(url) would create a new connection each time, while .child() would re-use the existing connection.

Setup

<ul><li>Created two new firebases each with identical data</li> <li>Setup an angularjs project using yeoman</li> <li>Included angularfire</li> </ul>

Code

For simplicity, I just put everything in the main controller of the generated code.

To test out the connections created with new Firebase() I did the following:

$scope.fb_root = $firebase(new Firebase(FBURL_NEW)); $scope.fb_root_apps = $firebase(new Firebase(FBURL_NEW + '/apps')); $scope.fb_root_someApp = $firebase(new Firebase(FBURL_NEW + '/apps/someApp')); $scope.fb_root_users = $firebase(new Firebase(FBURL_NEW + '/users')); $scope.fb_root_mike = $firebase(new Firebase(FBURL_NEW + '/users/mike'));

To test out the connections created with ref.$child() I did the following:

$scope.fb_child = $firebase(new Firebase(FBURL_CHILD)); $scope.fb_child_apps = $scope.fb_child.$child("apps"); $scope.fb_child_someApp = $scope.fb_child_apps.$child("someApp"); $scope.fb_child_users = $scope.fb_child.$child("users"); $scope.fb_child_mike = $scope.fb_child_users.$child("mike");

I then bound these objects in my view so I can see them, and I played around with updating data via my firebase forge and watching the data update live on my app.

Results

I opened up my local app into 17 browser tabs, hoping that a large number of tabs would exaggerate any differences between the connection methods.

What I found is that each tab only opened up one single web socket connection back to firebase for each firebase db. So at the end of the test, both methods resulted in the same peak count of 17 connections.

Conclusion

From this simple test I think it's safe to say that the Firebase JS library does a good job of managing its connection.

Regardless of your code calling new Firebase() a bunch of times, or by referencing child locations via .child(), the library will only create a single connection as far as your metering is concerned. That connection will stay online for as long as your app is open.

So in your example - yes I believe you will see 6 concurrent connections, 1 for the app where someone is sending the message, and 5 for the apps receiving the message.

Update

One other thing worth mentioning is that Firebase measures connections for paid plans based on the 95th percentile of usage during the month. This is listed in the FAQ section of their Pricing page @ <a href="https://www.firebase.com/pricing.html" rel="nofollow">https://www.firebase.com/pricing.html</a>

Update 11-Mar-16: Firebase no longer appears to measure connections based on 95th %. Instead, the 101st concurrent connection is denied.

<a href="https://www.firebase.com/pricing.html" rel="nofollow">https://www.firebase.com/pricing.html</a> :

<blockquote>

All our plans have a hard limit on the number of database connections. Our Free and Spark plans are limited to 100. The limit cannot be raised. All other plans have a courtesy limit of 10,000 database connections. This can be removed to permanently allow Unlimited connections if you email us at firebase-support@google.com.. The reason we impose this courtesy limit is to prevent abuse and to ensure that we are prepared to handle our largest customers. Please contact us at least 24 hours in advance so we can lift this limit and ensure we have enough capacity available for your needs.

</blockquote>

Recommend

  • retrieving data from a database using ajax without requesting every x seconds
  • Synchronous request in Windows Azure?
  • Building GUI using GroupLayout in Java
  • pos absolute jquery validationengine v2.5.5 custom error messages not working
  • Getting attachments from Exchange Managed API using ASP.NET Core
  • Timestamp when a cell is changed via a formula (Excel)
  • Lumen - mongodb - jenssegers/laravel-mongodb - postman
  • MYSQL 5.5 Drop Primary Key
  • Django - using different apps together in a project
  • Elixir processes and no shared heap memory
  • What is a simple but somewhat effective way to “obfuscate” numeric values?
  • C# Interlocked functions as a lock mechanism?
  • PHP Google Calendar API: Adding Multiple Events at Once
  • How do I get online predictions in javascript for my model on Cloud Machine Learning Engine?
  • Translation between grid index and actual values
  • How can I find all permutations of a string without using recursion?
  • Merge two collections with Automapper by condition
  • Stream processing lots of stuff to OVA
  • Most concise way to write this query to add hour to a date
  • @Embeddable and @EmbeddedId consists only of complex classes
  • what is the advantage of EventMachine
  • Hexagonal Images [duplicate]
  • How to access the fields of a jqGrid row?
  • Get rows that come alphabetically after one with a specified ID
  • Load factor of hash tables with tombstones
  • MIPS Pseudo istructions, replacements
  • merge and order two columns in the same model
  • Using publish-composite with Angular-Meteor
  • angular Scroll div on button click
  • Getting webGL error in autodesk viewer
  • How to re-render views using Angular JS
  • Is there an easy way to associate an event with a ListViewItem?
  • How to pass solution folder as parameter in command line arguments (for debug)?
  • Django Haystack Rebuild Index
  • Does Apportable support to build library binary (.a/.so)?
  • For loop with if condition on multiple R functions
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • Switching to Release Build causes runtime error in Web Reference
  • Why ng-show works with ng-repeat but ng-if doesn't? [duplicate]
  • QuartzCore.framework for Mono Develop