# NEST async VS sync

**URL:** <https://discuss.elastic.co/t/nest-async-vs-sync/156427>\
**Category:** Elasticsearch\
**Created:** [November 13, 2018, 9:35am UTC](https://discuss.elastic.co/t/nest-async-vs-sync/156427 "2018-11-13T09:35:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yoav](https://avatars.discourse-cdn.com/v4/letter/y/58f4c7/32.png) [@yoav](https://discuss.elastic.co/u/yoav)\
**Post date:** [November 13, 2018, 9:35am UTC](https://discuss.elastic.co/t/nest-async-vs-sync/156427/1 "2018-11-13T09:35:32Z")

</div>

Using NEST in .net core 2.1  
Is there any reason not to use async calls? For example (SearchAsync, DeleteIndexAsync, BulkAsync)  
Should we always prefer async NEST methods over sync methods?  
Thanks

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [November 20, 2018, 12:23am UTC](https://discuss.elastic.co/t/nest-async-vs-sync/156427/2 "2018-11-20T00:23:28Z")

</div>

Like most things in Software Development, "it depends" 🙂 Some non-exhaustive points to consider:

1. Are blocking threads and synchronously waiting on HTTP requests to complete a measurable bottleneck in your application for concurrently handling requests?
2. Does your application need to maintain a responsive UI whilst work is performed in the background?
3. Do other dependencies you have only expose async code paths, forcing the viral nature of async throughout?

There is overhead to using `async`/`await` in terms of memory allocation, compiler generated state machines and typically a small performance hit. The benefit for _largely_ I/O bound operations is asynchronous concurrency.

Ultimately, the best way to determine whether to use sync or async methods would be to benchmark both approaches in your application.

---

<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:** [December 18, 2018, 12:23am UTC](https://discuss.elastic.co/t/nest-async-vs-sync/156427/3 "2018-12-18T00:23:29Z")

</div>

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