Skip to content

Commit 744e0ae

Browse files
Anton Ivanovjenkins
Anton Ivanov
authored and
jenkins
committed
[finagle-memcached] apply offloading of responses after gathering response parts
# Problem Finagle offloads responses from clients ASAP to free up netty threads. If a multikey request to memcached is partitioned across memcached endpoints, each response of such subrequest is offloaded. This means additional inter-thread synchonisation and even additional delay while subresponses are waiting in the offload queue. # Solution Offload responses after all subresponses are collected. JIRA Issues: STOR-8861 Differential Revision: https://phabricator.twitter.biz/D1184723
1 parent d6872e1 commit 744e0ae

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

finagle-memcached/src/main/scala/com/twitter/finagle/Memcached.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.twitter.hashing
66
import com.twitter.finagle.client._
77
import com.twitter.finagle.dispatch.SerialServerDispatcher
88
import com.twitter.finagle.dispatch.StalledPipelineTimeout
9+
import com.twitter.finagle.filter.OffloadFilter
910
import com.twitter.finagle.liveness.FailureAccrualFactory
1011
import com.twitter.finagle.liveness.FailureAccrualPolicy
1112
import com.twitter.finagle.loadbalancer.Balancers
@@ -268,6 +269,12 @@ object Memcached extends finagle.Client[Command, Response] with finagle.Server[C
268269
BindingFactory.role,
269270
MemcachedPartitioningService.module
270271
)
272+
// We want offloading to happen after partitioning, i.e. after all responses are collected
273+
// to reduce pressure on offload pool
274+
.remove(OffloadFilter.Role)
275+
.insertBefore(
276+
MemcachedPartitioningService.role,
277+
OffloadFilter.client[Command, Response])
271278
// We want this to go after the MemcachedPartitioningService so that we can get individual
272279
// spans for fanout requests. It's currently at protoTracing, so we remove it to re-add below
273280
.remove(MemcachedTracingFilter.memcachedTracingModule.role)

0 commit comments

Comments
 (0)