IBM Cloud Docs
容量

容量

IBM Cloudant 使您能够: 查看当前和目标供应的吞吐量容量设置,设置目标供应的吞吐量容量设置,以及查看当前使用的供应的吞吐量容量。

有关更多信息,请参阅 供应的吞吐量容量,以了解 IBM Cloudant 如何分配和使用容量以及如何在 UI 中查看和更改容量。

容量 API 需要 IBM Cloudant 旧认证管理员角色或 IAM 管理员角色才能访问 API 端点。 以下 curl 示例省略了认证方面以实现简单性。 请参阅 认证概述 部分,以获取有关使用这两种认证类型的更多详细信息。

查看当前和目标供应的吞吐量容量设置

/_api/v2/user/capacity/throughput 端点使用 GET 以查看分配给 IBM Cloudant 实例的供应吞吐量容量以及目标供应吞吐量容量。 更改目标容量时,将异步更改当前容量以满足目标容量。 容量更改的大小以及存储在 IBM Cloudant 实例中的数据量确定当前和目标容量匹配之前所花费的时间。 当当前容量和目标容量相同时,将完成容量更改。

方法
GET
路径
/_api/v2/user/capacity/throughput
响应
当前和目标容量设置。 每个都包括容量块数和总读取数/秒,写入数/秒以及吞吐量容量的全局查询数/秒。

请参见以下示例请求,了解如何使用 HTTP 获取当前和目标容量:

GET /_api/v2/user/capacity/throughput

请参阅以下示例请求以检索当前容量和目标容量:

curl "$SERVICE_URL/_api/v2/user/capacity/throughput"
import com.ibm.cloud.cloudant.v1.Cloudant;
import com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformation;

Cloudant service = Cloudant.newInstance();

CapacityThroughputInformation response =
service.getCapacityThroughputInformation().execute().getResult();

System.out.println(response);
const { CloudantV1 } = require('@ibm-cloud/cloudant');

const service = CloudantV1.newInstance({});

service.getCapacityThroughputInformation().then(response => {
  console.log(response.result);
});
from ibmcloudant.cloudant_v1 import CloudantV1

service = CloudantV1.new_instance()

response = service.get_capacity_throughput_information().get_result()

print(response)
getCapacityThroughputInformationOptions := service.NewGetCapacityThroughputInformationOptions()

capacityThroughputInformation, response, err := service.GetCapacityThroughputInformation(getCapacityThroughputInformationOptions)
if err != nil {
panic(err)
}

b, _ := json.MarshalIndent(capacityThroughputInformation, "", "  ")
fmt.Println(string(b))

先前的 Go 示例需要以下导入块:

import (
   "encoding/json"
   "fmt"
   "github.com/IBM/cloudant-go-sdk/cloudantv1"
)

所有 Go 示例都需要初始化 service 对象。 有关更多信息,请参阅 API 文档的 认证部分 以获取示例。

返回的结构包含以下字段:

current
详细说明已分配的当前容量,并显示容量块数和吞吐量请求类的细目。
target
详细说明已分配的目标容量,并显示容量块数和吞吐量请求类的细目。
blocks
供应的吞吐量容量块数,其中块为 100 次读取/秒,50 次写入/秒和 5 次全局查询/秒。
throughput
特定读取数/秒,写入数/秒和全局查询数/秒的细目。

请参阅具有当前容量和目标容量的以下示例 JSON 响应:

{
  "current": {
    "throughput": {
      "read": 500,
      "write": 250,
      "blocks": 5,
      "query": 25
    }
  },
  "target": {
    "throughput": {
      "read": 1000,
      "write": 500,
      "blocks": 10,
      "query": 50
    }
  }
}

设置目标供应的吞吐量容量设置

/_api/v2/user/capacity/throughput 端点使用 PUT 来设置 IBM Cloudant 实例的目标供应吞吐量容量。 更改目标容量时,将异步更改当前容量以满足目标容量。

方法
PUT
路径
/_api/v2/user/capacity/throughput
响应
当前和目标容量设置,包括容量块数和总读取数/秒,写入数/秒和全局查询数/秒。

请参见以下示例请求,了解如何使用 HTTP 设置目标容量:

PUT $SERVICE_URL/_api/v2/user/capacity/throughput
Content-Type: application/json

请参阅以下示例 JSON 对象以设置目标容量:

{
  "blocks": $NUMBER_OF_BLOCKS
}

其中,块由 100 次读取/秒,50 次写入/秒和 5 次全局查询/秒的供应吞吐量容量组成。 $NUMBER_OF_BLOCKS 字段必须为1到100之间的整数。 可以通过联系 IBM Cloudant 支持来获取更大的容量大小。

请参阅以下示例请求以设置目标容量:

curl -X PUT "$SERVICE_URL/_api/v2/user/capacity/throughput" -H "Content-Type: application/json" --data '{"blocks": 1}'
import com.ibm.cloud.cloudant.v1.Cloudant;
import com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformation;
import com.ibm.cloud.cloudant.v1.model.PutCapacityThroughputConfigurationOptions;

Cloudant service = Cloudant.newInstance();

PutCapacityThroughputConfigurationOptions options =
    new PutCapacityThroughputConfigurationOptions.Builder()
        .blocks(1)
        .build();

CapacityThroughputInformation response =
service.putCapacityThroughputConfiguration(options).execute().getResult();

System.out.println(response);
const { CloudantV1 } = require('@ibm-cloud/cloudant');

const service = CloudantV1.newInstance({});

service.putCapacityThroughputConfiguration({
  blocks: 1,
}).then(response => {
  console.log(response.result);
});
from ibmcloudant.cloudant_v1 import CloudantV1

service = CloudantV1.new_instance()

response = service.put_capacity_throughput_configuration(
  blocks=1
).get_result()

print(response)
putCapacityThroughputConfigurationOptions := service.NewPutCapacityThroughputConfigurationOptions(
  1,
)

capacityThroughputConfiguration, response, err := service.PutCapacityThroughputConfiguration(putCapacityThroughputConfigurationOptions)
if err != nil {
  panic(err)
}

b, _ := json.MarshalIndent(capacityThroughputConfiguration, "", "  ")
fmt.Println(string(b))

先前的 Go 示例需要以下导入块:

import (
   "encoding/json"
   "fmt"
   "github.com/IBM/cloudant-go-sdk/cloudantv1"
)

返回的结构包含以下字段:

current
详细说明当前分配的容量,并显示容量块数和吞吐量请求类的细目。
target
详细说明目标容量集,并显示容量块数和吞吐量请求类的细目。
blocks
供应的吞吐量容量块数,其中块为 100 次读取/秒,50 次写入/秒和 5 次全局查询/秒。
throughput
特定读取数/秒,写入数/秒和全局查询数/秒的细目。

请参阅具有目标容量集的以下示例 JSON 响应:

{
  "current": {
    "throughput": {
      "read": 500,
      "write": 250,
      "blocks": 5,
      "query": 25
    }
  },
  "target": {
    "throughput": {
      "read": 1000,
      "write": 500,
      "blocks": 10,
      "query": 50
    }
  }
}

查看当前使用的供应吞吐量容量

/_api/v2/user/current/throughput 端点使用 GET 方法可查看 IBM Cloudant 实例的供应吞吐量容量的当前耗用情况。 当前使用量显示在给定秒内对实例执行的读,写和全局查询的数量。 当您使用此终端节点时,最佳实践是持续汇总这些数据,以便更全面地了解 IBM Cloudant吞吐量消耗模式。

方法
GET
路径
/_api/v2/user/current/throughput
响应
已使用的供应吞吐量容量的当前消耗,按读取数,写入数和全局查询数进行细分。

请参见以下示例请求,了解如何使用 HTTP 获取当前容量消耗:

GET $SERVICE_URL/_api/v2/user/current/throughput

请参阅以下示例请求以检索当前的容量消耗:

curl "$SERVICE_URL/_api/v2/user/current/throughput"
import com.ibm.cloud.cloudant.v1.Cloudant;
import com.ibm.cloud.cloudant.v1.model.CurrentThroughputInformation;

Cloudant service = Cloudant.newInstance();

CurrentThroughputInformation response =
service.getCurrentThroughputInformation().execute().getResult();

System.out.println(response);
const { CloudantV1 } = require('@ibm-cloud/cloudant');

const service = CloudantV1.newInstance({});

service.getCurrentThroughputInformation().then(response => {
  console.log(response.result);
});
from ibmcloudant.cloudant_v1 import CloudantV1

service = CloudantV1.new_instance()

response = service.get_current_throughput_information().get_result()

print(response)
getCurrentThroughputInformationOptions := service.NewGetCurrentThroughputInformationOptions()

currentThroughputInformation, response, err := service.GetCurrentThroughputInformation(getCurrentThroughputInformationOptions)
if err != nil {
  panic(err)
}

b, _ := json.MarshalIndent(currentThroughputInformation, "", "  ")
fmt.Println(string(b))

先前的 Go 示例需要以下导入块:

import (
   "encoding/json"
   "fmt"
   "github.com/IBM/cloudant-go-sdk/cloudantv1"
)

返回的结构包含以下字段:

  • throughput-当前使用的读,写和全局查询数的细目。

请参阅当前容量消耗的以下示例 JSON 响应:

{
  "throughput": {
    "read": 133,
    "write": 42,
    "query": 13
  }
}