# Problem with elasticsearch performance when excuting aggregations

**URL:** <https://discuss.elastic.co/t/problem-with-elasticsearch-performance-when-excuting-aggregations/105271>\
**Category:** Elasticsearch\
**Created:** [October 25, 2017, 3:01pm UTC](https://discuss.elastic.co/t/problem-with-elasticsearch-performance-when-excuting-aggregations/105271 "2017-10-25T15:01:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sarra\_Bouhenni](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Sarra\_Bouhenni](https://discuss.elastic.co/u/Sarra_Bouhenni)\
**Post date:** [October 25, 2017, 3:01pm UTC](https://discuss.elastic.co/t/problem-with-elasticsearch-performance-when-excuting-aggregations/105271/1 "2017-10-25T15:01:05Z")

</div>

Hello Elastic community,

First of all, I would like to thank the ELK team for their support and rich online documentation.

But, I'm facing a performance problem that I didn't know how to solve, let me explain:  
I have datatables on kibana along with other visualisations like maps, histograms etc.  
I have documents of type "trip [date,rider,driver,destination,pickup,cost,distance,etc]",  
I have created a datatable to aggregate trips like that:

```
{
  "title": "Request list",
  "type": "table",
  "params": {
    "perPage": 10,
    "showMeticsAtAllLevels": false,
    "showPartialRows": false,
    "showTotal": false,
    "sort": {
      "columnIndex": 8,
      "direction": "desc"
    },
    "totalFunc": "sum"
  },
  "aggs": [
    {
      "id": "10",
      "enabled": true,
      "type": "min",
      "schema": "metric",
      "params": {
        "field": "requested_at",
        "customLabel": "Date of first request"
      }
    },
    {
      "id": "1",
      "enabled": true,
      "type": "count",
      "schema": "metric",
      "params": {
        "customLabel": "Number of requests"
      }
    },
    {
      "id": "11",
      "enabled": true,
      "type": "terms",
      "schema": "bucket",
      "params": {
        "field": "rider_profile.rider_id",
        "size": 10000,
        "order": "desc",
        "orderBy": "10",
        "customLabel": "Rider ID"
      }
    },
    {
      "id": "2",
      "enabled": true,
      "type": "terms",
      "schema": "bucket",
      "params": {
        "field": "rider_profile.full_name",
        "size": 10000,
        "order": "desc",
        "orderBy": "1",
        "customLabel": "Rider name"
      }
    },
    {
      "id": "3",
      "enabled": true,
      "type": "terms",
      "schema": "bucket",
      "params": {
        "field": "rider_profile.email",
        "size": 10000,
        "order": "desc",
        "orderBy": "1",
        "customLabel": "Rider email"
      }
    },
    {
      "id": "4",
      "enabled": true,
      "type": "terms",
      "schema": "bucket",
      "params": {
        "field": "rider_profile.phone",
        "size": 10000,
        "order": "desc",
        "orderBy": "1",
        "customLabel": "Rider phone"
      }
    },
    {
      "id": "5",
      "enabled": true,
      "type": "terms",
      "schema": "bucket",
      "params": {
        "field": "pickup.formatted_address",
        "size": 10000,
        "order": "desc",
        "orderBy": "1",
        "customLabel": "Pickup location"
      }
    },
    {
      "id": "6",
      "enabled": true,
      "type": "terms",
      "schema": "bucket",
      "params": {
        "field": "destination.formatted_address",
        "size": 10000,
        "order": "desc",
        "orderBy": "1",
        "customLabel": "Destination"
      }
    },
    {
      "id": "7",
      "enabled": true,
      "type": "terms",
      "schema": "bucket",
      "params": {
        "field": "status",
        "size": 10000,
        "order": "desc",
        "orderBy": "1",
        "customLabel": "Status"
      }
    },
    {
      "id": "8",
      "enabled": true,
      "type": "terms",
      "schema": "bucket",
      "params": {
        "field": "estimated_distance",
        "size": 10000,
        "order": "desc",
        "orderBy": "1",
        "customLabel": "Distance"
      }
    },
    {
      "id": "9",
      "enabled": true,
      "type": "terms",
      "schema": "bucket",
      "params": {
        "field": "estimated_cost",
        "size": 10000,
        "order": "desc",
        "orderBy": "1",
        "customLabel": "Cost"
      }
    }
  ],
  "listeners": {}
}

```

In my index, I have 19920 documents, but when setting a bigger date range, I get the error `Bad gateway` which means that my cluster is **Overloaded!**  
My cluster consists of

- 2 master nodes
- 1 Client node
- 3 Data node
- 1 Discovery node

Do you think that I'm doing wrong visualizations (specially with an aggregation of size 10000) Or is it a problem with my cluster performance that need to be enhanced (I would to not go to this solution because I already have a limited ressources).

Thanks in advance for any clarifications or propositions.

---

<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:** [November 22, 2017, 3:01pm UTC](https://discuss.elastic.co/t/problem-with-elasticsearch-performance-when-excuting-aggregations/105271/2 "2017-11-22T15:01:07Z")

</div>

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