Skip to content

负载均衡

Haotian Zhang edited this page Oct 28, 2025 · 8 revisions

目录

简介

北极星默认提供了一些负载均衡能力Spring Cloud Tencent 为简化开发者使用,统一注入默认的负载均衡器,以便支持基于配置指定默认的负载均衡算法。

调整负载均衡策略

配置方式设置

Spring Cloud Tencent 提供了两种通过配置的方式来达到调整负载均衡策略的方式。

全局负载均衡策略

spring.cloud.loadbalancer.strategies

单一服务负载均衡策略

spring.cloud.loadbalancer.clients.{service-id}.strategies

可选负载均衡策略

负载均衡策略
polarisWeightedRoundRobin 默认负载均衡策略。权重轮询算法。算法实现:https://github.com/polarismesh/polaris-java/pull/413
roundRobin 轮询算法
random 随机算法
polarisWeightedRandom 权重随机算法,通过北极星页面调整权重生效的前提是负载均衡算法是 polarisWeightedRandom
polarisRingHash 一致性哈希算法
polarisShortestResponseTime 最短相应时间算法
polarisLeastConnection 最短连接数算法

Clone this wiki locally