Repository navigation
atenet-router: add safe actor assignments caching and retry logic - #2420
Lior Lieberman (LiorLieberman) merged 20 commits into
Conversation
d531530 to
e4e1b6b
Compare
|
Note: linking related issue #1330. |
|
Also found #593 which was filed even earlier but seems to point to the same issue that this PR will address. |
e4e1b6b to
15ccdbb
Compare
Benchmarking summaryOutdated comment, check latest below |
2722314 to
c6cc014
Compare
|
Lior Lieberman (@LiorLieberman) Bowei Du (@bowei) Thank both for our offline discussion! Copying some follow up to your feedback here for posterity, regarding 503 handling and thread nature of this cache implementation: On 503 (upstream failure) handling.
On threads and thread-safety:
|
c6cc014 to
d8c3a6a
Compare
|
Rebased to current main HEAD |
|
Looking into the e2e failures |
|
Thanks for the followup Pancho!
Some ideas;
Some other nits;
|
|
Amended the commit with a fix for the e2e test: the ingress cache dynamic module needed to learn and stamp the worker's SPIFFE ID into dynamic metadata alongside the worker IP, fixing upstream mTLS certificate SAN validation failures on cache hits. |
d8c3a6a to
338c287
Compare
|
Thank you Lior Lieberman (@LiorLieberman) for your careful and thorough feedback - it is sorely needed! Addressing some your questions below, which include a couple of questions for you as well. 1 & 2- I completely missed that an actor could return a 503... Looking deeper into this, turns out there IS a way to tell when the 503 is coming from Envoy tcp_proxy, as certain internal flags (ResponseFlags) are set by the Envoy, which allow us to be more granular in our strategy. Another conclusion I gathered is that cache eviction and "replayability" should be decoupled, since there are circumstances in which we will want to evict but not replay (the latter always requires the former, of course). Also, agreed on leaving buffering out of scope here. Regarding the 503s classification:
3- You're totally right. I started re-injecting the header before recreate_stream per your suggestion and added tests. I also added & updated unit tests for all of the above, and I'm now looking into debugging e2e failures, as well as improving the e2e coverage. I'll follow up here with updates on that. |
|
Also updated PR description to reflect latest status. |
I think like you, we should not try to classify whether a req is idempotent based on http methods. so no need to replay until someone shouts On Also - reading the code, I think that on the CONNECT path, a refused CONNECT (with actual stale case) shows up as UC, so it's evicted but not replayed. This means the deafult path (which is CONNECT) never gets a replay. Is my understanding from the code correct? probably not the intention
I could not confirm this - where can I find more about it? I dont think necessarly every client does that On the config.rs impl - I think that the pr description is stale, at least I could not find |
|
+1 do not assume based on verb that you can replay a request. There are many applications that don't obey these semantics unfortunately and there is no way to really tell people to fix this. |
|
Thanks again Lior Lieberman (@LiorLieberman) . Here's another update
|
|
Switching this PR to draft temporarily while we hash out some design decisions offline. |
Bindings for actors that were never looked up again stayed in the cache forever, once per Envoy worker thread. A full thread cache now drops expired bindings before it binds another actor, and doesn't cache the actor if none had expired. It scans at most once a second. Signed-off-by: Pancho <[email protected]>
The websocket testserver gains /hang, which never answers, and /hanging, which counts waiting /hang requests, so the test can suspend an actor while a cache hit is in flight. Signed-off-by: Pancho <[email protected]>
Read the cap from the filter config's max_actors_per_thread, which defaults to 10,000. The router doesn't set it yet. Signed-off-by: Pancho <[email protected]>
Add --ingress-cache-ttl and --ingress-cache-max-cached-actors, which the router passes to the ingress-cache filter as its JSON config. The cap is per Envoy worker thread. Rename the module setting from max_actors_per_thread to max_cached_actors to match. Signed-off-by: Pancho <[email protected]>
Envoy's HTTP/1 codec delivers a bodiless request's headers with end_of_stream, so a GET or HEAD without it or content-length may carry a body: chunked, HTTP/2 without END_STREAM, or an upgrade. A stale hit would replay it without the body. Serve from the cache only requests that end with their headers or have content-length: 0. Signed-off-by: Pancho <[email protected]>
A stale cache hit is now replayed, so the combinedvolumes and identity suites no longer retry after one. Fix test comments that still said UC is never replayed and that the cache is process-wide. Signed-off-by: Pancho <[email protected]>
Clients could forge the ate-endpoint-cached header, and it reached the actor. Match the cached route on dynamic metadata the filter sets instead, and drop the header. Signed-off-by: Pancho <[email protected]>
1d9293d to
426f965
Compare
|
Thank you Lior! It's behind the IngressCache preview gate, OFF by default. |
Signed-off-by: Pancho <[email protected]>
|
For posterity, we are in stabilization period until v1.0. I added v1.1 milestone here. This PR is ready to merge. We should merge it as soon as the stabilization window finishes. |
|
Approved. Lets rebase this one and track it to merge on 11/18 (per https://groups.google.com/g/ate-dev/c/OnUyIc_FGBs/m/kfeKrnwlAAAJ) |
Signed-off-by: Pancho <[email protected]>
Every ingress request calls
ext_procinatenet-router, which callsResumeActoron the ATE API server to find the actor's worker. This adds an Envoy Rust dynamic module (envoy_substrate_ingress_cache) that caches<atespace>/<actor> -> worker IPin Envoy, so bodiless requests to a warm actor skip that call. It's behind theIngressCachepreview gate, off by default.ext_proc, reads the actor fromdev.ate.target.actorfilter state or a singleate-target-actorheader (an inner header on a terminated CONNECT tunnel is ignored). It sets theenvoy.filters.listener.original_dstmetadata (workerip:atunnel_port, actor port, worker SPIFFE ID),x-ate-target-portandate-target-actor, plusate.ingress_cachehitdynamic metadata, and clears the route cache. A dedicated route that matches that metadata, which clients can't set, hasext_procdisabled.ext_procunchanged. On a successful response the filter learns the binding from theoriginal_dstmetadata. Failures aren't learned.content-length: 0use the cache, because Envoy doesn't buffer bodies for replay. Everything else, including all gRPC, chunked or HTTP/2 GETs and upgrades, skips the lookup (bypass). Their responses still refresh the cache if successful.421+x-ate-assignment-stale: true,503withUF/UH/UC/UR(Envoy flags), orgrpc-status: 14evicts the binding it used, but not a newer one. Application 503s without flags are left alone.503 UC). Thetunnel_watcheris a network filter on theactor_connectinternal listener, beforetcp_proxy, that can them apart from byte direction alone. A close withUFmarks the actor's entries for that worker stale; an mid-flight close with a request outstanding marks them spoiled. Its close callback runs insidetcp_proxy's close, so the mark always lands before the router's503.ext_procwithrecreate_stream(restoringate-target-actor; the new stream starts without the hit metadata) only when we have certainty an actor did NOT receive it:421stale,503UF/UH, or503 UCwithupstream_reset_before_response_starteddetails AND only when the cache entry is stale and not spoiled. Replay of requests with body, including all gRPC is left out of scope of this initial implementation.atenet-router's--ingress-cache-ttl(default 5s) and--ingress-cache-max-cached-actors(default 10,000 per thread) set its TTL and size. Known limitations are in the module README.On kind with the router at 2 CPUs and 50 actors, the cache raised the max RPS within a 25ms tail-latency SLO from 3936 to 3968, cut p50 from 3.77ms to 1.03ms, and cut
ext_proccalls by ~96%.AI was used to assist with the development of this change: including knowledge gathering, adversarial testing and review, test coverage writing, refactoring, and all code writing. Line by line read of all deltas by the human author (except for autogenerated vendor/ dir), as well as benchmark and test results review.