Fix 504 timeout: Add K8s client caching + QPS increase + benchmarks#5430
Open
shovan-mondal wants to merge 3 commits intolitmuschaos:masterfrom
Open
Fix 504 timeout: Add K8s client caching + QPS increase + benchmarks#5430shovan-mondal wants to merge 3 commits intolitmuschaos:masterfrom
shovan-mondal wants to merge 3 commits intolitmuschaos:masterfrom
Conversation
55066e9 to
801e684
Compare
amityt
approved these changes
Feb 17, 2026
Contributor
amityt
left a comment
There was a problem hiding this comment.
Thanks for the changes @shovan-mondal Will definitely help in optimization and scaling. 🚀
amityt
reviewed
Feb 17, 2026
Contributor
Author
|
Great suggestion, @amityt You're completely right, different cluster sizes will need different limits. I will move these to environment variables while keeping 50 and 100 as the sensible defaults. I'll push the updated commit shortly! |
Signed-off-by: shovan-mondal <shovanmondal2004@gmail.com>
Signed-off-by: shovan-mondal <shovanmondal2004@gmail.com>
Signed-off-by: shovan-mondal <shovanmondal2004@gmail.com>
5f20ffd to
b246e85
Compare
Contributor
Author
|
@amityt I havepushed the settings to environment variables. Now Ready for review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Fixes #5079 (504 Gateway Timeouts).
This PR addresses a critical concurrency anti-pattern in the subscriber's
GetGenericK8sClient, where a newkubernetes.Clientsetwas being initialized for every single request.The Issue:
The Fix:
sync.Onceto enforce a Singleton pattern for the Kubernetes client (reusing the TCP connection).rest.Configwith QPS=50 and Burst=100 to handle concurrent UI requests without client-side throttling.client_perf_test.goto validate the performance improvement.Benchmark Results:
I ran a parallel benchmark simulating 20 concurrent requests.
Types of changes
What types of changes does your code introduce to Litmus? Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Dependency
Special notes for your reviewer:
I have included a new test file
pkg/k8s/parallel_benchmark_test.gowhich runs the benchmark scenarios shown above. You can verify the fix locally by running:This test proves that the singleton implementation matches the speed of the unthrottled code (~38ms) but maintains a single persistent connection, eliminating the TLS handshake overhead that causes the 504s in production.