You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As part of #1388, to support Dashboards connecting to multiple OpenSearch Cluster, the thread discussed adding a new saved object datasource, and referenced to the data model of index-pattern. There's also a proposed POC PR.
There's an issue with the POC code. When it establishes the connection with external datasource, it was using the @opensearch-js client in the search strategy.
This is not resource efficient since it creates a connection for each and every query. We need better approach to do client management.
Proposed Solution [WIP]
We can take a look at how clients are managed in Dashboards core. The lifecycle starts when Dashboards-core plugin is spinning up, it creates 2 client and registers to the core context to expose to other modules through http services. It can spawn child clients as needed(AsScopedClient) from auth in request, which returns a new client instance that shares the connection pool with the parent client. If you call close in any of the parent/child clients, every client will be closed. The connections close when Dashboards stops.
We may consider adding one more client only for external data source, to the ClusterClient class. And wire our logic to spawn child clients as needed, from datasource. Similar to asScoped function.
zhongnansu
changed the title
[POC Proposal] Efficient client management to support multiple OpenSearch clusters
[POC] Efficient client management to support multiple OpenSearch clusters
Apr 26, 2022
zhongnansu
changed the title
[POC] Efficient client management to support multiple OpenSearch clusters
[PoC] Efficient client management to support multiple OpenSearch clusters
Apr 26, 2022
My poc code PR zengyan-amazon#2. it's based on the poc did by @zengyan-amazon (Issue #1388 / PR #1499), which have the data sources added and use plain Client for each request to data source.
However, step 5 is blocked.
adjust client config as needed(header, ssl). May need add new parsing logic specific for dataSourceClient
Basically the connection failed connecting to the test endpoint I give, instead routing the request to localhost. It seems that certain ConnectionPool options is not allowed to configure while creating client.child(), for example Connection. It was documented in Elastic
You can pass to the child every client option you would pass to a normal client, but the connection pool specific options (ssl, agent, pingTimeout, Connection, and resurrectStrategy).
Implement a client pooling strategy that keeps a number of clients(e.g. 200), maintain LRU cache to manage. Within each client scope, we can still use .child() to handler different user on the same endpoint.
Spend some time exploring opensearch-js client lib, to see if by making minor change we can enable node(endpoint) option for child() instances.
Problem Statement
As part of #1388, to support Dashboards connecting to multiple OpenSearch Cluster, the thread discussed adding a new saved object
datasource
, and referenced to the data model ofindex-pattern
. There's also a proposed POC PR.There's an issue with the POC code. When it establishes the connection with external datasource, it was using the @opensearch-js client in the search strategy.
OpenSearch-Dashboards/src/plugins/data/server/search/opensearch_search/ext_opensearch_search_strategy.ts
Lines 87 to 93 in beb46f5
This is not resource efficient since it creates a connection for each and every query. We need better approach to do client management.
Proposed Solution [WIP]
We can take a look at how clients are managed in Dashboards core. The lifecycle starts when Dashboards-core plugin is spinning up, it creates 2 client and registers to the core context to expose to other modules through http services. It can spawn child clients as needed(AsScopedClient) from auth in request, which returns a new client instance that shares the connection pool with the parent client. If you call
close
in any of the parent/child clients, every client will be closed. The connections close when Dashboards stops.We may consider adding one more client only for external data source, to the
ClusterClient
class. And wire our logic to spawn child clients as needed, fromdatasource
. Similar toasScoped
function.OpenSearch-Dashboards/src/core/server/opensearch/client/cluster_client.ts
Lines 76 to 79 in 4469d17
OpenSearch-Dashboards/src/core/server/opensearch/client/cluster_client.ts
Lines 91 to 98 in 4469d17
POC is needed and I am currently working on it
Changes need to make
asCurrentUser
andasInternalUser
, define a new interfaceasDataSourceUser
, forcontext.core.client
to callcluster_client
only for data Sourcecore Context
, in order to retrieve data source meta info, that will be used to establish connectiondataSourceClient
The text was updated successfully, but these errors were encountered: