# Question: ES response size limitations | 502 bad gateway

**URL:** https://discuss.elastic.co/t/question-es-response-size-limitations-502-bad-gateway/152447
**Category:** Elasticsearch
**Created:** [October 15, 2018, 8:09am UTC](https://discuss.elastic.co/t/question-es-response-size-limitations-502-bad-gateway/152447 "2018-10-15T08:09:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![omurbekjk](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omurbekjk](https://discuss.elastic.co/u/omurbekjk)
#### Post date: [October 15, 2018, 8:09am UTC](https://discuss.elastic.co/t/question-es-response-size-limitations-502-bad-gateway/152447/1 "2018-10-15T08:09:37Z")

</div>

We have large data in ES, we send request with the size limit: 1,000 and we do pagination to get remaining results.  
Sometimes we get 502 bad gateway, hard to debug what went wrong.  
I assumed if the response size is too large maybe the server is failing to serve it.  
Also we do aggregation with the size limit: 10 000.

1. What is the recommended size for es query and aggregation?
2. How should we handle aggregation queries when we do pagination?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [October 15, 2018, 8:42am UTC](https://discuss.elastic.co/t/question-es-response-size-limitations-502-bad-gateway/152447/2 "2018-10-15T08:42:29Z")

</div>

Can you share the query that failed?

> What is the recommended size for es query and aggregation?

The default values are the recommended ones.

> How should we handle aggregation queries when we do pagination?

Aggs are computed on the whole resultset whatever the page you're looking at.

---

<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 12, 2018, 8:53am UTC](https://discuss.elastic.co/t/question-es-response-size-limitations-502-bad-gateway/152447/3 "2018-11-12T08:53:37Z")

</div>

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