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

[Feature Request] Optimize the api _cat/nodes #14746

Open
kkewwei opened this issue Jul 14, 2024 · 7 comments · May be fixed by #14853
Open

[Feature Request] Optimize the api _cat/nodes #14746

kkewwei opened this issue Jul 14, 2024 · 7 comments · May be fixed by #14853
Labels
Cluster Manager enhancement Enhancement or improvement to existing feature or request

Comments

@kkewwei
Copy link
Contributor

kkewwei commented Jul 14, 2024

Is your feature request related to a problem? Please describe

Now the method is as follows:

        return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<>(channel) {
                     ......
                    nodesInfoRequest.timeout(request.param("timeout"));
                    client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {
                               ......
                               // wait all the nodes response
                               nodesStatsRequest.timeout(request.param("timeout"));
                              client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
                                      ......
                               }
                    }
        }

It seems has two problems:

  1. cluster().nodesInfo() and cluster().nodesStats() use separate timeout, in that case, if timeout from the client is 30s, without adding cluster().state(), the overall time can be 60s, which is 2x times that the expect.
  2. Only all nodes return the a NodeInfoResponse in cluster().nodesInfo() can the next cluster().nodesStats() be called. It's normal to have a slow node(such as fullGc) in large clusters, the api will become unresponsive, it means that if some of nodes are blocked in cluster().nodesInfo(), the overrall api will be blocked.

Describe the solution you'd like

  1. If timeout is 30s in _cat/nodes, the overall time should be around 30s.
  2. If some of nodes are blocked, it doesn't affect the rest nodes to get metrics. Each node separately call cluster().nodesInfo() and cluster().nodesStats().

The code can be like this:

        long time1 = threadPool.relativeTimeInMillis();
        return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<>(channel) {
                     ......
                    long time2 = threadPool.relativeTimeInMillis();
                    nodesInfoRequest.timeout(timeout - (time2-time1)));
                    for (String nodeId : nodeIds) {
                         nodesInfoRequest.nodesIds(nodeId);
                          client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {
                                    ......
                                    long time3 = threadPool.relativeTimeInMillis();
                                    nodesStatsRequest.timeout(timeout - (time3-time1)));
                                    nodesStatsRequest.nodesIds(nodeId);
                                   client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
                                         ......
                                    }
                           }
                    }
                    channel.sendResponse(RestTable.buildResponse(buildTable(fullId, request, clusterStateResponse, nodesInfoResponse, nodesStatsResponse), channel));

        }

Related component

Cluster Manager

Describe alternatives you've considered

No response

Additional context

No response

@kkewwei kkewwei added enhancement Enhancement or improvement to existing feature or request untriaged labels Jul 14, 2024
@kkewwei kkewwei linked a pull request Jul 22, 2024 that will close this issue
3 tasks
@shwetathareja
Copy link
Member

cc : @aasom143 who was looking into holistic API cancellation across different cat and cluster APIs

@rajiv-kv
Copy link
Contributor

rajiv-kv commented Aug 1, 2024

[Triage - attendees 1 2 3 4] - @kkewwei Thanks for creating the issue.
Please check if this can leverage the cancellation framework 13908

@kkewwei
Copy link
Contributor Author

kkewwei commented Aug 23, 2024

[Triage - attendees 1 2 3 4] - @kkewwei Thanks for creating the issue. Please check if this can leverage the cancellation framework 13908

@rajiv-kv The the cancellation framework can be used here to solve the first problem, It doesn't solve the second problem.

I wold like to solve the two of the problems within the cancellation framework, cc @aasom143.

@aasom143
Copy link
Contributor

aasom143 commented Sep 6, 2024

Hi @kkewwei, thanks for following up. With the new cancellation framework, we have added a new timeout(cancel_after_time_interval) that can be used to address the first problem. For the second issue, we already have a timeout which can configured for each node's transport call. By setting this timeout, we can prevent our requests from being blocked by a faulty node. I hope this provides clarity on how to resolve the second problem.

@aasom143
Copy link
Contributor

aasom143 commented Sep 6, 2024

To address the first issue, could you please add cancellation support for the cat/nodes API? You can refer to the recent PR regarding cancellation support for the cat/shards API.

@kkewwei
Copy link
Contributor Author

kkewwei commented Sep 11, 2024

To address the first issue, could you please add cancellation support for the cat/nodes API? You can refer to the recent PR regarding cancellation support for the cat/shards API.

Of course, thank you.

@kkewwei
Copy link
Contributor Author

kkewwei commented Oct 19, 2024

@aasom143, It's ok now, please have a look when you are free.#14853

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cluster Manager enhancement Enhancement or improvement to existing feature or request
Projects
Status: 🏗 In progress
Development

Successfully merging a pull request may close this issue.

5 participants