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

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

namespace-id

Namespace ID

app-id

Name of the application

service-id

Name of the service

quantity

Number of instances to be used

note

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

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

Examples

$ curl -w"\n" -X PUT "http://localhost:11015/v3/namespaces/default/apps/WordCount/services/RetrieveCounts/instances" \ -d '{ "instances" : 2 }'
> curl -X PUT "http://localhost:11015/v3/namespaces/default/apps/WordCount/services/RetrieveCounts/instances" ^ -d "{ \"instances\" : 2 }"

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:

GET /v3/namespaces/<namespace-id>/apps/<app-id>/workers/<worker-id>/instances
PUT /v3/namespaces/<namespace-id>/apps/<app-id>/workers/<worker-id>/instances

with the arguments as a JSON string in the body:

{ "instances" : <quantity> }

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:

GET /v3/namespaces/default/apps/DemoApp/workers/DataWorker/instances