Concurrent connection in chat app

1,464 views
Skip to first unread message

Anh Nguyen

unread,
Jun 19, 2014, 1:03:54 AM6/19/14
to fireba...@googlegroups.com

I'm evaluating Firebase for building a chat app. And it's plan makes me concern: 10,000 concurrent connections/$1,499/month.

It seems to me that the chat app will have an always-on connection to Firebase, to receive incoming messages instantly. It means that if my app get 10,000 active installs on Android, then no matter whether they're opening the app or not, I will have to pay $1,499/a month.

Anyone know a solution for reducing concurrent connections to Firebase without impacting the perceived quality of the chat app? 

Thanks.

James Tamplin

unread,
Jun 19, 2014, 2:35:04 AM6/19/14
to fireba...@googlegroups.com
 Hi Anh -

A few points to note:

1. A bi-directional connection to the server is only going to count if the app is open. 
2. You can intelligently use goOffline() to reduce the number of connections.
3. We only bill on the 95th percentile. So you can have peaks of usage and not get charged.
4. The number of concurrent connections you have probably won't be as high as you think.
 
A good rule of thumb is 1 concurrent = 1000 monthly visits for the typical website or app (apps actually average even higher). For example, 50 concurrent connections equals roughly 50,000 visits a month, where 750 concurrents would be nearing a million visitors.

Most developers vastly overestimate the number of concurrent users they will have. As a data point -- our own website could operate comfortably on the "free" Firebase plan.

Hope this helps,

James

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



Anh Nguyen

unread,
Jun 20, 2014, 2:39:43 AM6/20/14
to fireba...@googlegroups.com
Hi James, thanks for your reply. 
I want to understand this better "A bi-directional connection to the server is only going to count if the app is open."
What if my app has a background service that keeps listening to firebase event, something like this:

public class FirebaseBackgroundService extends Service {
private Firebase f = new Firebase("https://somedemo.firebaseio-demo.com/");
private ValueEventListener handler;
@Override public IBinder onBind(Intent arg0) { return null; }
@Override
public void onCreate() {
super.onCreate();
handler = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot arg0) {
// notify data change
}
@Override public void onCancelled() { }
};
f.addValueEventListener(handler);
}
}

Thanks

Michael Wulf

unread,
Jun 20, 2014, 12:53:02 PM6/20/14
to fireba...@googlegroups.com
Your background service will count as one concurrent. Essentially, every browser tab, mobile device, or server process/thread which opens a unique socket connection is a concurrent. Multiple calls to new Firebase() or multiple on/once listeners, et al are optimized to utilize the same connection.

Matt Boes

unread,
Sep 13, 2014, 6:34:57 PM9/13/14
to fireba...@googlegroups.com
Hi, I have a follow on Android question.  New to Firebase too.

I'm interested to know more about how Firebase works with the Android activity lifecycle.  Many users will hit the home button from an app, which essentially puts the app through a paused and then stopped state.  However, the app instance may not be destroyed for a potentially long while if the Android system does not require system resources elsewhere.

If a user hits the home button from a Firebase-based app or switches to another app not to return for some unknown period, is the Firebase connection still open?

Thanks!

Ossama Alami

unread,
Sep 15, 2014, 5:25:32 PM9/15/14
to fireba...@googlegroups.com
Hi Matt - 

The Firebase Android client currently doesn't preform any action based on Android Activity lifecycle events, so the connection will very likely continue to stay open. If you'd want to disconnect when the app is in the background, you'll want to explicitly call goOffline() and goOffline in onStop and onStart, respectively.

Hope this helps,
Ossama
Ossama Alami | VP, Developer Happiness, Firebase | [+@]ossamaalami

Matt Boes

unread,
Sep 16, 2014, 10:15:11 AM9/16/14
to fireba...@googlegroups.com

Got it.  Thanks Ossama

You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/lUAQeLjtpIU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages