public static ServiceInstance getHostByRandomWeight3(
			List<ServiceInstance> serviceInstances) {
		Map<Instance, ServiceInstance> instanceMap = new HashMap<>();
		List<Instance> nacosInstance = serviceInstances.stream().map(serviceInstance -> {
			Map<String, String> metadata = serviceInstance.getMetadata();

			// see
			// com.alibaba.cloud.nacos.discovery.NacosServiceDiscovery.hostToServiceInstance()
			Instance instance = new Instance();
			instance.setIp(serviceInstance.getHost());
			instance.setPort(serviceInstance.getPort());
			instance.setWeight(Double.parseDouble(metadata.get("nacos.weight")));
			instance.setHealthy(Boolean.parseBoolean(metadata.get("nacos.healthy")));
			instanceMap.put(instance, serviceInstance);
			return instance;
		}).collect(Collectors.toList());

		Instance instance = getHostByRandomWeight2(nacosInstance);
		NacosServiceInstance nacosServiceInstance = (NacosServiceInstance) instanceMap.get(instance);
		// When local support IPv6 address stack, referred to use IPv6 address.
		if (StringUtils.isNotEmpty(NacosLoadBalancer.ipv6)) {
			convertIPv4ToIPv6(nacosServiceInstance);
		}
		return nacosServiceInstance;
	}
Spring Cloud LoadBalancer Choose instance by weight.
@param serviceInstances Instance List
@return the chosen instance
spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/balancer/NacosBalancer.java