Stay organized with collections Save and categorize content based on your preferences.
gRPC is a high performance, open source universal RPC framework developed by Google that you can use to define your services using Protocol Buffers. You can use gRPC to interact with Cloud Storage. gRPC utilizes direct connectivity between Compute Engine instances and Cloud Storage buckets, bypassing Google Front Ends (GFEs).
Note: For analytics workloads on Google Cloud, gRPC improves Cloud Storage read performance only when the Compute Engine instance and the Cloud Storage bucket are in the same region.You can connect to Cloud Storage using gRPC through the following supported clients:
Apache Beam I/O connector on Dataflow for read and write requests.
Cloud Storage C++, Go, and Java client libraries. For instructions on enabling gRPC for these client libraries, see Enable gRPC on client library.
Cloud Storage FUSE. You can use Cloud Storage FUSE as a client by specifying grpc
in the client-protocol
field using a Cloud Storage FUSE configuration file or the --client-protocol
option using the gcsfuse CLI. To use gRPC with Cloud Storage FUSE, we recommend using Cloud Storage FUSE versions 2.10.0 or newer.
Ensure you have the following versions installed:
gRPC version 1.65.1 or later
C++ client library version v2.30.0 or later
C++ version 14 or later
For installation instructions, see Setting up a C++ development environment.
Ensure each Compute Engine instance has a service account attached to it, even if the service account has no permissions. This service account is used to represent the Compute Engine instance in the Application Layer Transport Security (ALTS) handshake process and is required for direct connectivity.
Create a gRPC client using gcs::MakeGrpcClient()
:
namespace gcs = google::cloud::storage;
void App() {
auto client = gcs::MakeGrpcClient();
// application code
}
The C++ client library automatically uses direct connectivity when it detects that the application is running on Google Cloud.
To configure the C++ client library to use gRPC, enable the Cloud Storage gRPC client to update your build system configuration for CMake or Bazel.
CMakeEnable the Cloud Storage gRPC client plugin at compile-time.
cmake -DGOOGLE_CLOUD_CPP_ENABLE=storage_grpc [other options here]
In your codebase, for the target_link_libraries()
command replace google-cloud-cpp::storage
with google-cloud-cpp::storage_grpc
For example, the quickstart program for gRPC uses the following code:
add_executable(quickstart_grpc quickstart_grpc.cc)
target_link_libraries(quickstart_grpc google-cloud-cpp::storage_grpc)
Replace the dependencies from @google_cloud_cpp//:storage
to @google_cloud_cpp//:storage_grpc
.
For example, the quickstart program for gRPC uses the following code:
cc_binary(
name = "quickstart",
srcs = [
"quickstart.cc",
],
deps = [
"@com_github_googleapis_google_cloud_cpp//:storage_grpc",
],
)
Ensure you have the following versions installed:
Java client libraries:
com.google.cloud:google-cloud-storage:2.43.1
or later.com.google.cloud:libraries-bom:26.48
or later.Java 8 or later
For installation instructions, see Setting up a Java development environment.
Ensure each Compute Engine instance has a service account attached to it, even if the service account has no permissions. This service account is used to represent the Compute Engine instance in the Application Layer Transport Security (ALTS) handshake process and is required for direct connectivity.
To make sure that your projects have compatible versions of Google Cloud client libraries, use the versions specified in the Google Cloud libraries Bill of Materials (BOM). To update your project to use the BOM, use any of the following methods:
Standalone Cloud StorageIf you are using the Cloud Storage client library independently (without other Google Cloud libraries), use the Cloud Storage client library-specific BOM.
MavenImport the BOM in the dependencyManagement
section of your pom.xml
file.
The following example shows how you would import the BOM and include the google-cloud-storage
artifact.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage-bom</artifactId>
<version>2.43.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
</dependency>
</dependencies>
Gradle
Add a platform dependency on com.google.cloud:google-cloud-storage-bom
:
implementation platform('com.google.cloud:google-cloud-storage-bom:2.43.1')
implementation 'com.google.cloud:google-cloud-storage'
Cloud Storage with other Google Cloud libraries
If you are using the Cloud Storage client library along with other Google Cloud libraries, use the Google Cloud client libraries BOM.
MavenImport the BOM in the dependencyManagement
section of your pom.xml
file.
The following example shows how to import the BOM and include the libraries-bom
artifact.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.48.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
</dependency>
</dependencies>
Gradle
Add a platform dependency on com.google.cloud:libraries-bom
:
implementation platform('com.google.cloud:libraries-bom:26.48.0')
implementation 'com.google.cloud:google-cloud-storage'
Create a gRPC client
The following sample uses a gRPC centric builder. The gRPC Java client automatically uses direct connectivity when it detects that the application is running on Google Cloud.
Go Before you beginEnsure you use Cloud Storage Go client library version 1.46.0 or later.
Ensure each Compute Engine instance has a service account attached to it, even if the service account has no permissions. This service account is used to represent the Compute Engine instance in the Application Layer Transport Security (ALTS) handshake process and is required for direct connectivity.
To use the client, you need to call the NewGRPCClient
constructor in your application instead of NewClient
.
The Go client library automatically uses direct connectivity when it detects that the application is running on Google Cloud.
For information about how to use a gRPC client, see gRPC API.
Configure VPC Service ControlsIf you are using Virtual Private Cloud with restricted virtual IP addresses (VPC Service Controls) to enhance the security of your network, you need to update your firewall rules to enable direct connectivity for optimal performance between your Compute Engine instance and Cloud Storage bucket.
To do so, add allowlist firewall rules to permit traffic on all ports for the following CIDR blocks:
34.126.0.0/18
2001:4860:8040::/42
In addition to the preceding rules, retain the existing allowlist rule for 199.36.153.4/30
.
If you have restrictions on firewall rule modifications and you cannot update them, then you can force the traffic to avoid direct connectivity by using storage.googleapis.com
as the Cloud Storage endpoint instead of google-c2p://storage.googleapis.com
.
For example, for C++ use, .set<google::cloud::EndpointOption>(storage.googleapis.com)
instead of google-c2p:///storage.googleapis.com
.
You can configure Cloud Storage client libraries to to generate gRPC related metrics in Cloud Monitoring. The gRPC related metrics can help you to do the following:
Monitor and optimize the performance of gRPC requests to Cloud Storage.
Troubleshoot and debug issues.
Gain insights into your application's usage and behavior.
For information about how to generate gRPC related metrics, see Use client-side metrics.
If gathering metrics isn't necessary for your use case, you can choose to opt-out of metrics collection. For instructions, see Opt-out of client-side metrics.
LimitationsIPv6 requests cannot be sent over legacy networks.
Direct connectivity is not supported when using the following GKE versions on IPv4-only clusters:
gRPC does not support the notifications
, hmacKeys
, and serviceAccount
methods.
HTTP-specific client constructor options, such as WithHTTPClient, are not supported for Go client library.
To learn how to check for direct connectivity and troubleshoot when it's not available, see Direct connectivity.
What's nextExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["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-08-07 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4