elasticsearch聚合在大型索引的小子集上内存不足

时间:2014-10-17 16:22:14

标签: elasticsearch

我有一个名为'reporting'的索引,我们为每个用户存储不同类型的每日统计信息。我们有大约2,000名用户。我们的索引是大约2亿个大约2亿个文件。我们针对特定用户在日期范围内的统计信息对此索引执行聚合。

在这种情况下,我们正在执行过滤的'bool'查询并执行术语匹配以按用户ID(一次1到2个用户ID)进行过滤,并按范围匹配按日期范围过滤。我们有一个存储桶聚合,它按用户ID和子聚合对它们进行分组,子聚合为每个存储桶合并一个值。

看起来像这样:

{
    "query": {
        "filtered": {
            "filter": {
                "bool": {
                    "must": [
                        {
                            "terms": {
                                "uid": [1,2,3]
                            }
                        },
                        {
                            "range": {
                                "d": {
                                    "gte": "2014-10-01",
                                    "lte": "2014-10-12"
                                }
                            }
                        }
                    ]
                }
            }
        }
    },
    "aggs": {
        "group_by_user": {
            "terms": {
                "field": "uid",
                "size": 0
            },
            "aggs": {
                "spend": {
                    "sum": {
                        "field": "sp"
                    }
                }
            }
        }
    }
}

问题是我在耗尽内存时遇到断路器异常。 [Data too large, data for field [uid] would be larger than limit of [2802686361/2.6gb]];

我们在一个3节点集群上运行它,每个节点有7.5gb的内存;我不禁觉得我在查询/过滤器上做错了。任何帮助或指导都将非常感激。

编辑:添加_stats的输出

{
    "_shards": {
        "total": 6,
        "successful": 6,
        "failed": 0
    },
    "_all": {
        "primaries": {
            "docs": {
                "count": 212102401,
                "deleted": 318328
            },
            "store": {
                "size_in_bytes": 46498616525,
                "throttle_time_in_millis": 94162
            },
            "indexing": {
                "index_total": 9405119,
                "index_time_in_millis": 3091378,
                "index_current": 0,
                "delete_total": 0,
                "delete_time_in_millis": 0,
                "delete_current": 0
            },
            "get": {
                "total": 2,
                "time_in_millis": 22,
                "exists_total": 0,
                "exists_time_in_millis": 0,
                "missing_total": 2,
                "missing_time_in_millis": 22,
                "current": 0
            },
            "search": {
                "open_contexts": 0,
                "query_total": 1611,
                "query_time_in_millis": 489683,
                "query_current": 0,
                "fetch_total": 56,
                "fetch_time_in_millis": 62,
                "fetch_current": 0
            },
            "merges": {
                "current": 0,
                "current_docs": 0,
                "current_size_in_bytes": 0,
                "total": 831,
                "total_time_in_millis": 1228785,
                "total_docs": 33098268,
                "total_size_in_bytes": 7812950398
            },
            "refresh": {
                "total": 4978,
                "total_time_in_millis": 358409
            },
            "flush": {
                "total": 29,
                "total_time_in_millis": 8926
            },
            "warmer": {
                "current": 0,
                "total": 10852,
                "total_time_in_millis": 2293
            },
            "filter_cache": {
                "memory_size_in_bytes": 613970692,
                "evictions": 33934
            },
            "id_cache": {
                "memory_size_in_bytes": 0
            },
            "fielddata": {
                "memory_size_in_bytes": 4045281152,
                "evictions": 0
            },
            "percolate": {
                "total": 0,
                "time_in_millis": 0,
                "current": 0,
                "memory_size_in_bytes": -1,
                "memory_size": "-1b",
                "queries": 0
            },
            "completion": {
                "size_in_bytes": 0
            },
            "segments": {
                "count": 95,
                "memory_in_bytes": 1671534384,
                "index_writer_memory_in_bytes": 0,
                "version_map_memory_in_bytes": 0
            },
            "translog": {
                "operations": 436449,
                "size_in_bytes": 59595977
            },
            "suggest": {
                "total": 0,
                "time_in_millis": 0,
                "current": 0
            }
        },
        "total": {
            "docs": {
                "count": 424204629,
                "deleted": 685198
            },
            "store": {
                "size_in_bytes": 93177256029,
                "throttle_time_in_millis": 1609799
            },
            "indexing": {
                "index_total": 86978099,
                "index_time_in_millis": 31607032,
                "index_current": 0,
                "delete_total": 0,
                "delete_time_in_millis": 0,
                "delete_current": 0
            },
            "get": {
                "total": 4,
                "time_in_millis": 46,
                "exists_total": 0,
                "exists_time_in_millis": 0,
                "missing_total": 4,
                "missing_time_in_millis": 46,
                "current": 0
            },
            "search": {
                "open_contexts": 0,
                "query_total": 4674,
                "query_time_in_millis": 766372,
                "query_current": 0,
                "fetch_total": 114,
                "fetch_time_in_millis": 133,
                "fetch_current": 0
            },
            "merges": {
                "current": 0,
                "current_docs": 0,
                "current_size_in_bytes": 0,
                "total": 7700,
                "total_time_in_millis": 19175664,
                "total_docs": 358907679,
                "total_size_in_bytes": 82787257943
            },
            "refresh": {
                "total": 34174,
                "total_time_in_millis": 3192066
            },
            "flush": {
                "total": 175,
                "total_time_in_millis": 83934
            },
            "warmer": {
                "current": 0,
                "total": 76291,
                "total_time_in_millis": 29435
            },
            "filter_cache": {
                "memory_size_in_bytes": 1244975360,
                "evictions": 79602
            },
            "id_cache": {
                "memory_size_in_bytes": 0
            },
            "fielddata": {
                "memory_size_in_bytes": 8267198587,
                "evictions": 0
            },
            "percolate": {
                "total": 0,
                "time_in_millis": 0,
                "current": 0,
                "memory_size_in_bytes": -1,
                "memory_size": "-1b",
                "queries": 0
            },
            "completion": {
                "size_in_bytes": 0
            },
            "segments": {
                "count": 192,
                "memory_in_bytes": 3333325472,
                "index_writer_memory_in_bytes": 0,
                "version_map_memory_in_bytes": 0
            },
            "translog": {
                "operations": 876208,
                "size_in_bytes": 59595977
            },
            "suggest": {
                "total": 0,
                "time_in_millis": 0,
                "current": 0
            }
        }
    },
    "indices": {
        "reporting-stats": {
            "primaries": {
                "docs": {
                    "count": 212102401,
                    "deleted": 318328
                },
                "store": {
                    "size_in_bytes": 46498616525,
                    "throttle_time_in_millis": 94162
                },
                "indexing": {
                    "index_total": 9405119,
                    "index_time_in_millis": 3091378,
                    "index_current": 0,
                    "delete_total": 0,
                    "delete_time_in_millis": 0,
                    "delete_current": 0
                },
                "get": {
                    "total": 2,
                    "time_in_millis": 22,
                    "exists_total": 0,
                    "exists_time_in_millis": 0,
                    "missing_total": 2,
                    "missing_time_in_millis": 22,
                    "current": 0
                },
                "search": {
                    "open_contexts": 0,
                    "query_total": 1611,
                    "query_time_in_millis": 489683,
                    "query_current": 0,
                    "fetch_total": 56,
                    "fetch_time_in_millis": 62,
                    "fetch_current": 0
                },
                "merges": {
                    "current": 0,
                    "current_docs": 0,
                    "current_size_in_bytes": 0,
                    "total": 831,
                    "total_time_in_millis": 1228785,
                    "total_docs": 33098268,
                    "total_size_in_bytes": 7812950398
                },
                "refresh": {
                    "total": 4978,
                    "total_time_in_millis": 358409
                },
                "flush": {
                    "total": 29,
                    "total_time_in_millis": 8926
                },
                "warmer": {
                    "current": 0,
                    "total": 10852,
                    "total_time_in_millis": 2293
                },
                "filter_cache": {
                    "memory_size_in_bytes": 613970692,
                    "evictions": 33934
                },
                "id_cache": {
                    "memory_size_in_bytes": 0
                },
                "fielddata": {
                    "memory_size_in_bytes": 4045281152,
                    "evictions": 0
                },
                "percolate": {
                    "total": 0,
                    "time_in_millis": 0,
                    "current": 0,
                    "memory_size_in_bytes": -1,
                    "memory_size": "-1b",
                    "queries": 0
                },
                "completion": {
                    "size_in_bytes": 0
                },
                "segments": {
                    "count": 95,
                    "memory_in_bytes": 1671534384,
                    "index_writer_memory_in_bytes": 0,
                    "version_map_memory_in_bytes": 0
                },
                "translog": {
                    "operations": 436449,
                    "size_in_bytes": 59595977
                },
                "suggest": {
                    "total": 0,
                    "time_in_millis": 0,
                    "current": 0
                }
            },
            "total": {
                "docs": {
                    "count": 424204629,
                    "deleted": 685198
                },
                "store": {
                    "size_in_bytes": 93177256029,
                    "throttle_time_in_millis": 1609799
                },
                "indexing": {
                    "index_total": 86978099,
                    "index_time_in_millis": 31607032,
                    "index_current": 0,
                    "delete_total": 0,
                    "delete_time_in_millis": 0,
                    "delete_current": 0
                },
                "get": {
                    "total": 4,
                    "time_in_millis": 46,
                    "exists_total": 0,
                    "exists_time_in_millis": 0,
                    "missing_total": 4,
                    "missing_time_in_millis": 46,
                    "current": 0
                },
                "search": {
                    "open_contexts": 0,
                    "query_total": 4674,
                    "query_time_in_millis": 766372,
                    "query_current": 0,
                    "fetch_total": 114,
                    "fetch_time_in_millis": 133,
                    "fetch_current": 0
                },
                "merges": {
                    "current": 0,
                    "current_docs": 0,
                    "current_size_in_bytes": 0,
                    "total": 7700,
                    "total_time_in_millis": 19175664,
                    "total_docs": 358907679,
                    "total_size_in_bytes": 82787257943
                },
                "refresh": {
                    "total": 34174,
                    "total_time_in_millis": 3192066
                },
                "flush": {
                    "total": 175,
                    "total_time_in_millis": 83934
                },
                "warmer": {
                    "current": 0,
                    "total": 76291,
                    "total_time_in_millis": 29435
                },
                "filter_cache": {
                    "memory_size_in_bytes": 1244975360,
                    "evictions": 79602
                },
                "id_cache": {
                    "memory_size_in_bytes": 0
                },
                "fielddata": {
                    "memory_size_in_bytes": 8267198587,
                    "evictions": 0
                },
                "percolate": {
                    "total": 0,
                    "time_in_millis": 0,
                    "current": 0,
                    "memory_size_in_bytes": -1,
                    "memory_size": "-1b",
                    "queries": 0
                },
                "completion": {
                    "size_in_bytes": 0
                },
                "segments": {
                    "count": 192,
                    "memory_in_bytes": 3333325472,
                    "index_writer_memory_in_bytes": 0,
                    "version_map_memory_in_bytes": 0
                },
                "translog": {
                    "operations": 876208,
                    "size_in_bytes": 59595977
                },
                "suggest": {
                    "total": 0,
                    "time_in_millis": 0,
                    "current": 0
                }
            }
        }
    }
}

0 个答案:

没有答案