Latency issue in Peered connection

1

I have a Peered connection in the AWS mumbai region. The peering is done with Mongodb Atlas to a difference account. The aim is to get lowest latency possible during the query from my server to the mongodb managed server.

I belived that the latency would be in the range of 10ms for each query. But if I do a findOne query the difference is more than 15ms. which increases exponentially.

I have another mongodb instance that is self managed by me in the same account but on a different ec2 instance. The latency in quering data using one document is 3ms and for 100 objects it is 20ms. But if I use the same query to retrieve one document using peered connection the latency for one document is more than 20ms and for 100 objects it is 80ms.

So basically I'm seeing 4 times the difference of latency which increases as the data increases. Is this expected behaviour. Can the latency be reduced in any way.

  • Have you compared the latency to the same queries originating in the same VPC as the Peered MongoDB ? You can eliminate the peering network connection latency that way. Rule of thumb, you should see around 1 or 2 ms between AZs in the same region due to a peering connection.

  • Yes, as mentioned in the post as well, if there are two different ec2 instance, one is the API server and one is the mongodb server in the same VPC. I'm getting a latency of 3ms for querying one document and. 20ms for querying 100 objects. So peered connection in the same region is taking 4 times longer to respond to the same nature of query.

Devesh
asked 2 months ago136 views
1 Answer
1

It's not 100% clear from your question how your network is structured.

In general, there is no latency difference between access between EC2 instances in a single VPC vs. EC2 instances in peered VPCs. (For an explanation of why that is, see this re:Invent video on YouTube. Note that it does not matter if the peered VPCs are in different accounts.

However, traffic between availability zones will always incur a latency penalty (because the speed of light is finite). if lowest possible latency is desired then hosting the application components in the same AZ is the best way to go. The latency between availability zones is measured in single-digit milliseconds (see the documentation for more information) but it is still latency and it adds up.

If you are seeing higher latency you should do a deep-dive on where the latency is being introduced - not all of it will come from the network; there may be other bottlenecks in the database or application.

profile pictureAWS
EXPERT
answered 2 months ago