You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .readme-partials.yaml
+60-22
Original file line number
Diff line number
Diff line change
@@ -110,28 +110,33 @@ custom_content: |
110
110
-------
111
111
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.
112
112
113
-
#### Download Instructions
114
-
Instructions:
115
-
1. Clone the grpc-experimental branch from GitHub:
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:
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
+
```
135
140
136
141
#### How to Use
137
142
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: |
181
186
#### New Features
182
187
There are new gRPC specific features available to use in this update.
183
188
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`.
186
224
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.
Copy file name to clipboardExpand all lines: README.md
+60-22
Original file line number
Diff line number
Diff line change
@@ -208,28 +208,33 @@ gRPC Java Datastore Client User Guide
208
208
-------
209
209
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.
210
210
211
-
#### Download Instructions
212
-
Instructions:
213
-
1. Clone the grpc-experimental branch from GitHub:
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:
There are new gRPC specific features available to use in this update.
281
286
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`.
284
322
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.
0 commit comments