繁体   English   中英

Twitter Finagle打开太多文件

[英]Twitter Finagle open too many files

我使用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:为什么mapValues生成视图,并且有任何稳定的替代方法? ,Map的mapValue方法可能比较棘手

val resultIsAView = m.mapValue(mapFunction)

每次使用结果视图resultIsAView时,都会重新评估函数mapFunction

您可以确认只创建一个finagleClient ,而不为每个收到的请求创建一个吗? (即Thrift.newIface应该在rpc方法之外)。

其他可能的原因,您可能只有一个客户端,但是otherRpc后端从未响应,因此您的服务器会为每个请求创建一个新的连接(因为先前的请求仍在“使用中”)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM