lokidundun commented on issue #7758:
URL: 
https://github.com/apache/incubator-seata/issues/7758#issuecomment-3776321450

   > Create a robust server-side connection management mechanism with load 
balancing to distribute client call traffic evenly, avoiding single-client 
overload and improving system stability.
   > 
   > Implementation Steps
   > 1. Add Load Balancing Core Components
   > 
   > - Add loadbalance sub-package under org.apache.seata.core.rpc.netty
   > - Define LoadBalance<T> interface (core method: select(List<T> candidates))
   > - Implement 2 default strategies:
   >    -  --RoundRobinLoadBalance (default, thread-safe with AtomicInteger for 
index tracking)
   >    -  --RandomLoadBalance (alternative, uses Random for selection)
   > 
   > - Create LoadBalanceFactory:
   >   -   --Register strategies in a static map
   >   -   --Fetch strategy via Seata Configuration (default: roundrobin)
   > 
   > 2. Enhance ChannelManager for Connection Management
   > 
   > - Inject LoadBalance<Channel> instance into ChannelManager (via 
LoadBalanceFactory)
   > 
   > - Refactor getChannel() method:
   >   -  --Collect all active channels (filter via channel.isActive()) for 
target IP/app/resource
   >   -   --Replace "first-available" selection with 
loadBalance.select(activeChannels)
   > - Update getChannelFromSameClientMap():
   >   -  --Gather active channels first, then apply load balancing
   > - Add auto-cleanup for inactive channels:
   >   -  --Remove disconnected channels during active channel collection
   > - Refactor tryOtherApp() 
   >   -  --Collect cross-application active channels, then select via load 
balancing
   > 
   > 3. Configuration & Compatibility Handling
   > 
   > - Add configuration item to seata-server.properties:
   >   -  --seata.server.loadbalance.type (options: roundrobin/random; default: 
roundrobin)
   > - Maintain backward compatibility:
   >   -  --Retain original ChannelManager method signatures
   >   -  --Fall back to existing logic if no active channels are available
   > 
   > 4. Unit Tests:
   >   - Test load balance strategies (round-robin/random selection correctness)
   >   - Test ChannelManager active channel filtering/cleanup
   > 
   > Key Technical Details
   > 
   >   - Leverage existing Seata classes:
   >   - ChannelManager (core connection management)
   >   - ServerOnRequestProcessor (server-to-client call entry)
   >   - Configuration/ConfigurationFactory (strategy configuration)
   >   - RpcContext/Channel (connection metadata)
   
   This is a plan I thought. What do you think about it? If this issue is not 
urgent, I'd like to give it a try.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to