Elffuss BraidHub

kikocis/java-driver public

Document edge case for protocol v3 pool tuning.
Changeset4236dea1319856d87dbf31641a7c82d2d5e874a4071941204ee9aee85a154c09
Authorolim7t <omichallat+github@gmail.com> · 2015-07-15 15:42 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2015-07-15 16:22 +02:00
Parents047e599c35f7

Browse the files at this changeset

1 file changed

modified features/pooling/README.md +34 −1
@@ -7,7 +7,7 @@
77 connection to handle multiple simultaneous requests:
88
99 * 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;
1111 * the driver writes a request containing the stream id and the query on
1212 the connection, and then proceeds without waiting for the response (if
1313 you're using the asynchronous API, this is when the driver will send you
@@ -244,6 +244,39 @@
244244 your pools are underused and you could get away with less core
245245 connections.
246246
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+
247280 [result_set_future]:http://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/core/ResultSetFuture.html
248281 [pooling_options]:http://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/core/PoolingOptions.html
249282 [lbp]:http://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/core/policies/LoadBalancingPolicy.html