mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 17:07:15 +02:00
Add short-term host/contact caching for high-QPS domain mutations
After investigating common domain create/update command usage patterns by registrars, we noticed that it is frequent for a given registrar to reuse both hosts (using a standardized set of nameservers) as well as contacts (e.g. for privacy/proxy services). With these usage patterns, potential per-registrar throughput during high volume scenarios (i.e. first moments of General Availability) suffers from hitting hot keys in Datastore. The solution, implemented in this CL, is to add short-term in-memory caching for contacts and hosts, analogous to how we are already caching Registry and Registrar entities. These new cached paths are only used inside domain flows to determine existence and deleted/pending delete status of contacts and hosts. This is a potential loss of transactional consistency, but in practice it's hard to imagine this having negative effects, as contacts or hosts that are in use cannot be deleted, and caching would primarily affect widely used contacts and hosts. Note that this caching can be turned on or off through a configuration option, and by default would be off. We'd only want it on when we really needed it, i.e. during a big launch. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=187093378
This commit is contained in:
parent
cd9bd35a08
commit
ce136f9285
13 changed files with 461 additions and 16 deletions
|
@ -17,7 +17,6 @@ package google.registry.flows.domain;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.base.Predicates.equalTo;
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||
import static com.google.common.collect.Iterables.any;
|
||||
import static com.google.common.collect.Sets.difference;
|
||||
|
@ -275,12 +274,7 @@ public class DomainFlowUtils {
|
|||
nullToEmpty(contacts).stream().map(DesignatedContact::getContactKey).forEach(keysToLoad::add);
|
||||
Optional.ofNullable(registrant).ifPresent(keysToLoad::add);
|
||||
keysToLoad.addAll(nullToEmpty(nameservers));
|
||||
// This cast is safe because, in Objectify, Key<? extends EppResource> can also be
|
||||
// treated as a Key<EppResource>.
|
||||
@SuppressWarnings("unchecked")
|
||||
ImmutableList<Key<EppResource>> typedKeys =
|
||||
keysToLoad.build().stream().map(key -> (Key<EppResource>) key).collect(toImmutableList());
|
||||
verifyNotInPendingDelete(ofy().load().keys(typedKeys).values());
|
||||
verifyNotInPendingDelete(EppResource.loadCached(keysToLoad.build()).values());
|
||||
}
|
||||
|
||||
private static void verifyNotInPendingDelete(Iterable<EppResource> resources)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue