MongoDB Stitch and Atlas Connections

48 views
Skip to first unread message

Dimitar Kurtev

unread,
May 12, 2019, 8:39:08 AM5/12/19
to MongoDB Stitch Users
I have trouble understanding when Stitch creates a new connections to Atlas. 

I have noticed the following:
1. Using watch([id]) always creates a connection and holds it until the change stream is closed. Even if I have 20 clients watching the same document id, this will create at least 20 connections and hold them until the change stream is closed.
2. Calling multiple Stitch functions from one client creates more than one connection, but later those connections are automatically closed. 
3. Opening 10 clients that call multiple function, creates less than 10 connections, holds them for some time and then automatically closes some of them, but not all.

My questions are:
1. Is there anywhere a documentation explaining when and why connections are created? Could someone explain?
2. Couldn't watch([id]) function be improved if the same document is being watched by multiple clients ? One connection should be enough, right?
3. If we assume that I have a quota of 100 connections and 200 users open my website at the same time, calling several functions at the same time, how many connections will be opened ? Would the request fail ?
4. Does stitch reuse connections when quota is reached?

Any help is welcome.

Br,
Dimitar

Drew DiPalma

unread,
May 14, 2019, 11:10:02 AM5/14/19
to MongoDB Stitch Users
Hi Dimitar – 

Stitch is made up of a number of request processing servers so, while we do connection pooling/management, at a lower number of users you may see connections being opened per request and then being shared more and more often as the number of users scales up.  

You should see some variance here as sometimes even with a lower number of users requests will get routed to the same server and connections will be re-used.  At high levels of usage, we would expect you to see approximately 1 connection per concurrent request plus connections for your running watch/triggers which should scale linearly before all request processing servers open streams (this will vary a bit based on whether your application is deployed as local or global) plus a number of warm connections. We are making some improvements to how connections are managed within the next month or so, and you may see some optimizations there. 

You are able to exceed the permitted number of connections with Stitch and if you do so requests will fail/you will need to scale up your cluster to meed the additional demand.  

Hope that helps!
Drew

Dimitar Kurtev

unread,
May 15, 2019, 5:22:47 AM5/15/19
to MongoDB Stitch Users
Hi Drew,

Thanks for the fast response. 

That's helpful. 

Best regards,
Dimitar
Reply all
Reply to author
Forward
0 new messages