-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cluster): Add support for request proxying for scale out #2385
Conversation
This turned out to be a fairly simple change. |
Thanks for the base commit @rchincha. It set a good foundation for me to build on :) |
5bccf03
to
cefa689
Compare
cefa689
to
b60fc9e
Compare
latter wold it be possible to leverage this to scale out in situations where a shared storage is not available by also setting up syncs between the members? |
b60fc9e
to
af97207
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2385 +/- ##
==========================================
- Coverage 92.86% 92.85% -0.02%
==========================================
Files 167 168 +1
Lines 22077 22289 +212
==========================================
+ Hits 20502 20696 +194
- Misses 982 993 +11
- Partials 593 600 +7 ☔ View full report in Codecov by Sentry. |
af97207
to
bf4651e
Compare
Hi @luisdavim, thank you for the question! This PR focuses on shared storage, but support for a situation without shared storage is definitely something that is being looked into. |
bf4651e
to
ed62c20
Compare
Add detailed comments in your commit msg. This is a significant feature enhancement. |
ed62c20
to
acc11b7
Compare
ea5ea86
to
a47e785
Compare
Line 263 in a716be3
resp, err := httpClient.Do(fwdRequest) ^ make sure the regex check is done on this "url" before forwarding |
"Nightly jobs / s3+dynamodb scale-out performance" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to compute the sockets on every request? Is there a performance impact?
Yes, we shouldn't. |
a47e785
to
1f3dca7
Compare
I agree, this a performance hit especially since it happens for every request. I've changed to logic to perform the socket logic at the controller startup (because we need the member data for logging). This happens only once. When proxying, we do a lookup on the index alone (since all the zots have an identical member config) which is a quicker comparison than string compare too. |
This change introduces support for shared storage backed zot cluster scale out. New feature Multiple stateless zot instances can run using the same shared storage backend where each instance looks at a specific set of repositories based on a siphash of the repository name to improve scale as the load is distributed across multiple instances. For a given config, there will only be one instance that can perform dist-spec read/write on a given repository. What's changed? - introduced a transparent request proxy for dist-spec endpoints based on siphash of repository name. - new config for scale out cluster that specifies list of cluster members. Signed-off-by: Vishwas Rajashekar <[email protected]>
1f3dca7
to
645fad2
Compare
TODO: checking if any extras after the specified path are also routed to the same handler. Left a comment above on the fact that the regex is already done before routing. Doing it once more would add a penalty to every proxied request. If there is a chance that other paths are routed here, a regex would be needed. |
If the regex is already done, I suppose since clusterProxy is a wrapper around the routes, no need to do it again. |
Regarding the regex, I tried adding some query params to the API call, and it seems to have let it through:
Logs: {"level":"info","clusterMember":"127.0.0.1:9001","clusterMemberIndex":"1","module":"http","component":"session","clientIP":"127.0.0.1:51370","method":"GET","path":"/v2/alpine/tags/list?example=test","statusCode":200,"latency":"0s","bodySize":35,"headers":{"Accept":["*/*"],"Accept-Encoding":["gzip"],"User-Agent":["curl/7.81.0"],"X-Zot-Cluster-Hop-Count":["1"]},"goroutine":27,"caller":"zotregistry.dev/zot/pkg/api/session.go:132","time":"2024-05-18T14:07:28.799382217Z","message":"HTTP API"} This is no different from the usual behaviour of the application though. Any extra path params will fail the query, as expected:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
What type of PR is this?
feature
Which issue does this PR fix:
Towards #125
Carry forward of #2041
Initial fork PR rchincha#160
What does this PR do / Why do we need it:
This PR adds support for proxying requests to other members of a zot instance cluster for scale out.
This PR only has support for shared storage cluster scale out.
Testing done on this change:
Automation added to e2e:
N/A - no functionality change from an application point of view. The proxy is transparent to clients.
Will this break upgrades or downgrades?
No. Scale-out is new and there wouldn't be existing setups using this config yet.
Does this PR introduce any user-facing change?:
yes
TODO:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.