kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 4236dea1319856d87dbf31641a7c82d2d5e874a4071941204ee9aee85a154c09 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2015-07-15 15:42 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-07-15 16:22 +02:00 |
| Parents | 047e599c35f7 |
1 file changed
modified features/pooling/README.md +34 −1
| @@ -7,7 +7,7 @@ | ||
| 7 | 7 | connection to handle multiple simultaneous requests: |
| 8 | 8 | |
| 9 | 9 | * when a query gets executed, a *stream id* gets assigned to it. It is a |
| 10 | - unique identifier for the current connection; | |
| 10 | + unique identifier on the current connection; | |
| 11 | 11 | * the driver writes a request containing the stream id and the query on |
| 12 | 12 | the connection, and then proceeds without waiting for the response (if |
| 13 | 13 | you're using the asynchronous API, this is when the driver will send you |
| @@ -244,6 +244,39 @@ | ||
| 244 | 244 | your pools are underused and you could get away with less core |
| 245 | 245 | connections. |
| 246 | 246 | |
| 247 | +#### Tuning protocol v3 for very high throughputs | |
| 248 | + | |
| 249 | +As mentioned above, the default pool size for protocol v3 is core = max | |
| 250 | += 1. This means all requests to a given node will share a single | |
| 251 | +connection, and therefore a single Netty I/O thread. | |
| 252 | + | |
| 253 | +There is a corner case where this I/O thread can max out its CPU core | |
| 254 | +and become a bottleneck in the driver; in our benchmarks, this happened | |
| 255 | +with a single-node cluster and a high throughput (approximately 80K | |
| 256 | +requests / second). | |
| 257 | + | |
| 258 | +It's unlikely that you'll run into this issue: in most real-world | |
| 259 | +deployments, the driver connects to more than one node, so the load will | |
| 260 | +spread across more I/O threads. However if you suspect that you | |
| 261 | +experience the issue, here's what to look out for: | |
| 262 | + | |
| 263 | +* the driver throughput plateaus but the process does not appear to | |
| 264 | + max out any system resource (in particular, overall CPU usage is well | |
| 265 | + below 100%); | |
| 266 | +* one of the driver's I/O threads maxes out its CPU core. You can see | |
| 267 | + that with a profiler, or OS-level tools like `pidstat -tu` on Linux. | |
| 268 | + I/O threads are called `<cluster_name>-nio-worker-<n>`, unless you're | |
| 269 | + injecting your own `EventLoopGroup` with `NettyOptions`. | |
| 270 | + | |
| 271 | +The solution is to add more connections per node. To ensure that | |
| 272 | +additional connections get created before you run into the bottleneck, | |
| 273 | +either: | |
| 274 | + | |
| 275 | +* set core = max; | |
| 276 | +* keep core = 1, but adjust [maxRequestsPerConnection][mrpc] and | |
| 277 | + [newConnectionThreshold][nct] so that enough connections are added by | |
| 278 | + the time you reach the bottleneck. | |
| 279 | + | |
| 247 | 280 | [result_set_future]:http://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/core/ResultSetFuture.html |
| 248 | 281 | [pooling_options]:http://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/core/PoolingOptions.html |
| 249 | 282 | [lbp]:http://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/core/policies/LoadBalancingPolicy.html |