# Search slow when high concurrency?

**URL:** <https://discuss.elastic.co/t/search-slow-when-high-concurrency/63125>\
**Category:** Elasticsearch\
**Created:** [October 16, 2016, 10:52am UTC](https://discuss.elastic.co/t/search-slow-when-high-concurrency/63125 "2016-10-16T10:52:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![famoss](https://avatars.discourse-cdn.com/v4/letter/f/67e7ee/32.png) [@famoss](https://discuss.elastic.co/u/famoss)\
**Post date:** [October 16, 2016, 10:52am UTC](https://discuss.elastic.co/t/search-slow-when-high-concurrency/63125/1 "2016-10-16T10:52:52Z")

</div>

I have a index which need to save about 100 million docs,and the index-type have about 30 fields..

Here's what I do.

template:

```
{
    "template": "index*",
    "settings": {
        "number_of_shards": 6,
        "number_of_replicas": 1
    },
    "mappings": {
        "type": {
            "_all": {
                "enabled": false
            },
            "dynamic_templates": [
                {
                    "notanalyzed": {
                        "match_mapping_type": "string",
                        "mapping": {
                            "type": "string",
                            "index": "not_analyzed"
                        }
                    }
                }
            ],
            "properties": {
                "field1":{
                     "type": "string"
                },
                "field2":{
                    "type": "string"
                },
                "field3":{
                    "type": "string",
                     "index": "not_analyzed"
                },
                "field4":{
                    "type": "long"
                },
                "field5":{
                    "type": "string",
                     "index": "not_analyzed"
                },
                "field6":{
                    "type": "string",
                     "index": "not_analyzed"
                }
            }
        }
    }
}

```

dsl:

```
{
"filtered": {
    "filter": {
        "bool": {
            "should": [
                {
                    "term": {
                        "field3": "xxx"
                    }
                },
                {
                    "range": {
                        "field4": {
                            "lt": "xxx",
                            "gte": "xxx"
                        }
                    }
                }
            ],
            "must": [
                {
                    "term": {
                        "field6": "xxx"
                    }
                }
            ],
            "from": 0,
            "sort": [
                {
                    "field5": "asc"
                }
            ]
        }
    }
}

```

`{"term":{"field6":"?"}`,`field6` about have 1 million different values,and need to be used for query every time, `field4` is a time stamp，different query has different value.

server:  
3 servers(ssd,98G memory,32 core cpu),each server i deploy 3 nodes,1 master node(10G heap size),2 data nodes(20G heap size).

**EDIT:**  
I find if i use 500 thread to search,and the `es` response very slow,and many search need be executed exceed 20000 millisecond,and `es` `search.queue` sometimes exceed 500,So i want to optimize my cluster or search dsl.

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [October 19, 2016, 6:32am UTC](https://discuss.elastic.co/t/search-slow-when-high-concurrency/63125/2 "2016-10-19T06:32:49Z")

</div>

Hi @famoss,

500 concurrent search requests against a three node cluster are just too much. It's natural for systems that response times increase, when systems are overloaded. To give you an analogy: Think of 500 customers calling a hotline with 3 agents that answer the phone. Naturally, customers will have to wait. If you're interested in the theory just google for "Little's Law".

So, you should scale horizontally (see the [Definitive Guide](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/_scale_horizontally.html#_then_scale_some_more) for specific suggestions). It's also not ideal that you run multiple nodes per machine as they will steal resources from each other (see [some tips for running multiple nodes per machine](https://discuss.elastic.co/t/can-i-run-multiple-elasticsearch-nodes-on-the-same-machine/)).

Daniel

---

<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:** [July 5, 2017, 10:11pm UTC](https://discuss.elastic.co/t/search-slow-when-high-concurrency/63125/3 "2017-07-05T22:11:25Z")

</div>


