Fetch data from Cloud DNS in parallel

Before pushing an update to Cloud DNS, the CloudDnsWriter needs to read all the domain RRSs from Cloud DNS one by one to know what to delete.

Doing so sequentially results in update times that are too long (approx 200ms per domain, which is 20 seconds per batch of 100) severely limiting our QPS.

This CL uses Concurrent threading to do the Cloud DNS queries in parallel. Unfortunately, my preferred method (Set.parallelStream) doesn't work on App Engine :(

This reduces the per-item time from 200ms to 80ms, which can be further reduced to 50ms if we remove the rate limiter (currently set to 20 per second).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178126877
This commit is contained in:
guyben 2017-12-06 11:30:22 -08:00 committed by jianglai
parent 735112def6
commit d87f01e7bf
4 changed files with 134 additions and 73 deletions

View file

@ -76,4 +76,14 @@ public final class CloudDnsWriterModule {
int cloudDnsMaxQps = 20;
return RateLimiter.create(cloudDnsMaxQps);
}
@Provides
@Named("cloudDnsNumThreads")
static int provideNumThreads() {
// TODO(b/70217860): find the "best" number of threads, taking into account running time, App
// Engine constraints, and any Cloud DNS comsiderations etc.
//
// NOTE: any number below 2 will not use threading at all.
return 10;
}
}