我有一个4节点的elasticsearch集群。我有一个.net控制台应用程序,旨在用来自sql的数据填充集群。只要我保持添加(或删除)记录的速度相当低,一切正常。如果我最终增加线程数,我将从控制台应用程序中看到超时错误。群集共有48个核心,索引记录所需的平均时间约为0.1秒。
我已经能够让它每秒做大约7000条记录(文档)。我从未看到从elasticsearch.net抛出任何表明资源不足的异常。我从未看到任何索引队列重载。服务器永远不会达到超过10%cpu的峰值。看起来问题不是集群或它的配置,而是嵌套连接中的某些内容。这是我的连接代码:
//set up the es client
Uri node = new Uri(ConfigurationManager.AppSettings["ESConnectionString"]);
var connectionPool = new SniffingConnectionPool(new[] { node });
ConnectionSettings settings = new ConnectionSettings(connectionPool);
settings.SetDefaultPropertyNameInferrer(p => p); //ditch the camelcase
settings.SniffOnConnectionFault(true);
settings.SniffOnStartup(true);
settings.SniffLifeSpan(TimeSpan.FromMinutes(1));
settings.SetPingTimeout(3000);
settings.SetTimeout(5000);
settings.MaximumRetries(5);
//settings.SetMaximumAsyncConnections(20);
settings.SetDefaultIndex("dummyindex");
settings.SetBasicAuthentication(ConfigurationManager.AppSettings["ESUser"], ConfigurationManager.AppSettings["ESPass"]);
ElasticClient client = new ElasticClient(settings);
我已经使用http.basic身份验证设置了群集,但是我尝试打开和关闭它并没有区别。 以下是ES节点的一些相关设置:
discovery.zen.minimum_master_nodes: 2
discovery.zen.fd.ping_timeout: 30s
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["CACHE01","CACHE02","CACHE03","CACHE04"]
cluster.routing.allocation.node_concurrent_recoveries: 5
indices.recovery.max_bytes_per_sec: 50mb
http.basic.enabled: true
http.basic.user: "admin"
http.basic.password: "XXXXXXX"
此时我似乎无法弄清楚它是问题的.Net客户端还是服务器?一切都指向客户,但我不知道接下来要尝试什么。 我不认为我可以使用BulkAPI,因为我基本上只是从SQL服务器复制更改,为了使它们保持同步,我会在收到更改后立即执行更改。 看来,当我插入新文档时,我可以更快地进行更新。我已经阅读了更新文档,它几乎看起来像部分更新比完整更新更好,但是每次更新都会发生整个get-update-delete-reindex事件。
根据es docs,我不应该调整线程池或性能设置。我不认为我无论如何都会遇到这些限制。 ES错误日志也不表示任何问题。
有人建议我如何追踪连接错误?
更新: 这是实际错误:
错误:意外结果(SaveToES)。 Elasticsearch.Net.Exceptions.MaxRetryException:嗅探集群中的已知节点导致其自身的maxretry异常---> Elasticsearch.Net.Exceptions.SniffException:嗅探集群中的已知节点导致其自身的maxretry异常---> Elasticsearch.Net.Exceptions.MaxRetryException:重试1次后重试超时00:00:05:' GET _nodes / _all / clear?timeout = 3000'。 InnerException:WebException,InnerMessage:操作已超时,InnerStackTrace:在System.Net.HttpWebRequest.GetResponse() 在Elasticsearch.Net.Connection.HttpConnection.DoSynchronousRequest(HttpWebRequest请求,Byte []数据,IRequestConfiguration requestSpecificConfig) InnerException:WebException,InnerMessage:操作已超时,InnerStackTrace:在System.Net.HttpWebRequest.GetResponse() 在Elasticsearch.Net.Connection.HttpConnection.DoSynchronousRequest(HttpWebRequest request,Byte [] data,IRequestConfiguration requestSpecificConfig)---> System.AggregateException:发生一个或多个错误。 ---> System.Net.WebException:操作已超时 在System.Net.HttpWebRequest.GetResponse() 在Elasticsearch.Net.Connection.HttpConnection.DoSynchronousRequest(HttpWebRequest请求,Byte []数据,IRequestConfiguration requestSpecificConfig) ---内部异常堆栈跟踪结束--- ---内部异常堆栈跟踪结束--- at Elasticsearch.Net.Connection.RequestHandlers.RequestHandlerBase.ThrowMaxRetryExceptionWhenNeeded [T](TransportRequestState
1 requestState, Int32 maxRetries) at Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.RetryRequest[T](TransportRequestState
1 requestState) 在Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.DoRequest [T](TransportRequestState1 requestState) at Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.RetryRequest[T](TransportRequestState
1 requestState) 在Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.DoRequest [T](TransportRequestState1 requestState) at Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.Request[T](TransportRequestState
1 requestState,Object data) 在Elasticsearch.Net.Connection.Transport.Elasticsearch.Net.Connection.ITransportDelegator.Sniff(ITransportRequestState ownerState) ---内部异常堆栈跟踪结束--- ---内部异常堆栈跟踪结束--- 在Elasticsearch.Net.Connection.Transport.Elasticsearch.Net.Connection.ITransportDelegator.Sniff(ITransportRequestState ownerState) 在Elasticsearch.Net.Connection.Transport.Elasticsearch.Net.Connection.ITransportDelegator.SniffClusterState(ITransportRequestState requestState) 在Elasticsearch.Net.Connection.Transport.Elasticsearch.Net.Connection.ITransportDelegator.SniffOnConnectionFailure(ITransportRequestState requestState) 在Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.RetryRequest [T](TransportRequestState1 requestState) at Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.DoRequest[T](TransportRequestState
1 requestState) 在Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.Request [T](TransportRequestState1 requestState, Object data) at Elasticsearch.Net.Connection.Transport.DoRequest[T](String method, String path, Object data, IRequestParameters requestParameters) at Elasticsearch.Net.ElasticsearchClient.DoRequest[T](String method, String path, Object data, IRequestParameters requestParameters) at Elasticsearch.Net.ElasticsearchClient.IndicesCreatePost[T](String index, Object body, Func
2 requestParameters) 在Nest.RawDispatch.IndicesCreateDispatch [T](ElasticsearchPathInfo1 pathInfo, Object body) at Nest.ElasticClient.<CreateIndex>b__281_0(ElasticsearchPathInfo
1 p,ICreateIndexRequest d) 在Nest.ElasticClient.Nest.IHighLevelToLowLevelDispatcher.Dispatch [D,Q,R](D描述符,Func3 dispatch) at Nest.ElasticClient.CreateIndex(Func
2 createIndexSelector) at DCSCache.esvRepository.CreateIndex(String IndexName,String IndexVersion) 在DCSCache.esvRepository.Save(esv ItemToSave,String IndexName,String IndexVersion)