Issue 1:
I have searched the issues of this repository and believe that this is not a duplicate.

I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

Dubbo version: 2.7.4-SNAPSHOT

Operating System version: macOS 10.14.5

Java version: 1.8.0_172

Steps to reproduce this issue

I see there is LRU cache implement in dubbo, and LFU is also a useful cache strategy. So, if it's necessary to impl LFU, I will try my best to work on it.

Issue 2:
I have searched the issues of this repository and believe that this is not a duplicate.

I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

Dubbo version: 2.7.3

Operating System version: macOS

Java version: 1.8

Steps to reproduce this issue

服务端打开dubbo协议，并监听8080端口

客户端通过dubbo作为代理，以直连的方式与服务端建立连接。

String url="dubbo://127.0.0.1:20880"
ReferenceConfig<DemoService> referenceConfig = new ReferenceConfig<>();
referenceConfig.setInterface(DemoService.class);
referenceConfig.setUrl(url);

客户端跟服务端的网络出现问题，请求无法到达服务端。

原因：

为了避免并发请求重复创建线程，Netty在建连的时候时加锁的。

org.apache.dubbo.remoting.transport.netty.NettyClient

@Override
protected void doConnect() throws Throwable {
long start = System.currentTimeMillis();
ChannelFuture future = bootstrap.connect(getConnectAddress());
try {
boolean ret = future.awaitUninterruptibly(getConnectTimeout(), TimeUnit.MILLISECONDS);
...
} finally {

}
}

org.jboss.netty.channel.DefaultChannelFuture

private boolean await0(long timeoutNanos, boolean interruptable) throws InterruptedException {
try {
synchronized (this) {
try {
for (;;) {
try {
this.wait(waitTime / 1000000, (int) (waitTime % 1000000));
} catch (InterruptedException e) {

}
}
} finally {
}
}
} finally {
}
}

从调用的堆栈中可以发现，在请求发送之前会检查当前连接是否可用，如果不可用就会重新建连。

假设同时进来了100个请求，第一个请求发现连接不可用需要重新建连，由于服务端不可达，就会一直持有连接的锁，直到3s超时之后才会释放锁。那么，第100个请求等待的时候就是100*3=300s，会导致线程被大量阻塞。

at org.apache.dubbo.remoting.transport.netty.NettyClient.doConnect(NettyClient.java:130)
at org.apache.dubbo.remoting.transport.AbstractClient.connect(AbstractClient.java:189)
at org.apache.dubbo.remoting.transport.AbstractClient.<init>(AbstractClient.java:71)
at org.apache.dubbo.remoting.transport.netty.NettyClient.<init>(NettyClient.java:59)
at org.apache.dubbo.remoting.transport.netty.NettyTransporter.connect(NettyTransporter.java:37)
at com.ctrip.framework.cdubbo.internal.delegate.CDubboTransporterDelegate.connect(CDubboTransporterDelegate.java:25)
at org.apache.dubbo.remoting.Transporter$Adaptive.connect(Transporter$Adaptive.java)
at org.apache.dubbo.remoting.Transporters.connect(Transporters.java:75)
at org.apache.dubbo.remoting.exchange.support.header.HeaderExchanger.connect(HeaderExchanger.java:39)
at org.apache.dubbo.remoting.exchange.Exchangers.connect(Exchangers.java:109)
at org.apache.dubbo.rpc.protocol.dubbo.LazyConnectExchangeClient.initClient(LazyConnectExchangeClient.java:83)
at org.apache.dubbo.rpc.protocol.dubbo.LazyConnectExchangeClient.request(LazyConnectExchangeClient.java:127)

Pls. provide [GitHub address] to reproduce this issue.

Expected Result

对于直连模式，在出现服务端连接不可用的情况下，能够支持快速失败。

Actual Result

对于直连模式，在出现服务端连接不可用的情况下，会导致线程阻塞。

If there is an exception, please attach the exception trace:

Just put your stack trace here!