我使用Twitter-Finagle创建服务器。在服务器的每个RPC函数中,只需使用Finagle客户机调用另一个服务器的RPC。就像这样:
def rpc() = {
// finagleClient is created in a std way according to Finagle's Doc:
// val client = Thrift.newIface[Hello.FutureIface]("localhost:8080")
// http://twitter.github.io/finagle/guide/Protocols.html#thrift-and-scrooge
//
val f: Future[xx] = finagleClient.otherRpc()
f onSuccess { // do something }
f onFailure { // handle exception }
}但是,不太久,错误就会发生:
org.jboss.netty.channel.socket.nio.AbstractNioSelector: Failed to accept a connection
java.io.IOException: open too many files而且,我使用lsof -p并发现到另一个服务器的连接太多了(大约5000个连接!)我想知道它是怎么发生的?我错过了什么吗。
================问题求解=============
请参考Scala: Why mapValues produces a view and is there any stable alternatives?,Map的mapValue方法可能很棘手
val resultIsAView = m.mapValue(mapFunction)每次使用结果视图mapFunction时,都会重新评估函数resultIsAView。
发布于 2015-01-30 00:02:53
您能否确认您只创建了一个finagleClient,而不是为每个收到的请求创建了一个?(即Thrift.newIface应该在rpc方法之外)。
其他潜在原因是,您可能只有一个客户端,但otherRpc后端从未响应,因此您的服务器为每个请求创建一个新连接(因为上一个请求仍在“使用中”)。
https://stackoverflow.com/questions/28213800
复制相似问题