private boolean useLifoMode() {
    boolean localLifoMode = deque.size() > lifoThreshold;
    if (localLifoMode && lifoMode.compareAndSet(false, true)) {
      // Mode changed to LIFO
      logger.info("Request queue operating is LIFO mode");
    } else if (!localLifoMode && lifoMode.compareAndSet(true, false)) {
      // Mode changed to FIFO
      logger.info("Request queue operating is FIFO mode");
    }
    return localLifoMode;
  }
Based on queue size, decide whether the queue should operate in LIFO or FIFO mode.
@return {@code true} if the queue should operate in LIFO mode.
ambry-network/src/main/java/com/github/ambry/network/AdaptiveLifoCoDelNetworkRequestQueue.java