Skip to content

Commit b3fbfcc

Browse files
Docs: Update gapic upgrade installation instructions (#1677)
* Update user guide * chore: generate libraries at Wed Dec 4 18:25:42 UTC 2024 * Formatting code block * chore: generate libraries at Wed Dec 4 19:22:29 UTC 2024 * Remove client-side metrics suggestions --------- Co-authored-by: cloud-java-bot <[email protected]>
1 parent 8146530 commit b3fbfcc

File tree

2 files changed

+120
-44
lines changed

2 files changed

+120
-44
lines changed

.readme-partials.yaml

+60-22
Original file line numberDiff line numberDiff line change
@@ -110,28 +110,33 @@ custom_content: |
110110
-------
111111
In this feature launch, the [Java Datastore client](https://github.com/googleapis/java-datastore) now offers gRPC as a transport layer option with experimental support. Using [gRPC connection pooling](https://grpc.io/docs/guides/performance/) enables distributing RPCs over multiple connections which may improve performance.
112112
113-
#### Download Instructions
114-
Instructions:
115-
1. Clone the grpc-experimental branch from GitHub:
116-
```python
117-
git clone -b grpc-experimental https://github.com/googleapis/java-datastore.git
118-
```
119-
2. Run the following commands to build the library:
120-
```python
121-
# Go to the directory the code was downloaded to
122-
cd java-datastore/
123-
124-
# Build the library
125-
mvn clean install -DskipTests=true
126-
```
127-
3. Add the following dependency to your project:
128-
```xml
129-
<dependency>
113+
#### Installation Instructions
114+
The client can be built from the `grpc-experimental` branch on GitHub. For private preview, you can also download the artifact with the instructions provided below.
115+
116+
1. Download the datastore private preview package with dependencies:
117+
```
118+
curl -o <path-to-downloaded-jar> https://datastore-sdk-feature-release.web.app/google-cloud-datastore-2.20.0-grpc-experimental-1-SNAPSHOT-jar-with-dependencies.jar
119+
```
120+
2. Run the following commands to install JDK locally:
121+
```
122+
mvn install:install-file -Dfile=<path-to-downloaded-jar> -DgroupId=com.google.cloud -DartifactId=google-cloud-datastore -Dversion=2.20.0-grpc
123+
```
124+
3. Edit your pom.xml to add above package to `<dependencies/>` section:
125+
```xml
126+
<dependency>
130127
<groupId>com.google.cloud</groupId>
131128
<artifactId>google-cloud-datastore</artifactId>
132129
<version>2.20.0-grpc-experimental-1-SNAPSHOT</version>
133-
</dependency>
134-
```
130+
</dependency>
131+
```
132+
133+
And if you have not yet, add below to `<repositories/>` section:
134+
```xml
135+
<repository>
136+
<id>local-repo</id>
137+
<url>file://${user.home}/.m2/repository</url>
138+
</repository>
139+
```
135140
136141
#### How to Use
137142
To opt-in to the gRPC transport behavior, simply add the below line of code (`setTransportOptions`) to your Datastore client instantiation.
@@ -181,11 +186,44 @@ custom_content: |
181186
#### New Features
182187
There are new gRPC specific features available to use in this update.
183188
184-
##### Channel Pooling
185-
To customize the number of channels your client uses, you can update the channel provider in the DatastoreOptions.
189+
##### Connection Pool
190+
A connection pool, also known as a channel pool, is a cache of database connections that are shared and reused to improve connection latency and performance. With this update, now you will be able to configure the channel pool to improve application performance. This section guides you in determining the optimal connection pool size and configuring it within the Java datastore client.
191+
To customize the number of channels your client uses, you can update the channel provider in the DatastoreOptions.
192+
###### Determine the best connection pool size
193+
The default connection pool size is right for most applications, and in most cases there's no need to change it.
194+
195+
However sometimes you may want to change your connection pool size due to high throughput or buffered requests. Ideally, to leave room for traffic fluctuations, a connection pool has about twice the number of connections it takes for maximum saturation. Because a connection can handle a maximum of 100 concurrent requests, between 10 and 50 outstanding requests per connection is optimal. The limit of 100 concurrent streams per gRPC connection is enforced in Google's middleware layer, and you are not able to reconfigure this number.
196+
197+
The following steps help you calculate the optimal number of connections in your channel pool using estimate per-client QPS and average latency numbers.
198+
199+
To calculate the optimal connections, gather the following information:
200+
201+
1. The maximum number of queries per second (QPS) per client when your application is running a typical workload.
202+
2. The average latency (the response time for a single request) in ms.
203+
3. Determine the number of requests that you can send serially per second by dividing 1,000 by the average latency value.
204+
4. Divide the QPS in seconds by the number of serial requests per second.
205+
5. Divide the result by 50 requests per channel to determine the minimum optimal channel pool size. (If your calculation is less than 2, use at least 2 channels anyway, to ensure redundancy.)
206+
6. Divide the same result by 10 requests per channel to determine the maximum optimal channel pool size.
207+
208+
These steps are expressed in the following equations:
209+
```java
210+
(QPS ÷ (1,000 ÷ latency ms)) ÷ 50 streams = Minimum optimal number of connections
211+
(QPS ÷ (1,000 ÷ latency ms)) ÷ 10 streams = Maximum optimal number of connections
212+
```
213+
214+
###### Example
215+
Your application typically sends 50,000 requests per second, and the average latency is 10 ms. Divide 1,000 by 10 ms to determine that you can send 100 requests serially per second.
216+
Divide that number into 50,000 to get the parallelism needed to send 50,000 QPS: 500. Each channel can have at most 100 requests out concurrently, and your target channel utilization
217+
is between 10 and 50 concurrent streams. Therefore, to calculate the minimum, divide 500 by 50 to get 10. To find the maximum, divide 500 by 10 to get 50. This means that your channel
218+
pool size for this example should be between 10 and 50 connections.
219+
220+
It is also important to monitor your traffic after making changes and adjust the number of connections in your pool if necessary.
221+
222+
###### Set the pool size
223+
The following code sample demonstrates how to configure the channel pool in the client libraries using `DatastoreOptions`.
186224
See [ChannelPoolSettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.ChannelPoolSettings) and [Performance Best Practices](https://grpc.io/docs/guides/performance/) for more information on channel pools and best practices for performance.
187225
188-
Example:
226+
Code Example
189227
```java
190228
InstantiatingGrpcChannelProvider channelProvider =
191229
DatastoreSettings.defaultGrpcTransportProviderBuilder()

README.md

+60-22
Original file line numberDiff line numberDiff line change
@@ -208,28 +208,33 @@ gRPC Java Datastore Client User Guide
208208
-------
209209
In this feature launch, the [Java Datastore client](https://github.com/googleapis/java-datastore) now offers gRPC as a transport layer option with experimental support. Using [gRPC connection pooling](https://grpc.io/docs/guides/performance/) enables distributing RPCs over multiple connections which may improve performance.
210210

211-
#### Download Instructions
212-
Instructions:
213-
1. Clone the grpc-experimental branch from GitHub:
214-
```python
215-
git clone -b grpc-experimental https://github.com/googleapis/java-datastore.git
216-
```
217-
2. Run the following commands to build the library:
218-
```python
219-
# Go to the directory the code was downloaded to
220-
cd java-datastore/
221-
222-
# Build the library
223-
mvn clean install -DskipTests=true
224-
```
225-
3. Add the following dependency to your project:
226-
```xml
227-
<dependency>
211+
#### Installation Instructions
212+
The client can be built from the `grpc-experimental` branch on GitHub. For private preview, you can also download the artifact with the instructions provided below.
213+
214+
1. Download the datastore private preview package with dependencies:
215+
```
216+
curl -o <path-to-downloaded-jar> https://datastore-sdk-feature-release.web.app/google-cloud-datastore-2.20.0-grpc-experimental-1-SNAPSHOT-jar-with-dependencies.jar
217+
```
218+
2. Run the following commands to install JDK locally:
219+
```
220+
mvn install:install-file -Dfile=<path-to-downloaded-jar> -DgroupId=com.google.cloud -DartifactId=google-cloud-datastore -Dversion=2.20.0-grpc
221+
```
222+
3. Edit your pom.xml to add above package to `<dependencies/>` section:
223+
```xml
224+
<dependency>
228225
<groupId>com.google.cloud</groupId>
229226
<artifactId>google-cloud-datastore</artifactId>
230227
<version>2.20.0-grpc-experimental-1-SNAPSHOT</version>
231-
</dependency>
232-
```
228+
</dependency>
229+
```
230+
231+
And if you have not yet, add below to `<repositories/>` section:
232+
```xml
233+
<repository>
234+
<id>local-repo</id>
235+
<url>file://${user.home}/.m2/repository</url>
236+
</repository>
237+
```
233238

234239
#### How to Use
235240
To opt-in to the gRPC transport behavior, simply add the below line of code (`setTransportOptions`) to your Datastore client instantiation.
@@ -279,11 +284,44 @@ boolean isHTTP = datastore.getOptions().getTransportOptions() instanceof HTTPTra
279284
#### New Features
280285
There are new gRPC specific features available to use in this update.
281286

282-
##### Channel Pooling
283-
To customize the number of channels your client uses, you can update the channel provider in the DatastoreOptions.
287+
##### Connection Pool
288+
A connection pool, also known as a channel pool, is a cache of database connections that are shared and reused to improve connection latency and performance. With this update, now you will be able to configure the channel pool to improve application performance. This section guides you in determining the optimal connection pool size and configuring it within the Java datastore client.
289+
To customize the number of channels your client uses, you can update the channel provider in the DatastoreOptions.
290+
###### Determine the best connection pool size
291+
The default connection pool size is right for most applications, and in most cases there's no need to change it.
292+
293+
However sometimes you may want to change your connection pool size due to high throughput or buffered requests. Ideally, to leave room for traffic fluctuations, a connection pool has about twice the number of connections it takes for maximum saturation. Because a connection can handle a maximum of 100 concurrent requests, between 10 and 50 outstanding requests per connection is optimal. The limit of 100 concurrent streams per gRPC connection is enforced in Google's middleware layer, and you are not able to reconfigure this number.
294+
295+
The following steps help you calculate the optimal number of connections in your channel pool using estimate per-client QPS and average latency numbers.
296+
297+
To calculate the optimal connections, gather the following information:
298+
299+
1. The maximum number of queries per second (QPS) per client when your application is running a typical workload.
300+
2. The average latency (the response time for a single request) in ms.
301+
3. Determine the number of requests that you can send serially per second by dividing 1,000 by the average latency value.
302+
4. Divide the QPS in seconds by the number of serial requests per second.
303+
5. Divide the result by 50 requests per channel to determine the minimum optimal channel pool size. (If your calculation is less than 2, use at least 2 channels anyway, to ensure redundancy.)
304+
6. Divide the same result by 10 requests per channel to determine the maximum optimal channel pool size.
305+
306+
These steps are expressed in the following equations:
307+
```java
308+
(QPS ÷ (1,000 ÷ latency ms)) ÷ 50 streams = Minimum optimal number of connections
309+
(QPS ÷ (1,000 ÷ latency ms)) ÷ 10 streams = Maximum optimal number of connections
310+
```
311+
312+
###### Example
313+
Your application typically sends 50,000 requests per second, and the average latency is 10 ms. Divide 1,000 by 10 ms to determine that you can send 100 requests serially per second.
314+
Divide that number into 50,000 to get the parallelism needed to send 50,000 QPS: 500. Each channel can have at most 100 requests out concurrently, and your target channel utilization
315+
is between 10 and 50 concurrent streams. Therefore, to calculate the minimum, divide 500 by 50 to get 10. To find the maximum, divide 500 by 10 to get 50. This means that your channel
316+
pool size for this example should be between 10 and 50 connections.
317+
318+
It is also important to monitor your traffic after making changes and adjust the number of connections in your pool if necessary.
319+
320+
###### Set the pool size
321+
The following code sample demonstrates how to configure the channel pool in the client libraries using `DatastoreOptions`.
284322
See [ChannelPoolSettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.ChannelPoolSettings) and [Performance Best Practices](https://grpc.io/docs/guides/performance/) for more information on channel pools and best practices for performance.
285323

286-
Example:
324+
Code Example
287325
```java
288326
InstantiatingGrpcChannelProvider channelProvider =
289327
DatastoreSettings.defaultGrpcTransportProviderBuilder()

0 commit comments

Comments
 (0)