cloudflare / pingora

A library for building fast, reliable and evolvable network services.
Apache License 2.0
21.76k stars 1.21k forks source link

How should we set L4/L7 traffic weights? #441

Open ShyunnY opened 3 days ago

ShyunnY commented 3 days ago

I'm not sure if there is a similar issue mentioning this.

I'm new to pingora and I want to be able to configure traffic weights at the L4/L7 layer.

I see the default configuration of weight=1 in the source code, and I don't seem to find where I should configure this weight:

{
  let mut upstreams = BTreeSet::new();
  for addrs in iter.into_iter() {
  let addrs = addrs.to_socket_addrs()?.map(|addr| Backend {
    ...
    weight: 1, 
  });
  ...
  }
  Ok(Self::new(upstreams))
}

Are there any helper functions or examples? Thanks!

ShyunnY commented 1 day ago

Hi, can anyone give me a quick start example? I hope to use it as soon as possible.

thanks!