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: RTT helpers for NGS endpoints #921

Closed
wants to merge 6 commits into from

Conversation

boris-ilijic
Copy link
Contributor

@boris-ilijic boris-ilijic commented Nov 13, 2023

PR contains the new command that should contain NGS-related helpers.
Currently, RTT sub-command is implemented with following options:

$ nats ngs rtt -h 
usage: nats ngs rtt [<flags>] [<iterations>]

Displays RTT for all NGS endpoints. See:
https://docs.synadia.com/ngs/resources/connection-endpoints

Args:
  [<iterations>]  How many round trips to do when testing each NGS endpoint

Flags:
  -g, --global       query default (global) endpoint: tls://connect.ngs.global
  -c, --all-clouds   query all Cloud Endpoints (AWS, AZ, GCP)
      --aws          query AWS Cloud Endpoint: tls://aws.cloud.ngs.global
      --az           query AZ Cloud Endpoint: tls://az.cloud.ngs.global
      --gpc          query GCP Cloud Endpoint: tls://gcp.cloud.ngs.global
  -r, --all-regions  query all Regional Endpoints (Asia, EU, US)
      --asia         query regional endpoint in Asia: tls://asia.geo.ngs.global
      --eu           query regional endpoint in EU: tls://eu.geo.ngs.global
      --us           query regional endpoint in US: tls://us.geo.ngs.global
      --us-east      query regional endpoint in US East: tls://east.us.geo.ngs.global
      --us-west      query regional endpoint in US West: tls://west.us.geo.ngs.global
  -a, --all          query all available endpoints

Why another command?

It will be possible to expand ngs command with additional helpers, e.g. nats ngs usage related to querying nats req ngs.usage XXd and that will be added in separated PR in case this one is accepted.

Examples for nats ngs rtt

$ nats ngs rtt -g
╭─────────────────────────────────────────────────────────────────────╮
│                            NGS Endpoints                            │
├──────────────────────────┬──────────────────────────────────────────┤
│ Endpoint                 │ RTT                                      │
├──────────────────────────┼──────────────────────────────────────────┤
│ tls://connect.ngs.global │     tls://34.159.142.0:4222: 15.661296ms │
│                          │     tls://34.107.15.96:4222: 15.409145ms │
│                          │    tls://34.89.235.191:4222: 15.545593ms │
│                          │                                          │
╰──────────────────────────┴──────────────────────────────────────────╯
$ nats ngs rtt --all-clouds                                                                                                                                     on git:ngs-endpoints-rtt|⚑1 o
╭────────────────────────────────────────────────────────────────────────╮
│                              NGS Endpoints                             │
├────────────────────────────┬───────────────────────────────────────────┤
│ Endpoint                   │ RTT                                       │
├────────────────────────────┼───────────────────────────────────────────┤
│ tls://aws.cloud.ngs.global │      tls://34.254.41.96:4222: 37.864441ms │
│                            │     tls://63.34.115.219:4222: 40.373466ms │
│                            │     tls://34.249.55.202:4222: 39.356726ms │
│                            │                                           │
├────────────────────────────┼───────────────────────────────────────────┤
│ tls://az.cloud.ngs.global  │    tls://20.229.178.151:4222: 23.416578ms │
│                            │        tls://20.86.6.48:4222: 24.857193ms │
│                            │      tls://20.224.12.45:4222: 22.07743ms  │
│                            │                                           │
├────────────────────────────┼───────────────────────────────────────────┤
│ tls://gcp.cloud.ngs.global │      tls://34.107.15.96:4222: 15.512467ms │
│                            │      tls://34.159.142.0:4222: 15.221053ms │
│                            │     tls://34.89.235.191:4222: 15.797824ms │
│                            │                                           │
╰────────────────────────────┴───────────────────────────────────────────╯
$ nats ngs rtt --asia                                                                                                                                           on git:ngs-endpoints-rtt|⚑1 o
╭─────────────────────────────────────────────────────────────────────────╮
│                              NGS Endpoints                              │
├───────────────────────────┬─────────────────────────────────────────────┤
│ Endpoint                  │ RTT                                         │
├───────────────────────────┼─────────────────────────────────────────────┤
│ tls://asia.geo.ngs.global │       tls://34.81.56.112:4222: 234.216252ms │
│                           │    tls://104.199.229.130:4222: 221.977669ms │
│                           │      tls://35.234.43.228:4222: 248.738544ms │
│                           │                                             │
╰───────────────────────────┴─────────────────────────────────────────────╯
$ nats ngs rtt --trace -a 2
...
RTT iterations for server: tls://34.138.109.81:4222
#1:	rtt=115.695996ms
#2:	rtt=112.314724ms

RTT iterations for server: tls://18.116.91.206:4222
#1:	rtt=105.897304ms
#2:	rtt=105.569548ms
...
╭────────────────────────────────────────────────────────────────────────────╮
│                                NGS Endpoints                               │
├──────────────────────────────┬─────────────────────────────────────────────┤
│ Endpoint                     │ RTT                                         │
├──────────────────────────────┼─────────────────────────────────────────────┤
│ tls://connect.ngs.global     │       tls://34.159.142.0:4222: 15.549328ms  │
│                              │       tls://34.107.15.96:4222: 15.863202ms  │
│                              │      tls://34.89.235.191:4222: 15.905139ms  │
│                              │                                             │
├──────────────────────────────┼─────────────────────────────────────────────┤
│ tls://aws.cloud.ngs.global   │       tls://34.254.41.96:4222: 37.367758ms  │
│                              │      tls://63.34.115.219:4222: 39.91022ms   │
│                              │      tls://34.249.55.202:4222: 38.286523ms  │
│                              │                                             │
├──────────────────────────────┼─────────────────────────────────────────────┤
....

@ripienaar
Copy link
Collaborator

Unfortunately no I don’t think we can add a NGS specific command in here. As a generic open source command we can’t really put a bunch of stuff specific to a commercial offering in here.

I like the use case here (though I would rather try to find clusters dynamically as there are no guarantees about what NGS cluster are up and how long)

We could though deliver it as a plugin.

@boris-ilijic
Copy link
Contributor Author

Yes, I understand the reason and expected something like that, therefore I didn't go into the details. So I am closing PR.

Motivation and my use case are simple (although maybe not so common): I'd like to measure latencies between clients, from different regions and between different regions, and using explicit Region Endpoint for that test is quite good approximation. Currently, I am doing that by specifying --server flag, pasting there specific region endpoint and calling RTT command after, but having all that URLs in one place and also table formatted output as the result is handy for me.
But again, not having anything commercial within the tool is enough good reason to not proceed with that approach in any case.

@boris-ilijic
Copy link
Contributor Author

boris-ilijic commented Nov 14, 2023

Related to your comments:

though I would rather try to find clusters dynamically

Did you mean to have some primitives within natscli to define cluster and supper-cluster configuration or you have something else in mind?

We could though deliver it as a plugin.

Wasn't aware of the plugin capability tbh, you meant this I guess: https://github.com/nats-io/natscli/blob/main/plugins/plugins.go
Do you have any example for the tool that is deployed as plugin and also its configuration ?

@ripienaar
Copy link
Collaborator

The plugin ability is a bit new and we are not sure yet how exactly we want to handle plugin installation hence it being hidden atm.

The short answer is:

write your CLI using https://github.com/choria-io/fisk. You develop like “ngs rtt” in /bin/ngs and then you do “nats plugin register ngs /bin/ngs” and that’s it.

Longer answer is we can support any language and framework but need to doc up the integration protocol still.

@ripienaar
Copy link
Collaborator

As an alternative you could build exactly what you wanted with just a YAML file and https://choria-io.github.io/appbuilder/

appbuilder apps can be plugged into nats cli in the same way

@boris-ilijic
Copy link
Contributor Author

Thx, I'll take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants