Scaling Instances

You can scale CDAP components (instances of services and workers) using:

  • the Scaling methods of the Lifecycle Microservices;

  • the Get/Set Commands of the Command Line Interface; or

  • the ProgramClient API of the Java Client API.

The examples given below use the Lifecycle Microservices.

Scaling Services

You can query or change the number of instances of a service by using the instances parameter with HTTP GET or PUT methods:

GET /v3/namespaces/<namespace-id>/apps/<app-id>/services/<service-id>/instances PUT /v3/namespaces/<namespace-id>/apps/<app-id>/services/<service-id>/instances

with the arguments as a JSON string in the body:

{ "instances" : <quantity> }

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

service-id

Name of the service

quantity

Number of instances to be used

Note: You can scale system services using the Monitor Microservices Scaling System Services.

Examples

  • Retrieve the number of instances of the service CatalogLookup in the application PurchaseHistory in the namespace default:

    GET /v3/namespaces/default/apps/PurchaseHistory/services/CatalogLookup/instances
  • Set the number of handler instances of the service RetrieveCounts of the application WordCount:

    with the arguments as a JSON string in the body:

  • Using curl and the CDAP Sandbox:

Scaling Workers

You can query or change the number of instances of a worker by using the instances parameter with HTTP GET or PUT methods:

with the arguments as a JSON string in the body:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

worker-id

Name of the worker

quantity

Number of instances to be used

Example

Retrieve the number of instances of the worker DataWorker in the application DemoApp in the namespace default:

 

Created in 2020 by Google Inc.