# Why does not es use FileChannel2SocketChannel to recover shard？

**URL:** <https://discuss.elastic.co/t/why-does-not-es-use-filechannel2socketchannel-to-recover-shard/302224>\
**Category:** Elasticsearch\
**Created:** [April 12, 2022, 12:25pm UTC](https://discuss.elastic.co/t/why-does-not-es-use-filechannel2socketchannel-to-recover-shard/302224 "2022-04-12T12:25:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vsop\_479](https://avatars.discourse-cdn.com/v4/letter/v/6f9a4e/32.png) [@vsop\_479](https://discuss.elastic.co/u/vsop_479)\
**Post date:** [April 12, 2022, 12:25pm UTC](https://discuss.elastic.co/t/why-does-not-es-use-filechannel2socketchannel-to-recover-shard/302224/1 "2022-04-12T12:25:27Z")

</div>

Why does not es use FileChannel2SocketChannel to recover shard? which can eliminate the copy between user and kernel.  
The only benefit that sending file though heap, i can think is to control sending rate. Is there any other reasons to do so？

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [April 12, 2022, 3:33pm UTC](https://discuss.elastic.co/t/why-does-not-es-use-filechannel2socketchannel-to-recover-shard/302224/2 "2022-04-12T15:33:57Z")

</div>

Mainly simplicity. This isn't really an area that needs heavy optimisation, in fact it needs artificial throttling to limit the impact of recoveries on the rest of the system. There's some opportunity to save a bit of CPU here but it's just not really worth it.

Note that inter-node communications are typically encrypted and therefore need to be copied to userspace for decryption. I expect it will eventually be possible to offload the decryption work to the kernel (or even to dedicated hardware) but this is still only available in relatively new kernels and AFAIK not in the JDK yet.

---

<div class="post-metadata">

**Author:** ![vsop\_479](https://avatars.discourse-cdn.com/v4/letter/v/6f9a4e/32.png) [@vsop\_479](https://discuss.elastic.co/u/vsop_479)\
**Post date:** [April 13, 2022, 2:43am UTC](https://discuss.elastic.co/t/why-does-not-es-use-filechannel2socketchannel-to-recover-shard/302224/3 "2022-04-13T02:43:23Z")

</div>

Thanks, it's resolved my puzzle.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 11, 2022, 2:43am UTC](https://discuss.elastic.co/t/why-does-not-es-use-filechannel2socketchannel-to-recover-shard/302224/4 "2022-05-11T02:43:27Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
