d65008700a
acl: reduce complexity of token resolution process with alternative singleflighting Switches acl resolution to use golang.org/x/sync/singleflight. For the identity/legacy lookups this is a drop-in replacement with the same overall approach to request coalescing. For policies this is technically a change in behavior, but when considered holistically is approximately performance neutral (with the benefit of less code). There are two goals with this blob of code (speaking specifically of policy resolution here): 1) Minimize cross-DC requests. 2) Minimize client-to-server LAN requests. The previous iteration of this code was optimizing for the case of many possibly different tokens being resolved concurrently that have a significant overlap in linked policies such that deduplication would be worth the complexity. While this is laudable there are some things to consider that can help to adjust expectations: 1) For v1.4+ policies are always replicated, and once a single policy shows up in a secondary DC the replicated data is considered authoritative for requests made in that DC. This means that our earlier concerns about minimizing cross-DC requests are irrelevant because there will be no cross-DC policy reads that occur. 2) For Server nodes the in-memory ACL policy cache is capped at zero, meaning it has no caching. Only Client nodes run with a cache. This means that instead of having an entire DC's worth of tokens (what a Server might see) that can have policy resolutions coalesced these nodes will only ever be seeing node-local token resolutions. In a reasonable worst-case scenario where a scheduler like Kubernetes has "filled" a node with Connect services, even that will only schedule ~100 connect services per node. If every service has a unique token there will only be 100 tokens to coalesce and even then those requests have to occur concurrently AND be hitting an empty consul cache. Instead of seeing a great coalescing opportunity for cutting down on redundant Policy resolutions, in practice it's far more likely given node densities that you'd see requests for the same token concurrently than you would for two tokens sharing a policy concurrently (to a degree that would warrant the overhead of the current variation of singleflighting. Given that, this patch switches the Policy resolution process to only singleflight by requesting token (but keeps the cache as by-policy). |
||
---|---|---|
.. | ||
autopilot | ||
fsm | ||
prepared_query | ||
state | ||
acl.go | ||
acl_client.go | ||
acl_endpoint.go | ||
acl_endpoint_legacy.go | ||
acl_endpoint_test.go | ||
acl_replication.go | ||
acl_replication_legacy.go | ||
acl_replication_legacy_test.go | ||
acl_replication_test.go | ||
acl_server.go | ||
acl_test.go | ||
autopilot.go | ||
autopilot_oss.go | ||
autopilot_test.go | ||
catalog_endpoint.go | ||
catalog_endpoint_test.go | ||
client.go | ||
client_serf.go | ||
client_test.go | ||
config.go | ||
connect_ca_endpoint.go | ||
connect_ca_endpoint_test.go | ||
consul_ca_delegate.go | ||
coordinate_endpoint.go | ||
coordinate_endpoint_test.go | ||
enterprise_client_oss.go | ||
enterprise_server_oss.go | ||
filter.go | ||
filter_test.go | ||
flood.go | ||
health_endpoint.go | ||
health_endpoint_test.go | ||
helper_test.go | ||
intention_endpoint.go | ||
intention_endpoint_test.go | ||
internal_endpoint.go | ||
internal_endpoint_test.go | ||
issue_test.go | ||
kvs_endpoint.go | ||
kvs_endpoint_test.go | ||
leader.go | ||
leader_oss.go | ||
leader_test.go | ||
merge.go | ||
merge_test.go | ||
operator_autopilot_endpoint.go | ||
operator_autopilot_endpoint_test.go | ||
operator_endpoint.go | ||
operator_raft_endpoint.go | ||
operator_raft_endpoint_test.go | ||
prepared_query_endpoint.go | ||
prepared_query_endpoint_test.go | ||
raft_rpc.go | ||
rpc.go | ||
rpc_test.go | ||
rtt.go | ||
rtt_test.go | ||
segment_oss.go | ||
serf_test.go | ||
server.go | ||
server_lookup.go | ||
server_lookup_test.go | ||
server_oss.go | ||
server_serf.go | ||
server_test.go | ||
session_endpoint.go | ||
session_endpoint_test.go | ||
session_timers.go | ||
session_timers_test.go | ||
session_ttl.go | ||
session_ttl_test.go | ||
snapshot_endpoint.go | ||
snapshot_endpoint_test.go | ||
stats_fetcher.go | ||
stats_fetcher_test.go | ||
status_endpoint.go | ||
status_endpoint_test.go | ||
txn_endpoint.go | ||
txn_endpoint_test.go | ||
util.go | ||
util_test.go |