Proxy: Make Redis and Memory LB TTL configurable#4650
Open
liukun4515 wants to merge 1 commit intoossrs:developfrom
Open
Proxy: Make Redis and Memory LB TTL configurable#4650liukun4515 wants to merge 1 commit intoossrs:developfrom
liukun4515 wants to merge 1 commit intoossrs:developfrom
Conversation
Fixes ossrs#4647 Changed hardcoded TTL constants to configurable environment variables: - PROXY_SERVER_ALIVE_DURATION (default: 300s) - PROXY_HLS_ALIVE_DURATION (default: 120s) - PROXY_RTC_ALIVE_DURATION (default: 120s) This allows customers to adjust TTL values based on their scenarios. Changes: - Added three new environment variable getters in env.Environment interface - Replaced hardcoded constants with configurable helper functions - Updated MemoryLoadBalancer.Pick() to use configurable server alive duration - Updated RedisLoadBalancer TTL for server, HLS, and RTC keys - Added TTL values to startup logs for visibility
70f14fc to
ebf8b71
Compare
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.
Summary
Fixes #4647
Makes the hardcoded TTL values in Redis and Memory load balancers configurable through environment variables, allowing customers to adjust them based on their scenarios.
Problem
Currently, the TTL values are hardcoded:
ServerAliveDuration = 300s(5 minutes)HLSAliveDuration = 120s(2 minutes)RTCAliveDuration = 120s(2 minutes)For some scenarios, 300 seconds is too long, and customers need the ability to configure these values.
Solution
Added three new configurable environment variables:
PROXY_SERVER_ALIVE_DURATION(default:300s)PROXY_HLS_ALIVE_DURATION(default:120s)PROXY_RTC_ALIVE_DURATION(default:120s)Usage Examples
Reduce server TTL to 60 seconds:
Custom TTL for all values:
Changes
Testing
Files Changed
proxy/internal/env/env.go: +27, -1proxy/internal/lb/lb.go: +28, -6proxy/internal/lb/mem.go: +5, -1proxy/internal/lb/redis.go: +19, -5🤖 Generated with Claude Code