Skip to content

Commit 8602c6a

Browse files
DOCSP-53218 -- Private link IP addresses (#14205)
* DOCSP-53218 -- WIP * DOCSP-53218 -- AWS Private Link IP Address * DOCSP-53218 -- move to aws tab * DOCSP-53218 -- external review revisions * DOCSP-53218 -- fix bulleted lists * DOCSP-53218 -- copy review * DOCSP-53218 -- copy review * DOCSP-53218 -- copy review
1 parent 61b7a27 commit 8602c6a

File tree

4 files changed

+277
-2
lines changed

4 files changed

+277
-2
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import json
2+
import sys
3+
4+
def process_log_file(json_file_path):
5+
# Dictionary to store the filtered data
6+
filtered_data = {}
7+
8+
with open(json_file_path, "r") as json_file:
9+
# Read the file line by line
10+
for line in json_file:
11+
# Parse each line as a separate JSON object
12+
data = json.loads(line)
13+
14+
if 'msg' in data and data['msg'] == 'client metadata':
15+
# Extract the relevant data from the JSON object
16+
drivername = data['attr']['doc']['driver']['name']
17+
driverversion = data['attr']['doc']['driver']['version']
18+
connectionid = data['ctx']
19+
20+
# Create a unique key for the driver based on name and version
21+
driver_key = (drivername, driverversion)
22+
23+
# Add the connection ID to the driver's set of connections
24+
if driver_key not in filtered_data:
25+
filtered_data[driver_key] = {'connections': set(), 'opencount': 0, 'closedcount': 0}
26+
27+
filtered_data[driver_key]['connections'].add(connectionid)
28+
filtered_data[driver_key]['opencount'] += 1
29+
30+
if 'msg' in data and data['msg'] == 'Connection ended':
31+
connectionid = data['ctx']
32+
33+
# Check if the connection ID exists in any driver's connections
34+
for driver_data in filtered_data.values():
35+
if connectionid in driver_data['connections']:
36+
driver_data['closedcount'] += 1
37+
driver_data['connections'].remove(connectionid)
38+
39+
# Print the filtered data for each driver
40+
for driver_key, driver_data in filtered_data.items():
41+
print('Driver:', driver_key)
42+
print('Connection Opened:', driver_data['opencount'])
43+
print('Connection Closed:', driver_data['closedcount'])
44+
45+
if __name__ == '__main__':
46+
# Check if a JSON file argument is provided
47+
if len(sys.argv) < 2:
48+
print("Please provide the path to a JSON file as an argument.")
49+
sys.exit(1)
50+
51+
# Extract the JSON file path from the command-line arguments
52+
json_file_path = sys.argv[1]
53+
54+
# Process the log file
55+
process_log_file(json_file_path)

content/atlas/source/reference/atlas-limits.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ total number of connections |service| can allocate for a given query.
9292
</core/read-preference/#mongodb-readmode-secondary>`, |service| can read from
9393
the two secondary nodes for a combined 2980 connection limit.
9494

95+
The cluster connection limits are enforced for AWS only when connecting over
96+
private link for clusters on the supported versions:
97+
98+
- 8.1 and v8.1.0+
99+
- 8.0 and v8.0.10+
100+
- 7.0 and v7.0.22+
101+
95102
Increase Connection Limit
96103
~~~~~~~~~~~~~~~~~~~~~~~~~
97104

content/atlas/source/security-private-endpoint.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,29 @@ To set up a private endpoint, you must have
264264
:authrole:`Organization Owner` or :authrole:`Project Owner` access to
265265
the project.
266266

267+
Max Incoming Connections
268+
------------------------
269+
270+
|service| sets the :setting:`limits for concurrent incoming connections
271+
<net.maxIncomingConnections>` based on the {+cluster+} tier and
272+
:ref:`class<storage-class-ui>`. |service| connection limits apply per node. For
273+
:manual:`sharded {+clusters+} </sharding/>`, |service| connection limits apply per
274+
:manual:`mongos </core/sharded-cluster-query-router/>` router. The number of
275+
:manual:`mongos </core/sharded-cluster-query-router/>` routers is equal to
276+
the number of replica set nodes across all shards.
277+
278+
Your :manual:`read preference </core/read-preference/>` also contributes to the
279+
total number of connections |service| can allocate for a given query.
280+
281+
.. example::
282+
Your ``M10`` cluster has three nodes with a 1500 connection limit per node.
283+
|service| reserves 10 connections per node. If you set your :manual:`read preference
284+
</core/read-preference/>` to :manual:`secondary
285+
</core/read-preference/#mongodb-readmode-secondary>`, |service| can read from
286+
the two secondary nodes for a combined 2980 connection limit.
287+
288+
To learn more about connection limits and increasing your limits, see :ref:`connection-limits`.
289+
267290
.. _private-endpoint-considerations:
268291

269292
Considerations

content/atlas/source/troubleshoot-private-endpoints.txt

Lines changed: 192 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Troubleshoot Private Endpoint Connection Issues
1313
.. contents:: On this page
1414
:local:
1515
:backlinks: none
16-
:depth: 1
16+
:depth: 2
1717
:class: singlecol
1818

1919
This page outlines common private endpoint connection issues and possible resolutions.
@@ -103,6 +103,197 @@ This page outlines common private endpoint connection issues and possible resolu
103103
Name: vpce-024f5b57108c8d3ed-ypwbxwll.vpce-svc-02863655456245e5c.us-east-1.vpce.amazonaws.com
104104
Address: 10.0.20.54
105105

106+
Connection Refused Because There are Too Many Open Connections
107+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108+
109+
- If your connections exceed the connection limits for your
110+
`cluster service limit <https://www.mongodb.com/docs/atlas/reference/atlas-limits/#connection-limits-and-cluster-tier>`__,
111+
you should increase the cluster tier.
112+
- If your connection count is significantly higher than your
113+
expected connection count, see section below :ref:`Gather More Information on the Client Making the Most Connections <pl-troubleshoot-gather-info>`.
114+
- E.g. enforcement on a sharded cluster v7.0.22 using load balanced
115+
optimized connection string.
116+
117+
.. io-code-block::
118+
:copyable: false
119+
120+
.. input::
121+
122+
$ mongosh "mongodb+srv://aws-replica-set-7-pl-0-lb.22qdu.mongodb-dev.net/" --apiVersion 1 --username sarah
123+
Enter password: *****
124+
Current Mongosh Log ID: 68910f1754be6d9adc74e399
125+
Connecting to: mongodb+srv://<credentials>@aws-replica-set-7-pl-0-lb.22qdu.mongodb-dev.net/?appName=mongosh+2.5.6
126+
MongoNetworkError: Client network socket disconnected before secure TLS connection was established
127+
128+
.. output::
129+
130+
{"t":{"$date":"2025-08-04T19:48:17.649+00:00"},"s":"I", "c":"NETWORK",
131+
"id":22942, "ctx":"listener","msg":"Connection refused because there are
132+
too many open connections","attr":{"remote":"54.172.143.8:33205",
133+
"isLoadBalanced":false,"uuid":{"uuid":{"$uuid":"e52e9c14-7648-430a-bc2e-95292347b7e0"}},
134+
"connectionId":380,"connectionCount":58}}
135+
136+
137+
Viewing the Client Source IP
138+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139+
140+
.. note::
141+
142+
This feature is rolling out gradually. We expect it to be
143+
available for all the dedicated clusters in AWS by the end of September, 2025.
144+
145+
- You can view the client source IP in the mongos logs for sharded
146+
clusters connecting via Private Endpoints.
147+
- You can view the client source IP in the mongod logs for replica sets
148+
connecting via Private Endpoints.
149+
- You can view the client source IP in the audit logs for both replica sets
150+
and sharded clusters connecting via Private Endpoints.
151+
- This functionality is supported on AWS for the following versions:
152+
153+
- 8.1 and v8.1.0+
154+
- 8.0 and v8.0.10+
155+
- 7.0 and v7.0.22+
156+
157+
- The origin client IP address and port is indicated by the ``sourceClient`` field.
158+
That value is ``10.50.4.23`` in the above example.
159+
160+
.. code-block::
161+
162+
{"t":{"$date":"2025-07-21T12:15:42.123+00:00"},"s":"I","c":"NETWORK",
163+
"id":22943,"ctx":"listener","msg":"Connection accepted","attr":{"remote":"192.168.100.55:31245",
164+
"isLoadBalanced":true,"sourceClient":"10.50.4.23:50123","uuid":{"uuid":{"$uuid":"12345678-abcd-4321-abcd-87654321abcd"}},
165+
"connectionId":345,"connectionCount":19}}
166+
167+
168+
169+
.. _pl-troubleshoot-gather-info:
170+
171+
Gather More Information on the Client Making the Most Connections
172+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173+
174+
Gathering these details requires using the
175+
`jq tool <https://www.mongodb.com/docs/manual/reference/log-messages/#log-parsing-examples>`__,
176+
which can be downloaded from the `jq website <https://jqlang.github.io/jq/>`__.
177+
178+
Connections created from the client metadata
179+
`````````````````````````````````````````````
180+
181+
The following query provides the number of connections created from a
182+
particular client IP address. You can now collect the exact source VPC Private IP address
183+
using the attribute ``sourceClient``.
184+
185+
.. io-code-block::
186+
187+
.. input::
188+
189+
grep '"c":"NETWORK"' mongod.log | jq -c '.attr.sourceClient' | grep -v null | sort | uniq -c
190+
191+
.. output::
192+
193+
1 "172.31.36.2:32958"
194+
1 "172.31.36.2:52904"
195+
1 "172.31.36.2:52908"
196+
1 "172.31.36.2:52910"
197+
1 "172.31.36.2:52918"
198+
199+
Drivers used by the applications to connect to the cluster
200+
```````````````````````````````````````````````````````````
201+
202+
The following query provides the number of connections created by each
203+
driver. This is useful in scenarios where customers might use different
204+
drivers for different applications.
205+
206+
.. io-code-block::
207+
208+
.. input::
209+
210+
more mongodb.log| grep 'NETWORK' | jq -r '.attr.doc.driver.name' | grep -v null | sort | uniq -c | sort -rn
211+
212+
.. output::
213+
214+
56447 mongo-go-driver
215+
21633 mongo-java-driver|sync
216+
75 mongo-java-driver|sync|Airbyte
217+
4 nodejs|Mongoose
218+
219+
For a more detailed analysis of connection counts and driver details,
220+
you can use the following Python script, which provides comprehensive
221+
information on the number of connections created and terminated, along
222+
with the driver names and version details.
223+
224+
.. io-code-block::
225+
226+
.. input:: /includes/driver_details_and_connection_details.py
227+
228+
.. output::
229+
230+
Driver: ('mongo-go-driver', 'v1.12.0-cloud')
231+
Connection Opened: 14368
232+
Connection Closed: 14362
233+
234+
Driver: ('mongo-go-driver', 'v1.12.1')
235+
Connection Opened: 42056
236+
Connection Closed: 41958
237+
238+
Driver: ('mongo-java-driver|sync', '4.11.1')
239+
Connection Opened: 18012
240+
Connection Closed: 17987
241+
242+
Driver: ('mongo-java-driver|sync', '4.8.2')
243+
Connection Opened: 3621
244+
Connection Closed: 3610
245+
246+
Driver: ('nodejs|Mongoose', '4.17.1|6.12.0')
247+
Connection Opened: 3
248+
Connection Closed: 1
249+
250+
Driver: ('mongo-go-driver', 'v1.13.0')
251+
Connection Opened: 23
252+
Connection Closed: 20
253+
254+
Driver: ('mongo-java-driver|sync|Airbyte', '4.11.0')
255+
Connection Opened: 75
256+
Connection Closed: 75
257+
258+
Driver: ('nodejs|Mongoose', '4.17.2|6.13.0')
259+
Connection Opened: 1
260+
Connection Closed: 0
261+
262+
Application names used by client applications to connect to the cluster
263+
```````````````````````````````````````````````````````````````````````
264+
We can suggest that customers include the application name in the connection
265+
string to specify different applications connecting to the cluster. By using the
266+
``appName``, we can identify which application is creating many connections
267+
to the cluster in the future. See the `Miscellaneous Configuration <https://www.mongodb.com/docs/v6.2/reference/connection-string/#miscellaneous-configuration>`__
268+
section of our documentation for more details on using the ``appName`` in
269+
the connection string. Additionally, you can use the ``db.currentOp().appname``
270+
command to see the current operations associated with the application name.
271+
The following query provides details of the ``appName`` with the number of
272+
connections created by that particular application.
273+
274+
.. io-code-block::
275+
276+
.. input::
277+
278+
more mongodb.log| grep 'NETWORK' | jq -r '.attr.doc.application.name' | grep -v null | sort | uniq -c | sort -rn
279+
280+
.. output::
281+
282+
10809 niyo-*******-api
283+
8616 MongoDB CPS Module v13.17.2.8878 (git: 70c0b932f47f4f0b3e82a75e223f39ed9635b47f)
284+
7203 niyo-ns*****
285+
5752 MongoDB Automation Agent v13.17.2.8878 (git: 70c0b932f47f4f0b3e82a75e223f39ed9635b47f)
286+
3601 *****-auth-service
287+
288+
The provided details help to pinpoint the specific factors
289+
contributing to the high number of connections. By analyzing Source Client
290+
IP, client metadata, driver usage, and application names, you can identify
291+
which elements are responsible for the increased connections and determine
292+
the necessary areas to investigate. This targeted approach allows you
293+
to disregard other less relevant factors and concentrate on
294+
addressing the issues with the highlighted information, ultimately
295+
streamlining the mitigation process and enhancing cluster performance.
296+
106297
Multi-Region Private Endpoints
107298
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108299

@@ -421,4 +612,3 @@ This page outlines common private endpoint connection issues and possible resolu
421612

422613
telnet pl-0-<xyz>.mongodb.net 27017
423614

424-

0 commit comments

Comments
 (0)