The GCS C++ client library includes an optional plugin to access GCS via gRPC. When using GCS from Google Compute Engine (GCE) this plugin can enable higher total throughput across large workloads that run on hundreds or thousands of VMs.
Release Notes
There are some features that the gRPC plugin does not implement or implements differently from the REST-based implementation.
For best performance consider using Protobuf >= 23.2 and gRPC >= 1.55.0. Older versions of Protobuf requires enablingctype=CORD workaroundsat compile-time.
The cloud path endpoint (storage.googleapis.com) works from any hosting environment (on-prem, GKE, GCE, other cloud providers, etc.). For best performance on GCE or GKE we default to the direct connectivity endpointgoogle-c2p:///storage.googleapis.com.
TheFieldsrequest parameter is passed verbatim to the backend. Some fields have different names in gRPC, and the backend does not translate them. This is a rarely used feature, and we do not anticipate the behavior change is likely to cause problems. If it does cause any issues pleasefile a bug.
All thestorage::Client::*AccessControl()functions are emulated. For functions that change state, the emulation uses anOCC loop. While this preserves the semantics of a single RPC (e.g. no other concurrent changes are lost), it requires making at least two RPCs. This may increase the cost of calling these functions. Our telemetry shows these functions are not used via the C++ client library, but you should keep this in mind before deciding to use these functions in new code.
The functions to create, list, query, and delete HMAC keys and notifications are unavailable in gRPC. Our telemetry indicates that these functions are never used in C++, and therefore we do not anticipate this can cause problems.
Required code changes
To use GCS+gRPC plugin you need to make some changes to how your application initializes the GCS C++ client library. First, an additional header provides the initialization functions:
void GrpcReadWrite(std::string const& bucket_name) {
namespace gcs = ::google::cloud::storage;
auto constexpr kText = R"""(Hello World!)""";
auto client = gcs::MakeGrpcClient();
auto object = client.InsertObject(bucket_name, "lorem.txt", kText);
if (!object) throw std::move(object).status();
auto input = client.ReadObject(bucket_name, "lorem.txt",
gcs::Generation(object->generation()));
std::string const actual(std::istreambuf_iterator<char>{input}, {});
if (input.bad()) throw google::cloud::Status(input.status());
std::cout << "The contents read back are:\n"
<< actual
<< "\nThe received checksums are: " << input.received_hash()
<< "\nThe computed checksums are: " << input.computed_hash()
<< "\nThe original hashes are: crc32c=" << object->crc32c()
<< ",md5=" << object->md5_hash() << "\n";
}
Changing your build scripts
If you are using CMake to compile your application, then you need to change thetarget_link_libraries()command to usegoogle-cloud-cpp::storage_grpcinstead ofgoogle-cloud-cpp::storage. For example, our quickstart program for gRPC uses:
If you are using Bazel to compile your application, then you need to change the dependencies from@google_cloud_cpp//:storageto@google_cloud_cpp//:storage_grpc. For example, our `grpc/quickstart uses:
The gRPC client will default to enabling OpenTelemetry metrics. This means that the library must be built with support for OpenTelemetry and support for the gRPC OpenTelemetry plugin. Please note metrics require using a version of gRPC > 1.64.
If you are using CMake to compile your application:
Build and install OpenTelemetry with the following options:
```cpp
-DWITH_ABSEIL=ON
```
Build and install gRPC with the OpenTelemetry plugin enabled:
Build and and install gRPC with the following option:
-DgRPC_BUILD_GRPCPP_OTEL_PLUGIN=ON
If you are using Bazel and wish to disable gRPC metrics please build with the following option:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis document outlines the use of an optional gRPC plugin for the Google Cloud Storage (GCS) C++ client library, which can improve performance on Google Compute Engine (GCE) with large workloads.\u003c/p\u003e\n"],["\u003cp\u003eThe gRPC plugin has some differences from the REST-based implementation, including changes to endpoint overrides, field handling, and emulation of certain \u003ccode\u003estorage::Client::*AccessControl()\u003c/code\u003e functions, potentially increasing the number of RPCs needed.\u003c/p\u003e\n"],["\u003cp\u003eSpecific features such as creating, listing, querying, and deleting HMAC keys and notifications are unavailable when using the gRPC plugin, but telemetry suggests these are rarely used in C++.\u003c/p\u003e\n"],["\u003cp\u003eTo use the gRPC plugin, you must include additional headers and initialize the client with \u003ccode\u003egcs::MakeGrpcClient()\u003c/code\u003e, and also update the build process to link with \u003ccode\u003egoogle-cloud-cpp::storage_grpc\u003c/code\u003e in CMake or \u003ccode\u003e@google_cloud_cpp//:storage_grpc\u003c/code\u003e in Bazel.\u003c/p\u003e\n"],["\u003cp\u003eThe gRPC client defaults to enabling OpenTelemetry metrics, requiring the library to be built with support for OpenTelemetry and the gRPC OpenTelemetry plugin, and these metrics require gRPC version greater than 1.64.\u003c/p\u003e\n"]]],[],null,["Version 2.33.0keyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/storage/latest/storage-grpc)\n- [2.41.0](/cpp/docs/reference/storage/2.41.0/storage-grpc)\n- [2.40.0](/cpp/docs/reference/storage/2.40.0/storage-grpc)\n- [2.39.0](/cpp/docs/reference/storage/2.39.0/storage-grpc)\n- [2.38.0](/cpp/docs/reference/storage/2.38.0/storage-grpc)\n- [2.37.0](/cpp/docs/reference/storage/2.37.0/storage-grpc)\n- [2.36.0](/cpp/docs/reference/storage/2.36.0/storage-grpc)\n- [2.35.0](/cpp/docs/reference/storage/2.35.0/storage-grpc)\n- [2.34.0](/cpp/docs/reference/storage/2.34.0/storage-grpc)\n- [2.33.0](/cpp/docs/reference/storage/2.33.0/storage-grpc)\n- [2.32.0](/cpp/docs/reference/storage/2.32.0/storage-grpc)\n- [2.31.0](/cpp/docs/reference/storage/2.31.0/storage-grpc)\n- [2.30.0](/cpp/docs/reference/storage/2.30.0/storage-grpc)\n- [2.29.0](/cpp/docs/reference/storage/2.29.0/storage-grpc)\n- [2.28.0](/cpp/docs/reference/storage/2.28.0/storage-grpc)\n- [2.27.0](/cpp/docs/reference/storage/2.27.0/storage-grpc)\n- [2.26.0](/cpp/docs/reference/storage/2.26.0/storage-grpc)\n- [2.25.1](/cpp/docs/reference/storage/2.25.1/storage-grpc)\n- [2.24.0](/cpp/docs/reference/storage/2.24.0/storage-grpc)\n- [2.23.0](/cpp/docs/reference/storage/2.23.0/storage-grpc)\n- [2.22.1](/cpp/docs/reference/storage/2.22.1/storage-grpc)\n- [2.21.0](/cpp/docs/reference/storage/2.21.0/storage-grpc)\n- [2.20.0](/cpp/docs/reference/storage/2.20.0/storage-grpc)\n- [2.19.0](/cpp/docs/reference/storage/2.19.0/storage-grpc)\n- [2.18.0](/cpp/docs/reference/storage/2.18.0/storage-grpc)\n- [2.17.0](/cpp/docs/reference/storage/2.17.0/storage-grpc)\n- [2.16.0](/cpp/docs/reference/storage/2.16.0/storage-grpc)\n- [2.15.1](/cpp/docs/reference/storage/2.15.1/storage-grpc)\n- [2.14.0](/cpp/docs/reference/storage/2.14.0/storage-grpc)\n- [2.13.0](/cpp/docs/reference/storage/2.13.0/storage-grpc)\n- [2.12.0](/cpp/docs/reference/storage/2.12.0/storage-grpc)\n- [2.11.0](/cpp/docs/reference/storage/2.11.0/storage-grpc) \n\nUsing the GCS+gRPC Plugin\n=========================\n\nThe GCS C++ client library includes an optional plugin to access GCS via gRPC. When using GCS from Google Compute Engine (GCE) this plugin can enable higher total throughput across large workloads that run on hundreds or thousands of VMs.\n\n### Release Notes\n\nThere are some features that the gRPC plugin does not implement or implements differently from the REST-based implementation.\n\n1. For best performance consider using Protobuf \\\u003e= 23.2 and gRPC \\\u003e= 1.55.0. Older versions of Protobuf requires enabling [ctype=CORD workarounds](https://github.com/googleapis/google-cloud-cpp/blob/main/doc/ctype-cord-workarounds.md) at compile-time.\n2. To override the default endpoint you should use [`EndpointOption`](https://cloud.google.com/cpp/docs/reference/common/latest/structgoogle_1_1cloud_1_1EndpointOption.html) instead of [`RestEndpointOption`](/cpp/docs/reference/storage/2.33.0/structgoogle_1_1cloud_1_1storage_1_1RestEndpointOption).\n3. The cloud path endpoint (`storage.googleapis.com`) works from any hosting environment (on-prem, GKE, GCE, other cloud providers, etc.). For best performance on GCE or GKE we default to the direct connectivity endpoint `google-c2p:///storage.googleapis.com`.\n4. The [`Fields`](/cpp/docs/reference/storage/2.33.0/structgoogle_1_1cloud_1_1storage_1_1Fields) request parameter is passed verbatim to the backend. Some fields have different names in gRPC, and the backend does not translate them. This is a rarely used feature, and we do not anticipate the behavior change is likely to cause problems. If it does cause any issues please [file a bug](https://github.com/googleapis/google-cloud-cpp/issues/new/choose).\n5. All the `storage::Client::*AccessControl()` functions are emulated. For functions that change state, the emulation uses an [OCC loop](https://en.wikipedia.org/wiki/Optimistic_concurrency_control). While this preserves the semantics of a single RPC (e.g. no other concurrent changes are lost), it requires making at least two RPCs. This may increase the cost of calling these functions. Our telemetry shows these functions are not used via the C++ client library, but you should keep this in mind before deciding to use these functions in new code.\n6. The functions to create, list, query, and delete HMAC keys and notifications are unavailable in gRPC. Our telemetry indicates that these functions are never used in C++, and therefore we do not anticipate this can cause problems.\n\n### Required code changes\n\nTo use GCS+gRPC plugin you need to make some changes to how your application initializes the GCS C++ client library. First, an additional header provides the initialization functions: \n\n #include \"google/cloud/storage/grpc_plugin.h\"\n #include \"google/cloud/storage/options.h\"\n #include \"google/cloud/common_options.h\"\n #include \"google/cloud/options.h\"\n\nThen you initialize a [`google::cloud::storage::Client`](/cpp/docs/reference/storage/2.33.0/classgoogle_1_1cloud_1_1storage_1_1Client) using a new function: \n\n auto client = gcs::MakeGrpcClient();\n\nThe [`google::cloud::storage::Client`](/cpp/docs/reference/storage/2.33.0/classgoogle_1_1cloud_1_1storage_1_1Client) object returned by this function can be used as before: \n\n void GrpcReadWrite(std::string const& bucket_name) {\n namespace gcs = ::google::cloud::storage;\n auto constexpr kText = R\"\"\"(Hello World!)\"\"\";\n\n auto client = gcs::MakeGrpcClient();\n\n auto object = client.InsertObject(bucket_name, \"lorem.txt\", kText);\n if (!object) throw std::move(object).status();\n\n auto input = client.ReadObject(bucket_name, \"lorem.txt\",\n gcs::Generation(object-\u003egeneration()));\n std::string const actual(std::istreambuf_iterator\u003cchar\u003e{input}, {});\n if (input.bad()) throw google::cloud::Status(input.status());\n std::cout \u003c\u003c \"The contents read back are:\\n\"\n \u003c\u003c actual\n \u003c\u003c \"\\nThe received checksums are: \" \u003c\u003c input.received_hash()\n \u003c\u003c \"\\nThe computed checksums are: \" \u003c\u003c input.computed_hash()\n \u003c\u003c \"\\nThe original hashes are: crc32c=\" \u003c\u003c object-\u003ecrc32c()\n \u003c\u003c \",md5=\" \u003c\u003c object-\u003emd5_hash() \u003c\u003c \"\\n\";\n }\n\n### Changing your build scripts\n\nIf you are using CMake to compile your application, then you need to change the `target_link_libraries()` command to use `google-cloud-cpp::storage_grpc` instead of `google-cloud-cpp::storage`. For example, our quickstart program for gRPC uses: \n\n add_executable(quickstart_grpc quickstart_grpc.cc)\n target_link_libraries(quickstart_grpc google-cloud-cpp::storage_grpc)\n\nIf you are using Bazel to compile your application, then you need to change the dependencies from `@google_cloud_cpp//:storage` to `@google_cloud_cpp//:storage_grpc`. For example, our \\`grpc/quickstart uses: \n\n cc_binary(\n name = \"quickstart_grpc\",\n srcs = [\n \"quickstart_grpc.cc\",\n ],\n deps = [\n \"@google_cloud_cpp//:storage_grpc\",\n ],\n )\n\n### gRPC+OpenTelemetry\n\nThe gRPC client will default to enabling OpenTelemetry metrics. This means that the library must be built with support for OpenTelemetry and support for the gRPC OpenTelemetry plugin. Please note metrics require using a version of gRPC \\\u003e 1.64.\n\nIf you are using CMake to compile your application:\n\n1. Build and install OpenTelemetry with the following options:\n\n2. \\`\\`\\`cpp\n\n3. -DWITH_ABSEIL=ON\n4. \\`\\`\\`\n5. Build and install gRPC with the OpenTelemetry plugin enabled:\n\nBuild and and install gRPC with the following option: \n\n -DgRPC_BUILD_GRPCPP_OTEL_PLUGIN=ON\n\nIf you are using Bazel and wish to disable gRPC metrics please build with the following option: \n\n --//google/cloud/storage:enable_grpc_metrics=false"]]