0

I am curious about how does envoy store or manage the active request for each host and then use them for the Least Request First load balancing. Since the documentation of Envoy states that it picks N hosts randomly and then selects the least requested from them. This is algorithm gives O(1) complexity and very good results. So if envoy stores all active request count why doesn't it use a algorithm which may work in O(logn) to find the least requested host. Which could be implemented with a suitable data structure like segment trees.

I have read through the documentation and tried to look through the source code. But was unable to find what i was looking for .

Documentation

1 Answers1

0

I think this comment answers your question:

// As with tryChooseLocalLocalityHosts, this can be refactored for efficiency
// but O(N) is good enough for now given the expected number of priorities is
// small.

So it's about priorities in the backlog. Feel free to jump in and improve it ;)

Sergey Romanovsky
  • 4,216
  • 4
  • 25
  • 27