0

I'm using memcached codec in a finagle application. But the performance is very poor, way worse than using spymemcached client. I got 8k req/s with spymemached and 10 req/s with finagle's memcached codec. The memcached is running in my machine too. Am I missing something? A example of an error during stress test:

Mar 05, 2014 10:22:10 AM com.twitter.finagle.builder.SourceTrackingMonitor handle
SEVERE: A server service httpserver threw an exception
com.twitter.finagle.ChannelWriteException: org.jboss.netty.channel.ConnectTimeoutException: connection timed out: localhost/127.0.0.1:11211
at com.twitter.finagle.NoStacktrace(Unknown Source)
Caused by: org.jboss.netty.channel.ConnectTimeoutException: connection timed out: localhost/127.0.0.1:11211
at org.jboss.netty.channel.socket.nio.NioClientBoss.processConnectTimeout(NioClientBoss.java:137)
at org.jboss.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:83)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)
at org.jboss.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

How the client is configured:

 def client = Client( ClientBuilder()
    .hosts(parseHosts())
    .hostConnectionLimit(10)
    .codec(Memcached())
    .retries(2)
    .daemon(true)
    .build() )

A simple get operation:

def getUserTries(username: String): Future[Int] = {
   client.get(s"${username}_tries") flatMap { v => v match {
      case Some(c:ChannelBuffer) => Future.value( UserCache.fromChannelBuffer(c).toInt )
      case _ => Future.value(0)
   }
}

And a set operation:

def saveUserTries(username: String, tries: Int): Future[Unit] = {
   client.set( s"${username}_tries", UserCache.toChannelBuffer(tries.toString) )
}

1 Answers1

0

You should achieve similar performance with Finagle, but I don't see anything wrong with code you pasted. You should maybe have a look at this finagle memcached benchmark and adapt it to your usage.

Steve Gury
  • 15,158
  • 6
  • 38
  • 42