Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Randomize IPs in Cloud NAT

Hello!

I want to deploy an API, which in turn consumes an external API. This external API has a limit of 10 request per second per IP, however I expect more traffic in production. I was wondering if it 's possible to configure Cloud NAT to have multiple external IP addresses and "randomize" the outbound traffic through those IP. I was performing some load tests with my API in GKE and all requests went through the same IP address, even when I configured the Cloud NAT with 5 IPs. I was thinking about using CloudRun keeping 10RPS per instance, but I'd be really expensive. Thanks for your help!

Solved Solved
1 2 1,317
1 ACCEPTED SOLUTION

Hi @pedrodotmc,

An API that can only deliver 10 reqs / sec it's a bit of a problem. You sure they don't offer a higher volume for the right price and spare you of over-engineering a simple solution?

If you'll be using Cloud NAT this way you'll notice at some point that your bill will go up. Could NAT isn't really the best solution here, don't get me wrong is a brilliant tool but I'd say that Cloud NAT hasn't been built for this.

Let's be honest, what you're trying to achieve here it's a bit of a red flag from a design perspective. Even if it was possible to use Cloud NAT this way I wouldn't go with it, it'll be a huge waste of time.

I can see only two options here:

  1. Go and ask for a higher volume from your API provider
  2. Design you own solution or use one "off the shelf".

View solution in original post

2 REPLIES 2

Hi @pedrodotmc,

An API that can only deliver 10 reqs / sec it's a bit of a problem. You sure they don't offer a higher volume for the right price and spare you of over-engineering a simple solution?

If you'll be using Cloud NAT this way you'll notice at some point that your bill will go up. Could NAT isn't really the best solution here, don't get me wrong is a brilliant tool but I'd say that Cloud NAT hasn't been built for this.

Let's be honest, what you're trying to achieve here it's a bit of a red flag from a design perspective. Even if it was possible to use Cloud NAT this way I wouldn't go with it, it'll be a huge waste of time.

I can see only two options here:

  1. Go and ask for a higher volume from your API provider
  2. Design you own solution or use one "off the shelf".

Hi, I have similar problem as OP. Basically there's an external API that only allows a few requests in a given period of time from a certain IP address.

From what I could understand, Cloud NAT doesn't offer the possibility to act as a rotating proxy, since it always uses the same IP address for every outbound request even if you add more external IPs to its config.

You talked about "off the shelf" solutions, so could you name one that is available in GCP?