๐Scaling Instances
You can scale CDAP components (instances of flowlets, services, and workers) using:
- the Scaling methods of the Lifecycle HTTP RESTful API;
- 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 HTTP RESTful API.
๐Scaling Flowlets
You can query and set the number of instances executing a given flowlet
by using the instances
parameter with HTTP GET and PUT methods:
GET /v3/namespaces/<namespace-id>/apps/<app-id>/flows/<flow-id>/flowlets/<flowlet-id>/instances
PUT /v3/namespaces/<namespace-id>/apps/<app-id>/flows/<flow-id>/flowlets/<flowlet-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 being called |
flow-id |
Name of the flow |
flowlet-id |
Name of the flowlet |
quantity |
Number of instances to be used |
Examples
Retrieve the number of instances of the flowlet saver in the flow WhoFlow of the application HelloWorld in the namespace default:
GET /v3/namespaces/default/apps/HelloWorld/flows/WhoFlow/flowlets/saver/instances
Set the number of instances of the flowlet saver in the flow WhoFlow of the application HelloWorld in the namespace default:
PUT /v3/namespaces/default/apps/HelloWorld/flows/WhoFlow/flowlets/saver/instances
with the arguments as a JSON string in the body:
{ "instances" : 2 }
๐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: You can scale system services using the Monitor HTTP RESTful API 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:
PUT /v3/namespaces/default/apps/WordCount/services/RetrieveCounts/instances
with the arguments as a JSON string in the body:
{ "instances" : 2 }
Using
curl
and the Standalone CDAP:$ 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 HelloWorld in the namespace default:
GET /v3/namespaces/default/apps/HelloWorld/workers/DataWorker/instances