1. StreamNative Cloud
  2. Connect

Connect to cluster through pulsar-perf

The Pulsar Perf is a built-in performance test tool for Apache Pulsar. It can be used to test message writing or reading performance.

This document assumes that you have created a Pulsar cluster and a service account, and have granted the service account produce and consume permissions to the namespace for the target topic.

Prerequisites

  • Pulsar client 2.6.1 or higher version

Connect to cluster through OAuth2 authentication plugin

To connect a cluster through the OAuth2 authentication plugin, follow these steps.

  1. Get the service URL of your Pulsar cluster. For details, see get a service URL.

  2. Get the OAuth2 credential file of your service account. For details, see get an OAuth2 credential file.

  3. Connect to a Pulsar cluster through the OAuth2 authentication plugin.

    ./bin/pulsar-perf produce --service-url <broker_service_url> \
      --auth_plugin org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2 \
      --auth-params '{"privateKey":"file:///absolute path/to/key/file.json",
        "issuerUrl":"https://auth.streamnative.cloud",
        "audience":"your_audience"}' \
      -r 1000 -s 1024 test-topic
    
    • service-url: the broker URL of your Pulsar cluster.
    • privateKey: the path to your OAuth2 credential file. The privateKey parameter supports the following three pattern formats:
      • file:///path/to/file
      • file:/path/to/file
      • data:application/json;base64,<base64-encoded value>
    • issuerUrl: the URL of your OAuth2 authentication provider. You can get the value from your downloaded OAuth2 credential file.
    • audience: the audience parameter is the Uniform Resource Name (URN), which is a combination of the urn:sn:pulsar, the organization name, and the Pulsar instance name, in this format urn:sn:pulsar:<org_name>:<instance_name>.

Connect to cluster through Token authentication plugin

To connect a cluster through the Token authentication plugin, follow these steps.

  1. Get the service URL of your Pulsar cluster. For details, see get a service URL.

  2. Get the token of your service account. For details, see get a token.

  3. Connect to a Pulsar cluster through the Token authentication plugin.

    ./bin/pulsar-perf produce \
      --service-url SERVICE_URL \
      --auth_plugin org.apache.pulsar.client.impl.auth.AuthenticationToken \
      --auth-params token:AUTH_PARAMS \
      -r 1000 -s 1024 test-topic
    
    • service-url: the HTTP service URL of your Pulsar cluster.
    • auth-params: the token of your service account.

For details about how to use pulsar-perf to manage Pulsar components, see pulsar-perf examples.

Previous
CLI - pulsar-client