shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

Proxy performance confirmation

Open makssent opened this issue 1 year ago • 23 comments

Hi everyone! 👋

We recently started testing the performance of ShardingSphere-Proxy. We used a profiler and analyzed the results with a flamegraph, but haven’t seen any performance improvements — on the contrary, there’s some regression compared to JDBC. I don’t want to dive into testing advice for now — like “don’t use full routing,” etc. I’m more interested in something else:

👉Could you please share any articles or sources that demonstrate performance improvements with Proxy? Maybe there are materials with visual graphs or metrics showing that Proxy actually performs better (or at least on par) compared to direct database access? Or perhaps you can tell me — does Proxy currently provide any performance benefits in specific scenarios? I’ve often seen mentions that Proxy is slower than JDBC, but I haven’t found any articles that clearly show it outperforming direct database access in real benchmarks.

Thanks! 🙏

makssent avatar Oct 30 '25 08:10 makssent

ShardingSphere-Proxy does indeed perform worse than ShardingSphere-JDBC, and ShardingSphere-JDBC will also be slower than a direct database connected (since it adds some new features). Based on past experience, ShardingSphere-Proxy can be over 30% slower than ShardingSphere-JDBC. We can explore ways to improve performance. If necessary, you may provide flame graphs to analyze where the performance bottlenecks are together.

terrymanu avatar Oct 30 '25 11:10 terrymanu

ShardingSphere-Proxy does indeed perform worse than ShardingSphere-JDBC, and ShardingSphere-JDBC will also be slower than a direct database connected (since it adds some new features). Based on past experience, ShardingSphere-Proxy can be over 30% slower than ShardingSphere-JDBC. We can explore ways to improve performance. If necessary, you may provide flame graphs to analyze where the performance bottlenecks are together.

I understand and accept that. It’s logical that with a single shard, there’s an additional routing layer introduced by ShardingSphere, and in that case, Proxy will naturally perform slower than a direct database connection.

However, as I understand it, this overhead should be compensated when the number of shards increases — for example, with 2, 4, 6, or 8 shards, where the load is distributed and the overall effect should balance out the routing costs. But according to our tests, we don’t see that happening: performance does increase, but not proportionally to the loss introduced by Proxy. With JDBC, on the other hand, everything works as expected — performance scales up and the improvement is noticeable.

That’s why I wanted to ask — are there any articles, posts, or public results where someone has tested ShardingSphere-Proxy and achieved performance gains? Perhaps you or the community have conducted such experiments — I just haven’t come across any examples showing Proxy providing an actual performance improvement, only comparisons indicating that Proxy is slower than JDBC.

Right now, we’re deciding whether to continue investing in improving Proxy or to focus on adapting the JDBC variant for our needs. Of course, we understand that performance depends on many factors — database size, number of shards, hardware configuration, and so on — but it would really help to see a real-world example where Proxy shows a performance improvement as the number of shards increases, compared to a regular database connection without ShardingSphere. That way, we could reproduce such an experiment, verify the results, and make further decisions based on that.

makssent avatar Oct 30 '25 11:10 makssent

I understand that I could provide you with a flamegraph or other performance metrics, but I think it’s not very useful at this stage — we could keep optimizing endlessly without a clear goal. What I’d really like to see right now is whether there’s any existing example where Proxy showed a performance improvement on PostgreSQL or MySQL. If such a case exists, it would confirm that achieving better performance is possible, and we could try to reproduce that experiment or at least use it as a reference point to guide further optimization.

At this point, I’m mostly trying to find a real example where someone actually achieved a performance improvement with Proxy.

P.S. The choice of database shouldn’t matter much here — so far, we haven’t seen any proven performance improvements with Proxy on any database.

makssent avatar Oct 30 '25 11:10 makssent

These are the test results from my current company (SphereEx). You can consider SphereEx-DBPlusEngine in the diagram as equivalent to ShardingSphere. When the data volume is sufficiently large and the number of shards is adequate, both JDBC and Proxy show significant performance improvements. However, the improvement with JDBC is significantly more pronounced compared to Proxy.

Image

terrymanu avatar Oct 31 '25 01:10 terrymanu

Here is also a research paper (Apache ShardingSphere: A Holistic and Pluggable Platform for Data Sharding) that includes the results of performance testing.

terrymanu avatar Oct 31 '25 01:10 terrymanu

Thanks for sharing your benchmarks and examples. Did you use the standard MySQL Proxy from ShardingSphere without any custom modifications?

makssent avatar Oct 31 '25 07:10 makssent

Yes.

terrymanu avatar Nov 02 '25 02:11 terrymanu

Hi, @terrymanu I ran your test, but I was not able to reproduce the throughput gain shown in your example (×4.5) for OLTP Point Select. In my environment the cluster is indeed faster than the single node, but the speedup is at most around ~2x. I’m probably missing some important factor or misinterpreting the results — I’d really appreciate any hints on what else to look at or adjust.

Environment

  • NODE 1–5: 4 CPU, 8 GB RAM, SSD 65
  • Client: 4 CPU, 8 GB RAM, SSD 65
  • Proxy: 12 CPU, 8 GB RAM, SSD 65
  • Single node: 4 CPU, 8 GB RAM, SSD 65

Data volume

  • Single: 40M rows
  • Cluster: 8M rows per node (5 nodes, total 40M rows, just distributed)

2 GB is allocated for the InnoDB buffer pool. I checked that the buffer is empty → filled the table up to 8M rows → ran a warmup:

SELECT id FROM t_order_0 FORCE INDEX (PRIMARY) ORDER BY id LIMIT 1000000000;
...
SELECT id FROM t_order_9 FORCE INDEX (PRIMARY) ORDER BY id LIMIT 1000000000;

After that I ran a couple of test OLTP Point SELECT runs to stabilize the buffer — the buffer filled up and did not grow anymore, the page count did not change, everything was working from memory.

In theory, the speedup should come from the fact that the cluster works entirely from the buffer, while the single node constantly goes to disk, which is slower. In practice, the cluster indeed does not perform any disk reads, and the single node performs millions of disk reads, but the improvement turned out to be much smaller than expected.

The proxy also does not look like a bottleneck — its CPU utilization does not exceed 95%.

Single and Cluster were tested with the same Java benchmark (OLTP Point SELECT), only in one case the requests go directly to Single, and in the second — through Proxy to the cluster. So the “Java factor” and the client side are identical. Below are the results of all runs.

CLUSTER — runs

5 runs × 30 seconds (Cluster)

Threads QPS #1 QPS #2 QPS #3 QPS #4 QPS #5 QPS avg avg disk_reads pages_used
120 12557 8967 11823 10555 8659 10512 10.77 ms 122171 → 122171 122603 → 122603
160 12677 12116 14930 14930 11067 13144 12.18 ms 122171 → 122171 122603 → 122603
180 12318 13254 11200 17240 12288 13260 13.82 ms 122171 → 122171 122603 → 122603
200 14058 14721 13771 14044 11372 13593 14.78 ms 122171 → 122171 122603 → 122603

(further pages_used and disk_reads stay unchanged: pages_used shows InnoDB buffer pool usage and remains non-full, and disk_reads stays at zero — the cluster continues to serve all reads from buffer)

5 runs × 60 seconds (Cluster)

Threads QPS #1 QPS #2 QPS #3 QPS #4 QPS #5 QPS avg avg
120 16743 19928 21718 22012 20496 20179 5.99 ms
160 18968 22258 22408 20870 22067 21314 7.30 ms
180 18945 20349 20888 21413 22268 20773 8.38 ms
200 19581 20689 22349 22426 22810 21571 8.88 ms

5 runs × 120 seconds (Cluster)

Threads QPS #1 QPS #2 QPS #3 QPS #4 QPS #5 QPS avg avg
120 18910 14995 15874 12802 13599 15236 8.47 ms
160 17773 17849 16568 14175 14924 16258 11.71 ms
180 16472 18713 16073 12534 15560 15870 13.53 ms
200 16226 16706 14546 13671 16393 15508 14.72 ms

SINGLE — runs

5 runs × 30 seconds (Single)

Threads QPS #1 QPS #2 QPS #3 QPS #4 QPS #5 QPS avg avg disk_reads (total) disk_reads_avg pages_used
120 9416 9721 9525 9525 9441 9526 11.87 ms 1 144 157 228 831 131056 / 131072
160 9809 10412 9805 9788 9842 9951 16.09 ms 1 192 311 238 462 131056 / 131072
180 9755 10212 9748 9400 9510 9725 18.56 ms 1 167 719 233 544 131056 / 131072
200 10239 9942 10044 9719 9780 9925 20.24 ms 1 194 994 238 999 131056 / 131072

(from here on, pages_used is always 131056/131072 — the buffer is fully filled; further focus is on disk_reads)

5 runs × 60 seconds (Single)

Threads QPS #1 QPS #2 QPS #3 QPS #4 QPS #5 QPS avg avg disk_reads (total) disk_reads_avg
120 9651 9828 9775 9896 9835 9797 11.91 ms 2 352 894 470 579
160 9794 9799 9783 9888 9647 9782 16.33 ms 2 348 209 469 642
180 9900 9707 9921 9740 9903 9834 18.38 ms 2 360 695 472 139
200 9746 9971 9914 9717 9794 9828 20.53 ms 2 360 267 472 053

5 runs × 120 seconds (Single)

Threads QPS #1 QPS #2 QPS #3 QPS #4 QPS #5 QPS avg avg disk_reads (total) disk_reads_avg
120 9888 8282 8833 10478 10135 9523 13.35 ms 4 072 067 814 413
160 9961 8372 8552 11245 9814 9589 17.47 ms 4 180 584 836 116
180 9901 8443 8931 12069 9435 9756 19.58 ms 4 319 040 863 808
200 9851 8215 8357 12035 5988 8889 24.88 ms 3 971 902 794 380

CLUSTER vs SINGLE — comparison

5 runs × 30 seconds

Threads QPS Cluster QPS Single avg Cluster avg Single disk_reads Cluster disk_reads Single QPS gain (%)
120 10512 9526 10.77 ms 11.87 ms 0 1 144 157 +10.3%
160 13144 9951 12.18 ms 16.09 ms 0 1 192 311 +32.1%
180 13260 9725 13.82 ms 18.56 ms 0 1 167 719 +36.3%
200 13593 9925 14.78 ms 20.24 ms 0 1 194 994 +36.9%

5 runs × 60 seconds

Threads QPS Cluster QPS Single avg Cluster avg Single disk_reads Cluster disk_reads Single QPS gain (%)
120 20179 9797 5.99 ms 11.91 ms 0 2 352 894 +106.0%
160 21314 9782 7.30 ms 16.33 ms 0 2 348 209 +117.9%
180 20773 9834 8.38 ms 18.38 ms 0 2 360 695 +111.3%
200 21571 9828 8.88 ms 20.53 ms 0 2 360 267 +119.5%

5 runs × 120 seconds

Threads QPS Cluster QPS Single avg Cluster avg Single disk_reads Cluster disk_reads Single QPS gain (%)
120 15236 9523 8.47 ms 13.35 ms 0 4 072 067 +59.9%
160 16258 9589 11.71 ms 17.47 ms 0 4 180 584 +69.6%
180 15870 9756 13.53 ms 19.58 ms 0 4 319 040 +62.7%
200 15508 8889 14.72 ms 24.88 ms 0 3 971 902 +74.5%

In summary: there is indeed a performance gain, but at most about 100–120%, which is noticeably lower than in your example (×4.5). At the same time, the Single node shows significantly more stable results — the QPS range almost does not change, while in the cluster the metrics can vary from run to run.

I did not use Sysbench — I plan to run similar tests later on another DBMS for which there are no ready-made Sysbench scripts. To have a universal scenario from the start, I use a Java benchmark (OLTP Point Select), and it is the same for both Single and Cluster.

If I am misinterpreting the results, or there are MySQL/Proxy settings that should be adjusted, I would really appreciate any recommendations. Maybe I missed an important detail in the config or in the load scenario.

My Proxy config:

# database-sharding.yaml
databaseName: sharding_db

dataSources:
  ds0:
    url: jdbc:mysql://ip:3306/ds_0?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&cachePrepStmts=true&prepStmtCacheSize=256&prepStmtCacheSqlLimit=2048&useServerPrepStmts=true&useLocalSessionState=true&cacheDefaultTimezone=true&cacheResultSetMetadata=true&elideSetAutoCommits=true&maintainTimeStats=false
    username: root
    password: pass
    connectionTimeoutMilliseconds: 200000
    idleTimeoutMilliseconds: 120000
    maxLifetimeMilliseconds: 1800000

  ds1:
    url: jdbc:mysql://ip:3306/ds_1?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&cachePrepStmts=true&prepStmtCacheSize=256&prepStmtCacheSqlLimit=2048&useServerPrepStmts=true&useLocalSessionState=true&cacheDefaultTimezone=true&cacheResultSetMetadata=true&elideSetAutoCommits=true&maintainTimeStats=false
    username: root
    password: pass
    connectionTimeoutMilliseconds: 200000
    idleTimeoutMilliseconds: 120000
    maxLifetimeMilliseconds: 1800000

  ds2:
    url: jdbc:mysql://ip:3306/ds_2?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&cachePrepStmts=true&prepStmtCacheSize=256&prepStmtCacheSqlLimit=2048&useServerPrepStmts=true&useLocalSessionState=true&cacheDefaultTimezone=true&cacheResultSetMetadata=true&elideSetAutoCommits=true&maintainTimeStats=false
    username: root
    password: pass
    connectionTimeoutMilliseconds: 200000
    idleTimeoutMilliseconds: 120000
    maxLifetimeMilliseconds: 1800000

  ds3:
    url: jdbc:mysql:/ip:3306/ds_3?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&cachePrepStmts=true&prepStmtCacheSize=256&prepStmtCacheSqlLimit=2048&useServerPrepStmts=true&useLocalSessionState=true&cacheDefaultTimezone=true&cacheResultSetMetadata=true&elideSetAutoCommits=true&maintainTimeStats=false
    username: root
    password: pass
    connectionTimeoutMilliseconds: 200000
    idleTimeoutMilliseconds: 120000
    maxLifetimeMilliseconds: 1800000

  ds4:
    url: jdbc:mysql://ip:3306/ds_4?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&cachePrepStmts=true&prepStmtCacheSize=256&prepStmtCacheSqlLimit=2048&useServerPrepStmts=true&useLocalSessionState=true&cacheDefaultTimezone=true&cacheResultSetMetadata=true&elideSetAutoCommits=true&maintainTimeStats=false
    username: root
    password: pass
    connectionTimeoutMilliseconds: 200000
    idleTimeoutMilliseconds: 120000
    maxLifetimeMilliseconds: 1800000

rules:
  - !SHARDING
    tables:
      t_order:
        actualDataNodes: ds${0..4}.t_order_${0..9}
        databaseStrategy:
          standard:
            shardingColumn: id
            shardingAlgorithmName: db_by_id_inline
        tableStrategy:
          standard:
            shardingColumn: id
            shardingAlgorithmName: tbl_by_id_inline
    shardingAlgorithms:
      db_by_id_inline:
        type: INLINE
        props:
          algorithm-expression: ds${(int)(id / 8000000)}
      tbl_by_id_inline:
        type: INLINE
        props:
          algorithm-expression: t_order_${(int)((id % 8000000) / 800000)}

    keyGenerators:
      snowflake:
        type: SNOWFLAKE
#global.yaml
mode:
  type: Standalone
  repository:
    type: JDBC

authority:
  users:
    - user: root@%
      password: root
      admin: true
    - user: sharding@%
      password: sharding
  authenticators:
    native:
      type: NATIVE
  privilege:
    type: ALL_PERMITTED

transaction:
  defaultType: LOCAL

sqlParser:
  sqlStatementCache:
    initialCapacity: 2000
    maximumSize: 20000
  parseTreeCache:
    initialCapacity: 2000
    maximumSize: 20000

sqlFederation:
  sqlFederationEnabled: false
  executionPlanCache:
    initialCapacity: 1000
    maximumSize: 5000

props:
  system-log-level: INFO
  sql-show: false
  check-table-metadata-enabled: false
  proxy-frontend-executor-size: 0
  proxy-frontend-max-connections: 0
  proxy-frontend-ssl-enabled: false
  proxy-netty-backlog: 1024
  cdc-server-port: 33071
  proxy-default-port: 3313

Proxy connection config:

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://ip:3313/sharding_db?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&cachePrepStmts=true&prepStmtCacheSize=256&prepStmtCacheSqlLimit=2048&useServerPrepStmts=true&useLocalSessionState=true&cacheDefaultTimezone=true&cacheResultSetMetadata=true&elideSetAutoCommits=true&maintainTimeStats=false
spring.datasource.username=sharding
spring.datasource.password=sharding
spring.datasource.hikari.maximum-pool-size=200
spring.datasource.hikari.minimum-idle=0
spring.datasource.hikari.connection-timeout=65000
spring.datasource.hikari.idle-timeout=120000
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.keepalive-time=30000
spring.datasource.hikari.leak-detection-threshold=0

Single-node connection config:

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://ip:3306/single_db?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&cachePrepStmts=true&prepStmtCacheSize=256&prepStmtCacheSqlLimit=2048&useServerPrepStmts=true&useLocalSessionState=true&cacheDefaultTimezone=true&cacheResultSetMetadata=true&elideSetAutoCommits=true&maintainTimeStats=false
spring.datasource.username=root
spring.datasource.password=pass
spring.datasource.hikari.maximum-pool-size=200
spring.datasource.hikari.minimum-idle=0
spring.datasource.hikari.connection-timeout=65000
spring.datasource.hikari.idle-timeout=120000
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.keepalive-time=30000
spring.datasource.hikari.leak-detection-threshold=0

Project to reproduce the tests Full repository with the benchmark, configs and load code: 👉 https://github.com/makssent/sysbench_sphere

I would appreciate it if you could help clarify why the speedup is lower than expected and what else I can check or adjust.

makssent avatar Nov 24 '25 07:11 makssent

There were some debatable moments during testing. I aligned everything with SYSBENCH, but there are no changes in performance — only stabilized results, and now the metrics are identical to SYSBENCH.


SINGLE — 30-second runs (5 runs × 30s)

Threads QPS #1 QPS #2 QPS #3 QPS #4 QPS #5 QPS avg p95 avg Queries total Queries avg disk_reads total disk_reads avg
120 4264.20 5233.57 4807.77 5169.20 4380.47 4771.04 101.10 ms 716 656 143 331 553 357 110 671
160 4431.60 5544.27 5930.30 4358.17 4723.37 4997.54 113.13 ms 749 631 149 926 599 471 119 894
180 4433.53 5304.10 5850.93 4618.50 4277.77 4896.97 153.27 ms 734 545 146 909 587 842 117 568
200 3818.73 5089.50 6021.27 4561.00 4324.87 4763.07 169.74 ms 714 461 142 892 570 722 114 144

SINGLE — 60-second runs (5 runs × 60s)

Threads QPS #1 QPS #2 QPS #3 QPS #4 QPS #5 QPS avg p95 avg Queries total Queries avg disk_reads total disk_reads avg
120 4913.78 5295.62 5192.07 5477.22 4185.83 5012.90 105.33 ms 1 503 871 300 774 1 203 148 240 630
160 5194.27 5655.33 5015.72 5449.72 3989.92 5060.99 132.07 ms 1 518 297 303 659 1 213 650 242 730
180 5421.23 5408.20 4959.35 5517.52 5052.55 5271.77 158.64 ms 1 581 531 316 306 1 265 990 253 198
200 5391.20 5470.05 5539.00 4800.17 5003.93 5240.87 168.57 ms 1 572 261 314 452 1 257 970 251 594

SINGLE — 120-second runs (5 runs × 120s)

Threads QPS #1 QPS #2 QPS #3 QPS #4 QPS #5 QPS avg p95 avg Queries total Queries avg disk_reads total disk_reads avg
120 4980.14 2970.04 4114.28 4007.80 2702.25 3754.10 130.99 ms 2 252 942 450 588 1 703 743 340 749
160 5363.02 2967.93 4284.31 4796.78 3756.18 4233.64 176.19 ms 2 440 185 488 037 1 833 697 366 739
180 4577.58 4064.78 3947.65 3787.37 3422.74 3960.82 176.97 ms 2 375 014 475 003 1 891 278 378 255
200 3232.85 4322.37 4189.58 2194.95 3346.31 3457.21 262.67 ms 1 984 283 396 857 1 508 043 301 609

CLUSTER — 30-second runs (5 runs × 30s)

Threads QPS #1 QPS #2 QPS #3 QPS #4 QPS #5 QPS avg p95 avg Queries total Queries avg disk_reads total disk_reads avg
120 7092.43 7224.40 8369.73 5454.40 6440.63 6916.32 30.13 ms 1 037 448 207 490 0 0
160 8500.50 8369.83 9625.53 6934.03 6745.33 8035.04 36.75 ms 1 205 257 241 051 3 1
180 9088.23 9441.10 8447.07 8289.43 7180.90 8489.35 40.33 ms 1 273 402 254 680 1 0
200 9145.90 9067.00 8657.03 7505.47 8448.00 8564.68 45.46 ms 1 284 702 256 940 6 1

CLUSTER — 60-second runs (5 runs × 60s)

Threads QPS #1 QPS #2 QPS #3 QPS #4 QPS #5 QPS avg p95 avg Queries total Queries avg disk_reads total disk_reads avg
120 6038.62 7267.73 7172.95 8583.25 6620.23 7136.16 32.73 ms 2 205 867 441 173 1 0
160 6727.03 9195.58 7880.45 7766.42 6679.37 7649.37 37.13 ms 2 900 701 580 140 0 0
180 7305.70 10950.95 8430.73 5855.27 7275.10 7963.15 46.17 ms 2 857 302 571 460 0 0
200 7070.50 9946.05 7558.12 6070.97 6430.62 7415.25 57.16 ms 2 588 363 517 672 1 0

CLUSTER — 120-second runs (5 runs × 120s)

Threads QPS #1 QPS #2 QPS #3 QPS #4 QPS #5 QPS avg p95 avg Queries total Queries avg disk_reads total disk_reads avg
120 2892.16 3631.78 6038.62 7267.73 7172.95 5390.65 43.94 ms 2 127 485 425 497 1 0
160 4513.17 3910.93 6727.03 9195.58 7880.45 6445.03 41.70 ms 2 533 239 506 648 0 0
180 3926.22 5106.11 7305.70 10950.95 8430.73 7151.54 65.75 ms 3 041 546 608 309 0 0
200 4912.89 4621.41 7070.50 9946.05 7558.12 6821.39 70.57 ms 3 057 625 611 525 1 0

comparison — 30s / 60s / 120s

30 seconds

Threads QPS Cluster QPS Single p95 Cluster p95 Single disk_reads Cluster disk_reads Single QPS gain
120 6916.32 4771.04 30.13 ms 101.10 ms 0 553357 +45.0%
160 8035.04 4997.54 36.75 ms 113.13 ms 1 599471 +60.7%
180 8489.35 4896.97 40.33 ms 153.27 ms 0 587842 +73.4%
200 8564.68 4763.07 45.46 ms 169.74 ms 1 570722 +79.8%

60 seconds

Threads QPS Cluster QPS Single p95 Cluster p95 Single disk_reads Cluster disk_reads Single QPS gain
120 7136.16 5012.90 32.73 ms 105.33 ms 0 1 203 148 +42.3%
160 7649.37 5060.99 37.13 ms 132.07 ms 0 1 213 650 +51.1%
180 7963.15 5271.77 46.17 ms 158.64 ms 0 1 265 990 +51.0%
200 7415.25 5240.87 57.16 ms 168.57 ms 0 1 257 970 +41.5%

120 seconds

Threads QPS Cluster QPS Single p95 Cluster p95 Single disk_reads Cluster disk_reads Single QPS gain
120 5390.65 3754.10 43.94 ms 130.99 ms 0 1 703 743 +43.6%
160 6445.03 4233.64 41.70 ms 176.19 ms 0 1 833 697 +52.2%
180 7151.54 3960.82 65.75 ms 176.97 ms 0 1 891 278 +80.5%
200 6821.39 3457.21 70.57 ms 262.67 ms 0 1 508 043 +97.3%

makssent avatar Nov 25 '25 14:11 makssent

In total, I’ve run a huge number of tests: changed nodes, tested different combinations (2/3/4 nodes, etc.), and it’s now completely clear that the issue is not in the nodes. They work consistently and don’t lose performance as the dataset grows. For example, 2 nodes = 8+8M rows produce roughly the same results as 3 nodes = 8+8+8M. So the nodes themselves operate correctly and stably.

Logically, this would imply that the single-node setup should slow down significantly, but based on my calculations — that’s not happening. When increasing the dataset from 16M to 24M rows, the single node doesn’t degrade enough to justify a +300% performance gain from 3 nodes compared to +200% from 2 nodes. Because of this, it’s unclear where such a large scaling boost is supposed to come from.

I’ll also prepare a separate comparison showing how the single node slows down at 8, 16, 24, 32, and 40 million rows to measure the drop per +8M (equivalent to adding one node in the cluster). But based on what I’ve seen, there likely won’t be a strong regression there — unless the database were running on HDDs, which is obviously not our case.

If you have any ideas or insights on this, I’d appreciate them.

UPD — Comparative table of cluster node combinations by average QPS

###Comparative table of cluster node combinations by average QPS (

Threads ds0+ds1 nodes ds1+ds2 nodes ds2+ds3 nodes 3 nodes 4 nodes 5 nodes
120 23036.84 14214.54 16347.01 18980.62 20054.47 16781.46
160 25768.10 16901.63 17571.32 21076.81 21468.04 18499.17
180 25673.63 17302.55 17838.07 21673.69 22418.40 19410.09
200 25780.92 16929.91 17746.73 21594.29 22636.21 19444.78

As seen in the table, the results across all configurations are roughly the same, which indicates that the cluster operates stably and that the nodes themselves are not the cause of the missing performance gain.

Previously, there was a theory that some nodes might perform differently (even though their specs are identical, a few seemed to “lag” more than others). Because of this, I additionally tested multiple two-node combinations on different machines — however, the results clearly show that the issue does not come from the nodes.

(Although nodes 0 and 1 consistently show unusually high performance, I haven't looked into the reason yet, since it does not affect the overall picture.)

makssent avatar Nov 26 '25 14:11 makssent

I've updated the link to the testing repository and also added a new folder with logs containing all my benchmark results. The link has also been updated in the messages above.

https://github.com/makssent/sysbench_sphere

makssent avatar Nov 26 '25 14:11 makssent

Thank you for your thorough testing. This data is highly valuable, and we will analyze it carefully. However, we are currently swamped with work, and the volume of data is substantial. We need some time to digest the findings and analyze the performance bottlenecks.

If you happen to have time during the testing process, you could consider doing the following:

  1. Capture flame graphs to analyze ShardingSphere's performance bottlenecks.
  2. Monitor various MySQL performance metrics, such as I/O and memory usage, to further clarify whether the performance bottleneck lies in ShardingSphere or the database.

You're welcome to share these data—let's work together to pinpoint the issues.

terrymanu avatar Nov 26 '25 14:11 terrymanu

Thank you for your response. I really appreciate that my messages were noticed — I genuinely like your approach of always staying in touch with users. I’ll capture the I/O metrics and will try to prepare the flame graphs as well. As soon as I have new data, I’ll share it right away.

makssent avatar Nov 26 '25 14:11 makssent

I’ve collected a set of metrics. The table for the Single nodes isn’t ready yet — I’ll provide it later.
Below are the 30-second OLTP Point-Select I/O metrics on a 5-node cluster for 120 / 160 / 180 / 200 threads.

Static metrics (MySQL GLOBAL STATUS, identical for all thread counts):
Innodb_pages_flushed = 279,
Innodb_pages_written = 279,
Innodb_data_fsyncs = 203,
Innodb_data_reads = 127494, Innodb_data_writes = 576,
Innodb_data_read = 2 087 980 544 bytes,
Innodb_data_written = 4 674 048 bytes,
Innodb_os_log_fsyncs = 88,
Innodb_os_log_written = 72 192 bytes,
Innodb_buffer_pool_reads = 126924

Metrics that were always zero for all runs:
Innodb_buffer_pool_pages_dirty = 0,
Innodb_buffer_pool_bytes_dirty = 0,
Innodb_log_waits = 0,
Innodb_row_lock_waits = 0, Innodb_row_lock_time = 0, Innodb_row_lock_time_avg = 0, Innodb_row_lock_time_max = 0,
Innodb_data_pending_reads = 0, Innodb_data_pending_writes = 0, Innodb_data_pending_fsyncs = 0,
Innodb_os_log_pending_fsyncs = 0, Innodb_os_log_pending_writes = 0,
Innodb_undo_tablespaces_explicit = 0,
Innodb_buffer_pool_wait_free = 0,
Innodb_buffer_pool_read_ahead_rnd = 0,
Innodb_buffer_pool_read_ahead_evicted = 0,
Innodb_sampled_pages_read = 0, Innodb_sampled_pages_skipped = 0,
Innodb_truncated_status_writes = 0.


Cluster I/O deltas (only changing metrics)

Threads = 120

  • Innodb_buffer_pool_read_requests = 262 093
  • Innodb_rows_read = 86 456

Threads = 160

  • Innodb_buffer_pool_read_requests = 377 830
  • Innodb_rows_read = 124 675

Threads = 180

  • Innodb_buffer_pool_read_requests = 363 734
  • Innodb_rows_read = 120 027

Threads = 200

  • Innodb_buffer_pool_read_requests = 353 232
  • Innodb_rows_read = 116 550

Image

GitHub didn’t allow uploading all files directly, so I added the full (though small) set of metrics to a release instead:
https://github.com/makssent/sysbench_sphere/releases/tag/metrics

According to the flame graph, a significant portion of CPU time is spent in the routing layer.
The I/O metrics show that the entire working dataset fits fully into the InnoDB buffer pool.
Across all 30-second runs and all thread levels, the delta of Innodb_buffer_pool_reads remained zero — meaning the cluster handled all requests entirely from memory, without any disk access.

makssent avatar Nov 27 '25 12:11 makssent

Hi @makssent, you can use custome sharding algorithm to replace inline sharding algorithm. Because groovy expressions have some overhead.

Image

strongduanmu avatar Nov 28 '25 09:11 strongduanmu

Hi @strongduanmu, I’ve done everything you asked for and ran 3 tests of 30 seconds each — before and after the changes.


📊 Table (30 seconds, before changes)

Threads QPS #1 QPS #2 QPS #3 QPS avg p95 avg (ms) Queries total Queries avg
120 13401.83 19315.53 19254.07 17323.81 12.18 1 559 143 519 714.33
160 19177.73 19550.43 19290.10 19339.42 18.69 1 740 548 580 182.67
180 19379.13 19158.87 19159.23 19232.41 21.67 1 730 917 576 972.33
200 18433.47 19394.53 18912.33 18913.44 24.79 1 702 210 567 403.33

Old flame graphs ()

Image

📊 Table (30 seconds, after changes)

Threads QPS #1 QPS #2 QPS #3 QPS avg p95 avg (ms) Queries total Queries avg
120 17828.40 19665.90 19860.93 19118.41 10.98 1 720 657 573 552.33
160 19912.30 19537.03 19429.63 19626.32 18.19 1 766 369 588 789.67
180 20246.13 20434.83 19990.00 20223.66 20.84 1 820 129 606 709.67
200 20119.03 20309.77 20439.80 20289.53 23.61 1 826 058 608 686.00

New flame graphs

Image Image

📈 Comparison (before → after)

Threads QPS avg (before) QPS avg (after) Δ QPS Δ %
120 17323.81 19118.41 +1794.60 +10.36%
160 19339.42 19626.32 +286.90 +1.48%
180 19232.41 20223.66 +991.25 +5.15%
200 18913.44 20289.53 +1376.09 +7.28%

As you can see, there is an improvement, but it’s not very large. I understand that many things can still be optimized, but I don’t believe it’s realistic to push the Proxy to 4.5×. Right now, in an ideal (but rare) run we get around 2.5×, in good runs about 2×, and on average something like 1.5–2×. Honestly, I don’t see how this could be pushed to 4.5× through Proxy optimizations if without any optimizations it delivers only around 2×.

If needed, I can also provide full I/O metrics, an archive with all logs, or compile everything into a single detailed report.

makssent avatar Nov 29 '25 12:11 makssent

Let me refresh the data a bit, because during this time I tested many different configurations and made various adjustments.

Cluster Benchmark (200 threads)

Duration QPS #1 QPS #2 QPS #3 QPS Avg p95 #1 p95 #2 p95 #3 p95 Avg (ms)
30s 12101.23 13172.53 12348.53 12540.76 26.753 25.773 27.758 26.76
60s 14958.77 16880.63 16072.38 15970.59 24.482 20.582 21.288 22.12
120s 20357.69 14640.98 17766.53 17588.40 18.248 20.635 20.587 19.82

SingleDB Benchmark (200 threads)

Duration QPS #1 QPS #2 QPS #3 QPS Avg p95 #1 p95 #2 p95 #3 p95 Avg (ms)
30s 9282.47 9295.67 9088.30 9222.15 72.246 66.671 69.021 69.31
60s 9375.52 9648.97 9532.12 9518.87 88.779 87.511 90.904 89.07
120s 8935.35 9191.13 9431.38 9185.95 110.902 111.966 109.380 110.75

Comparative Benchmark Results (Cluster vs Single, 200 threads)

Duration QPS Single QPS Cluster QPS Gain (%) p95 Single (ms) p95 Cluster (ms)
30s 9222.15 12540.76 +35.9% (×1.36) 69.31 26.76
60s 9518.87 15970.59 +67.7% (×1.68) 89.07 22.12
120s 9185.95 17588.40 +91.5% (×1.92) 110.75 19.82

CPU Load on Single (120s)

Single CPU Load

As visible in the chart, during the 120-second runs the Single node reaches 93–100% total CPU load.

CPU Load on a Cluster Node (120s)

Cluster Node CPU Load

The cluster node CPU barely feels the load.

I included CPU graphs because one colleague suggested that Proxmox might distribute virtual CPU cores incorrectly, causing cluster VM nodes to compete for the same physical cores. However, the graphs show no evidence of CPU contention.

If virtualization were limiting RAM, cluster nodes would experience buffer pool pressure and fall back to disk I/O — but this does not happen.
In contrast, the Single node frequently performs physical reads.
Therefore, the issue does not appear to be related to virtualization.


SphereEX Reference Hardware

Component Value
CPU 48 cores
Memory 96 GB
Disk SSD 820 GB

The documentation does not specify whether this refers to a single physical machine or a set of VMs.

Comparing your p95 results with mine:
in our 60-second run, the cluster p95 is about 22 ms, while the Single node shows about 89 ms.
The latency reduction is significant, yet QPS increases only to ×1.36–×1.92, far from the ×4.5 in your benchmark.

If there is anything else I can provide to help clarify the situation, I am ready to collect additional metrics. I do not believe Proxy optimizations alone could realistically increase performance from this range up to ×4.5 in the current environment.


Current Situation Summary

  • The Single node pushes CPU usage close to 100%.
  • RAM is distributed correctly across cluster nodes, with no signs of virtualization-related memory pressure.
  • Network throughput has not been tested yet; I can check it if needed.
  • The workload is equivalent to Sysbench OLTP Point Select, and correctness was verified directly through MySQL.
  • Dataset sizes match your example: 40M rows on Single, 8M rows per cluster node; each MySQL instance has a 2 GB buffer pool.
    The Single node performs about 80% physical reads, which causes regression but still does not approach ×4.5.

If you need any additional information, I will be happy to provide it.
Your questions may help point me toward the root cause.

makssent avatar Dec 01 '25 12:12 makssent

Next, I plan to test the network layer to verify whether it might be acting as a bottleneck.

makssent avatar Dec 01 '25 16:12 makssent

I checked the network between the Proxy and all cluster nodes. I ran the following tests on each node:

iperf3 -c NODEX -t 10
iperf3 -c NODEX -P 4 -t 10
iperf3 -c NODEX -R -t 10

Results without Proxy running:

Node Single Multi (P=4) Reverse
NODE1 ~23.5 Gbit/s ~29.2 Gbit/s ~22.9 Gbit/s
NODE2 ~21.8 Gbit/s ~28.4 Gbit/s ~24.5 Gbit/s
NODE3 ~23.5 Gbit/s ~21.8 Gbit/s ~23.6 Gbit/s
NODE4 ~25.0 Gbit/s ~29.7 Gbit/s ~23.3 Gbit/s
NODE5 ~23–27 Gbit/s ~29–30 Gbit/s ~26.4 Gbit/s

The network works stably in the 22–30 Gbit/s range, without drops or instability. With Proxy running (but without OLTP load), throughput remains at the same level — around 22–24 Gbit/s.

When OLTP tests (200 threads) are running, iperf3 and Proxy begin to compete for CPU and the network stack. Because of this, iperf3 speed initially stays around ~20–23 Gbit/s, but then drops:

743 MBytes   6.12 Gbits/sec
680 MBytes   5.79 Gbits/sec
602 MBytes   4.99 Gbits/sec
580 MBytes   4.99 Gbits/sec
...
208 MBytes   1.65 Gbits/sec
165 MBytes   1.27 Gbits/sec
137 MBytes   1.15 Gbits/sec
125 MBytes   1.12 Gbits/sec

As soon as the load decreases, the speed returns to the normal level:

[  5]  57.00-58.00  sec  2.53 GBytes  21.7 Gbits/sec
[  5]  58.00-59.00  sec  2.75 GBytes  23.7 Gbits/sec
[  5]  59.00-60.00  sec  2.67 GBytes  22.9 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-60.00  sec  86.5 GBytes  12.4 Gbits/sec                  sender
[  5]   0.00-60.00  sec  86.5 GBytes  12.4 Gbits/sec                  receiver

Even the minimal speed (1–2 Gbit/s) is still higher than the actual SQL traffic of the Proxy. The network between Proxy and nodes is not a bottleneck. There is more than enough throughput for all OLTP tests, and no network limitations are observed.

makssent avatar Dec 02 '25 07:12 makssent

I think there is no need to look into anything further in this ticket for now. I’m currently rebuilding the virtual machines, and I’ll rerun the tests on the new setup. Once I have updated results, I’ll come back with fresh data. Hopefully, we’ll be able to close this ticket successfully. I’ll be back soon.

makssent avatar Dec 02 '25 14:12 makssent