Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) Log replication thread model #168

Closed
fengjiachun opened this issue May 21, 2019 · 0 comments · Fixed by #170
Closed

(feat) Log replication thread model #168

fengjiachun opened this issue May 21, 2019 · 0 comments · Fixed by #170
Assignees
Milestone

Comments

@fengjiachun
Copy link
Contributor

Your question

在并发量大的时候,Replicator.sendEntries() 锁竞争比较激烈,有大量的 block, 见这里
阻塞的是 JRaft-RPC-Processor 线程,这对 jraft 中其他操作比如 pre-vote、vote 等均有一定的影响

Your scenes

这个现象理论上是 sendEntriesonRpcReturned 线程不同导致的锁竞争,onRpcReturned 是被 bolt RPC 的 executor 调用,通用的 ThreadPoolExecutor 无法做到绑定 Thread 的方式进行调度

Your advice

Replicator 中增加一个 replicatorId 属性(最好用一个全局自增 int),再提供一个特殊的 thread pool,可以按照类似 [replicatorId % pool.length] 的方式将一个 Replicator instance 固定映射到一个 Thread 上,这个方式相比每个 Replicator 创建一个 Thread,在 multi-group 复制组很多的情况下,可以少创建很多线程,至于 pool 的 size,需要在 options 中配置

Environment

  • SOFAJRaft version: v1.2.5
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:
@fengjiachun fengjiachun self-assigned this May 21, 2019
@fengjiachun fengjiachun added this to the 1.2.6 milestone May 24, 2019
killme2008 pushed a commit that referenced this issue Jul 5, 2019
* (feat) add FixedThreadsExecutorGroup #168

* (feat) rename method

* (feat) add MpscSingleThreadExecutor and benchmark #168

* (fix) forget to warmup producers

* (fix) fix some bugs and add unit test

* (fix) add more unit test

* (fix) add more unit test

* (fix) add more unit test

* (fix) add some comments

* (fix) unit test

* (fix) add some comments

* (fix) refactoring Utils class

* (fix) refactoring Utils class

* (fix) jraft.closure.threadpool.size.max update default value

* (fix) fix unit test

* (fix) fix unit test

* (feat) refactor ThreadId and replicator (#169)

* (feat) refactor ThreadId and replicator

* (feat) Adds javadoc

* (feat) add pooled buf allocator (#161)

* (feat) add AdaptiveBufAllocator

* (feat) pooled for ByteBufferCollector #158

* (feat) pooled for ByteBufferCollector #158

* (feat) pooled for ByteBufferCollector #158

* (feat) pooled for ByteBufferCollector #158

* (fix) rename method name

* (fix) minor fix

* (fix) add metric for recyclers (#164)

* (fix) add metric for recyclers

* (fix) add metric for ByteBufferCollector.capacity

* (fix) code format

* (fix) by review comment

* feat/zero copy with replicator (#167)

* (fix) zero copy with replicator

* (fix) support zero copy and add benchmark

* (fix) rename field

* (fix) rm zero copy and unnecessary metric

* (fix) by review comment

* (feat) add unit test AdaptiveBufAllocatorTest

* (feat) add unit test RecyclersTest

* (feat) add unit test RecyclableByteBufferListTest

* (feat) add unit test ByteBufferCollectorTest

* Add unit tests for com.alipay.sofa.jraft.util.BytesUtil (#166)

These tests were written using Diffblue Cover.

* (fix) Utils.java format

* (feat) add FixedThreadsExecutorGroup #168

* (feat) rename method

* (feat) add MpscSingleThreadExecutor and benchmark #168

* (fix) forget to warmup producers

* (fix) fix some bugs and add unit test

* (fix) add more unit test

* (fix) add more unit test

* (fix) add more unit test

* (fix) add some comments

* (fix) unit test

* (fix) add some comments

* (fix) refactoring Utils class

* (fix) refactoring Utils class

* (fix) jraft.closure.threadpool.size.max update default value

* (fix) fix unit test

* (fix) fix unit test

* (feat) add pooled buf allocator (#161)

* (feat) add AdaptiveBufAllocator

* (feat) pooled for ByteBufferCollector #158

* (feat) pooled for ByteBufferCollector #158

* (feat) pooled for ByteBufferCollector #158

* (feat) pooled for ByteBufferCollector #158

* (fix) rename method name

* (fix) minor fix

* (fix) add metric for recyclers (#164)

* (fix) add metric for recyclers

* (fix) add metric for ByteBufferCollector.capacity

* (fix) code format

* (fix) by review comment

* feat/zero copy with replicator (#167)

* (fix) zero copy with replicator

* (fix) support zero copy and add benchmark

* (fix) rename field

* (fix) rm zero copy and unnecessary metric

* (fix) by review comment

* (feat) add unit test AdaptiveBufAllocatorTest

* (feat) add unit test RecyclersTest

* (feat) add unit test RecyclableByteBufferListTest

* (feat) add unit test ByteBufferCollectorTest

* (fix) Utils.java format

* (fix) fix bad key with executor map

* (fix) bad import

* (fix) fix unit test

* (feat) add mor benchmark

* (fix) code format

* (fix) code format

* (fix) benchmark with jmh

* (fix) benchmark with jmh

* (fix) set common daemon

* (fix) fix unit test

* (fix) should be no radical changes, especially if they are not fully tested.

* (feat) add jctools

* (feat) configure the number of processors #180 (#181)

* (fix) format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant