Uploaded image for project: 'Apache ServiceComb'
  1. Apache ServiceComb
  2. SCB-1414

Roundbin load balancing algorithm optimizes performance by using sync/atomic instead of mutex.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • mesher
    • None

    Description

      Mersher and servicecenter are implemented by go-chassiss.The roundbin load balancing algorithm in go-chassis use function 'pick'.

      The function 'pick' in go-chassis use mutex to add cursor value. Can we use sync/atomic to get better performance?

      func pick(key string) int {
      mu.RLock()
      i, ok := rrIdxMap[key]
      if !ok {
      mu.RUnlock()
      mu.Lock()
      i, ok = rrIdxMap[key]
      if !ok

      { i = rand.Int() rrIdxMap[key] = i }

      rrIdxMap[key]++
      mu.Unlock()
      return i
      }

      mu.RUnlock()
      mu.Lock()
      rrIdxMap[key]++
      mu.Unlock()
      return i
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            surechen chenshuo
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: