Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve data plugin performance #84923

Open
mshustov opened this issue Dec 3, 2020 · 6 comments
Open

Improve data plugin performance #84923

mshustov opened this issue Dec 3, 2020 · 6 comments
Assignees
Labels
Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) Feature:Search Querying infrastructure in Kibana impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. loe:medium Medium Level of Effort performance Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. triage_needed

Comments

@mshustov
Copy link
Contributor

mshustov commented Dec 3, 2020

The data plugin, being one of the most fundamental plugins in the Kibana ecosystem, is the critical part of improving the overall Kibana performance.

Network

If you run Kibana with APM enabled (see instruction), you can notice that the plugin performs some amount of duplicated network requests, which can be optimized:
2020-12-03_13-52-08
2020-12-03_14-30-36

Note: I've got these numbers running Kibana and Elasticsearch locally - the network latency might be even higher on Cloud.

Code

  • re-use API created by the core.
    const esClient = elasticsearch.client.asScoped(request);
    const savedObjectsClient = savedObjects.getScopedClient(request);
    const scopedIndexPatterns = await indexPatterns.indexPatternsServiceFactory(
    savedObjectsClient,
    esClient.asCurrentUser
    );
    const uiSettingsClient = uiSettings.asScopedToClient(savedObjectsClient);
    // cache ui settings, only including items which are explicitly needed by SearchSource
    const uiSettingsCache = pick(
    await uiSettingsClient.getAll(),
    searchSourceRequiredUiSettings
    );
    here RequestHandlerContext can be used.
  • extend RequestHandlerContext with lazy instantiated API
    class CoreElasticsearchRouteHandlerContext {
    #client?: IScopedClusterClient;
    #legacy?: {
    client: Pick<LegacyScopedClusterClient, 'callAsInternalUser' | 'callAsCurrentUser'>;
    };
    constructor(
    private readonly elasticsearchStart: InternalElasticsearchServiceStart,
    private readonly request: KibanaRequest
    ) {}
    public get client() {
    if (this.#client == null) {
    this.#client = this.elasticsearchStart.client.asScoped(this.request);
    }
    return this.#client;
    }
    public get legacy() {
    if (this.#legacy == null) {
    this.#legacy = {
    client: this.elasticsearchStart.legacy.client.asScoped(this.request),
    };
    }
    return this.#legacy;
    }
    }
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServices)

@lukeelmers
Copy link
Member

lukeelmers commented Dec 3, 2020

here RequestHandlerContext can be used

Awhile back there was a discussion around avoiding using RequestHandlerContext in cases like this because of some of the complexities it creates for folks authenticating via API keys (for example alerting would need to not only generate a fake KibanaRequest to create an alert that relies on the search service, but now also a fake RequestHandlerContext).

However, performance did not come up as a potential issue in that discussion.

@streamich has suggested a caching layer in the data plugin's services. Another option would be to go down the path of restructuring everything to accept scoped services, which was an alternative approach proposed in that thread.

@lukeelmers
Copy link
Member

Also on the same topic of data plugin performance, there's this related issue about whether we can further decrease the page load bundle size: #84788

@streamich streamich added Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) Feature:FieldFormatters Feature:Data Views Data Views code and UI - index patterns before 8.0 Feature:Search Querying infrastructure in Kibana impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. loe:medium Medium Level of Effort labels May 4, 2021
@lizozom
Copy link
Contributor

lizozom commented Apr 18, 2022

@lukeelmers @mshustov

This issue has been without activity for a while now.
Is it still relevant? Can it be made more actionable?
If it is releveant, we can add it to the Kibana Performance project and groom it.

@mshustov
Copy link
Contributor Author

Is it still relevant? Can it be made more actionable?

It's on AppServices team to answer these questions as they own data plugin

@petrklapka petrklapka added Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. and removed Team:AppServicesSv labels Nov 28, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) Feature:Search Querying infrastructure in Kibana impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. loe:medium Medium Level of Effort performance Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. triage_needed
Projects
None yet
Development

No branches or pull requests

9 participants