Skip to content

LoadBalancedRSocketMono loose sockets on server restart #633

@GusevAnton

Description

@GusevAnton

I have more than one server applications and I'm using LoadBalancedRSocketMono.
If I restart one of them, then all request will forward to a single node.

I've found the exception here, because new socket have zero values.

private synchronized void quickSlowestRS() {
    if (activeSockets.size() <= 1) {
      return;
    }

    WeightedSocket slowest = null;
    double lowestAvailability = Double.MAX_VALUE;
    for (WeightedSocket socket : activeSockets) {
      double load = socket.availability();
      if (load == 0.0) {
        slowest = socket;
        break;
      }
      if (socket.getPredictedLatency() != 0) {
        load *= 1.0 / socket.getPredictedLatency();
      }
      if (load < lowestAvailability) {
        lowestAvailability = load;
        slowest = socket;
      }
    }

    if (slowest != null) {
      activeSockets.remove(slowest);
    }
  }

the call is in WeightedSocket

synchronized (LoadBalancedRSocketMono.this) {
                  if (activeSockets.size() >= targetAperture) {
                    quickSlowestRS();
                    pendingSockets -= 1;
                  }
}

I think we don't need execute this method when we restart server node.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions