-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Description
Hi everyone. I’d like to clarify one nuance related to scaling and comparing single and cluster in ShardingSphere. I think it would be great to get an answer from @terrymanu when he has time.
There is a single node that performs inserts, for example, using 6 parallel operations. Then I scale the system via ShardingSphere to 2 nodes and effectively get two single nodes. The question is: how will these threads (connections) behave in this case? Will the Proxy distribute these 6 threads across the nodes (roughly 3 per node), or will each node effectively have 6 threads (or 6 connections)?
If the threads are “split,” then it’s not entirely clear to me where a performance gain close to ×2 should come from. It’s clear that sharding usually provides benefits by parallelizing INSERT and other operations across different nodes, reducing contention on CPU, locks, and I/O, etc. In this case, the load on each node becomes lower, but inserts are still executed with a total of 6 threads. Then it’s not entirely clear what exactly provides ×2 system capacity if the overall level of parallelism remains the same.
In sysbench tests that I’ve seen, the configuration on each node explicitly set the connection pool sizes: HikariPool.minimumPoolSize = 200 and HikariPool.maximumPoolSize = 200, after which sysbench was run with the --threads=200 parameter. Am I correct in understanding that with 200 threads this means that for single there are 200 connections to one database, and for cluster with two nodes there are 200 connections per node, i.e. 400 connections in total?
In my tests, acceptable QPS values were obtained only when I explicitly set HikariPool = 200 for both single and cluster with --threads=200. In this scenario, single had 200 connections to one database, while cluster had 200 connections per node. At the same time, without explicitly setting the HikariPool sizes, single was always faster, even in cases where single was already starting to hit resource limits (CPU, I/O, etc.).
The main question is: how should single and cluster be compared correctly from a scalability perspective? Is it correct to assume that when scaling we are effectively “adding one more node,” and then the comparison should look like this: single — one node with --threads = 200 and HikariPool = 200 (200 connections), and cluster — N nodes with the same --threads = 200 and HikariPool = 200 on each node, resulting in 200 × N connections in total? If this logic is incorrect, what approach is considered correct in ShardingSphere for a fair comparison: fixing the same number of client threads, the same total number of connections for the whole setup, or the same connection limits per node?