May 21, 2024


For a lot of prospects, making outbound connections to the web from their digital networks is a basic requirement of their Azure answer architectures. Elements resembling safety, resiliency, and scalability are necessary to think about when designing how outbound connectivity will work for a given structure. Fortunately, Azure has simply the answer for making certain extremely obtainable and safe outbound connectivity to the web: Digital Community NAT. Digital Community NAT, also called NAT gateway, is a totally managed and extremely resilient service that’s simple to scale and particularly designed to deal with large-scale and variable workloads.

NAT gateway offers outbound connectivity to the web via its attachment to a subnet and public IP deal with. NAT stands for community deal with translation, and as its title implies, when NAT gateway is related to a subnet, all the non-public IPs of a subnet’s assets (resembling, digital machines) are translated to NAT gateway’s public IP deal with. The NAT gateway public IP deal with then serves because the supply IP deal with for the subnet’s assets. NAT gateway will be hooked up to a complete of 16 IP addresses from any mixture of public IP addresses and prefixes.

NAT gateway configuration example as described in the caption.

Determine 1: NAT gateway configuration with a subnet and a public IP deal with and prefix.

Buyer is halted by connection timeouts whereas attempting to make hundreds of connections to the identical vacation spot endpoint

Prospects in industries like finance, retail, or different eventualities that require leveraging giant units of information from the identical supply want a dependable and scalable methodology to connect with this information supply.

On this weblog, we’re going to stroll via one such instance that was made attainable by leveraging NAT gateway.

Buyer background

A buyer collects a excessive quantity of information to trace, analyze, and in the end make enterprise selections for certainly one of their main workloads. This information is collected over the web from a service supplier’s REST APIs, hosted in an information middle they personal. As a result of the info units the shopper is focused on could change each day, a recurring report can’t be relied on—they have to request the info units every day. Due to the quantity of information, outcomes are paginated and shared in chunks. Because of this the shopper should make tens of hundreds of API requests for this one workload every day, usually taking from one to 2 hours. Every request correlates to its personal separate HTTP connection, just like their earlier on-premises setup.

The beginning structure

On this state of affairs, the shopper connects to REST APIs within the service supplier’s on-premises community from their Azure digital community. The service supplier’s on-premises community sits behind a firewall. The client began to note that generally a number of digital machines waited for lengthy durations of time for responses from the REST API endpoint. These connections ready for a response would ultimately day trip and lead to connection failures.

Diagram showing traffic flow from the customer's Azure Infrastructure to on-premises data center.

Determine 2: The client sends visitors from their digital machine scale set (VMSS) of their Azure digital community over the web to an on-premises service supplier’s information middle server (REST API) that’s fronted by a firewall.

The investigation

Upon deeper inspection with packet captures, it was discovered that the service supplier’s firewall was silently dropping incoming connections from their Azure community. Because the buyer’s structure in Azure was particularly designed and scaled to deal with the quantity of connections going to the service supplier’s REST APIs for gathering the info they required, this appeared puzzling. So, what precisely was inflicting the problem?

The client, the service supplier, and Microsoft help engineers collectively investigated why connections from the Azure community have been being sporadically dropped, and made a key discovery. Solely connections coming from a supply port and IP deal with that have been lately used (on the order of 20 seconds) have been dropped by the service supplier’s firewall. It is because the service supplier’s firewall enforces a 20-second cooldown interval on new connections coming from the identical supply IP and port. Any connections utilizing a brand new supply port on the identical public IP weren’t impacted by the firewall’s cooldown timer. From these findings, it was concluded that supply community deal with translation (SNAT) ports from the shopper’s Azure digital community have been being reused too rapidly to make new connections to the service supplier’s REST API. When ports have been reused earlier than the cooldown timer accomplished, the connection would timeout and in the end fail. The client was then confronted with the query of, how can we stop ports from being reused too rapidly to make connections to the service supplier’s REST API? Because the firewall’s cooldown timer couldn’t be modified, the shopper needed to work inside its constraints.

NAT gateway to the rescue

Primarily based on this information, NAT gateway was launched into the shopper’s setup in Azure as a proof of idea. With this one change, connection timeout points grew to become a factor of the previous.

NAT gateway was in a position to resolve this buyer’s outbound connectivity challenge to the service supplier’s REST APIs for 2 causes. One, NAT gateway selects ports at random from a big stock of ports. The supply port chosen to make a brand new connection has a excessive likelihood of being new and due to this fact will move via the firewall with out challenge. This massive stock of ports obtainable to NAT gateway is derived from the general public IPs hooked up to it. Every public IP deal with hooked up to NAT gateway offers 64,512 SNAT ports to a subnet’s assets and as much as 16 public IP addresses will be hooked up to NAT gateway. Which means a buyer can have over 1 million SNAT ports obtainable to a subnet for making outbound connections. Secondly, supply ports being reused by NAT gateway to connect with the service supplier’s REST APIs will not be impacted by the firewall’s 20-second cooldown timer. It is because the supply ports are set on their very own cooldown timer by NAT gateway for at the least so long as the firewall’s cooldown timer earlier than they are often reused. See our public article on NAT gateway SNAT port reuse timers to be taught extra.

Keep tuned for our subsequent weblog the place we’ll do a deep dive into how NAT gateway solves for SNAT port exhaustion via not solely its SNAT port reuse conduct but additionally via the way it dynamically allocates SNAT ports throughout a subnet’s assets.

Be taught extra

By the shopper state of affairs above, we discovered how NAT gateway’s choice and reuse of SNAT ports proves why it’s Azure’s advisable possibility for connecting outbound to the web. As a result of NAT gateway isn’t solely in a position to mitigate danger of SNAT port exhaustion but additionally connection timeouts via its randomized port choice, NAT gateway in the end serves as the best choice when connecting outbound to the web out of your Azure community.

To be taught extra about NAT gateway, see Design digital networks with NAT gateway.


Source link