查询 偶尔 消耗时长为3秒多,但实际内部took只有1毫秒
{
"index":"logs-shop-goods",
"type":"_doc",
"body":{
"size":20,
"track_total_hits":true,
"from":40,
"sort":[
{
"is_storage":{
"order":"desc"
}
},
{
"appoint":{
"order":"desc"
}
},
{
"order_sum":{
"order":"desc"
}
}
],
"query":{
"bool":{
"filter":[
{
"match_phrase":{
"categories.k_name":"网课"
}
},
{
"match_phrase":{
"bookCoupon":0
}
},
{
"match_phrase":{
"lotus":0
}
},
{
"match_phrase":{
"hide":0
}
},
{
"match_phrase":{
"state":1
}
},
{
"match_phrase":{
"sell_state":1
}
}
]
}
}
},
"_source":[
"goods_id"
]
}
1、服务器docker 配置:
elasticsearch:
image: elasticsearch-analysis-ik
environment:
- discovery.type=single-node
- 'ES_JAVA_OPTS=-Xms2g -Xmx2g'
- TZ=Asia/Shanghai
volumes:
- /data/elasticsearch/data:/usr/share/elasticsearch/data
networks:
- agent
deploy:
mode: replicated
replicas: 1
placement:
constraints: [node.hostname == iZ2ze4khotag1pkxnwl8g2Z]
logging:
driver: 'json-file'
options:
max-size: '500m'
2、通过portainer做集群
3、$hosts = [ 'elasticsearch:9200' ];单节点
4、会不会是单节点的连接数达到上限,才会出现延迟的情况呢?
5、现象2:不仅仅是查询,新增也会出现这种情况,而且固定都是外部消耗3秒多,内部都是毫秒
6、业务环境是:不同队列不停地进行不同索引的新增、更新、查询等操作,会不会是并发问题?
7、各个索引的"index.refresh_interval": "1s",
{
"index":"logs-shop-goods",
"type":"_doc",
"body":{
"size":20,
"track_total_hits":true,
"from":40,
"sort":[
{
"is_storage":{
"order":"desc"
}
},
{
"appoint":{
"order":"desc"
}
},
{
"order_sum":{
"order":"desc"
}
}
],
"query":{
"bool":{
"filter":[
{
"match_phrase":{
"categories.k_name":"网课"
}
},
{
"match_phrase":{
"bookCoupon":0
}
},
{
"match_phrase":{
"lotus":0
}
},
{
"match_phrase":{
"hide":0
}
},
{
"match_phrase":{
"state":1
}
},
{
"match_phrase":{
"sell_state":1
}
}
]
}
}
},
"_source":[
"goods_id"
]
}
1、服务器docker 配置:
elasticsearch:
image: elasticsearch-analysis-ik
environment:
- discovery.type=single-node
- 'ES_JAVA_OPTS=-Xms2g -Xmx2g'
- TZ=Asia/Shanghai
volumes:
- /data/elasticsearch/data:/usr/share/elasticsearch/data
networks:
- agent
deploy:
mode: replicated
replicas: 1
placement:
constraints: [node.hostname == iZ2ze4khotag1pkxnwl8g2Z]
logging:
driver: 'json-file'
options:
max-size: '500m'
2、通过portainer做集群
3、$hosts = [ 'elasticsearch:9200' ];单节点
4、会不会是单节点的连接数达到上限,才会出现延迟的情况呢?
5、现象2:不仅仅是查询,新增也会出现这种情况,而且固定都是外部消耗3秒多,内部都是毫秒
6、业务环境是:不同队列不停地进行不同索引的新增、更新、查询等操作,会不会是并发问题?
7、各个索引的"index.refresh_interval": "1s",
2 个回复
God_lockin
赞同来自:
zhengrukai
赞同来自:
问题应该是出在节点的连接上
我的代码每次连接es时都重新创建连接,在稍微高点的并发就会出现固定延迟3秒的问题。
解决方式:
laravel 框架下
App/Providers/AppServiceProvider.php下
注册一个es的单例对象,全局使用