Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Try lower DB pool size for Crystal - #4160

Merged
NateBrady23 merged 1 commit into
TechEmpower:masterfrom
vlazar:tune-crystal-db-pool-size
Oct 29, 2018
Merged

NateBrady23 merged 1 commit into
TechEmpower:masterfrom
vlazar:tune-crystal-db-pool-size

Conversation

@vlazar

@vlazar vlazar commented Oct 28, 2018

Copy link
Copy Markdown
Contributor

I've spent some time looking at the results before and after #3209 was merged where DB pool settings were added to one of Crystal implementations as a workaround.

Before #3209 https://www.techempower.com/benchmarks/#section=test&runid=ddc974dc-8f1a-4773-b609-c9c226fb42c2&hw=ph&test=json&l=hma7sv
After #3209 https://www.techempower.com/benchmarks/#section=test&runid=e70ce78c-fa34-4007-b3be-fee596ddb09e&hw=ph&test=json&l=hma7sv

Things I've noticed on physical hardware (Server Central):

RPS
It's ruined for endpoints with no DB involved:

  • Plaintext (2000k -> 200k)
  • JSON serialization (650k -> 85k)

Dropped for DB endpoints:

  • Single query (77k -> 45k)
  • Multiple queries (3.7k -> 3.2k)
  • Fortunes (87k -> 25k)
  • Data updates (0.9k -> 0.7k)

Latency
Became worse for

  • Data updates (550ms -> 750ms)

Improved for

  • Multiple queries (430ms -> 160ms)

Improved a lot for

  • Single query (250ms -> 1.5ms)
  • Fortunes (230ms -> 2.5ms)

I'm also taking into account the latest results where it's clear that every Crystal implementation except for one with DB pool settings has quite a lot of errors. So #3209 seems to prevent errors.

I'm also aware that in Cloud environment (Azure) it now performs very good after this fix. Especially for Single query and Fortunes endpoints.

I've seen other implementations are using 3-4 pool size per CPU for physical environment and 8 for cloud and produce very good results.

So what I want to try is a much lower DB pool size to see if it will start to perform better on physical hardware and at the same time not worse in cloud environment.

If this gives good results I'm going to add DB pool settings (maybe with some autotuning) for other Crystal implementations as a separate PR to prevent errors and improve results.

@NateBrady23
NateBrady23 merged commit e0eae86 into TechEmpower:master Oct 29, 2018
roberthusak pushed a commit to roberthusak/FrameworkBenchmarks that referenced this pull request Nov 6, 2018
vlazar added a commit to vlazar/FrameworkBenchmarks that referenced this pull request Nov 11, 2018
Lower DB pool size from TechEmpower#4160 results in better RPS on Citrine.

Before https://www.techempower.com/benchmarks/#section=test&runid=56076e97-0658-46a1-81bb-6f8890f2e85e
After https://www.techempower.com/benchmarks/#section=test&runid=5191fd86-6a2a-405b-b326-f160fc6781b7

                  Before    After    Better
JSON              345k   -> 1016k  ~ 3x
Single query      178k   -> 261k   ~ 1.5x
Multiple queries  9.2k   -> 11.9k  ~ 1.3x
Fortunes          87.5k  -> 258.4k ~ 3x
Data updates      1.2k   -> 3.1k   ~ 2.7x
Plain Text        740k   -> 2025k  ~ 2.7x

Note:

Keep an eye on Latency, since it's dropped a lot in some cases.

Might be a good idea to try average latency from multiple runs,
as latency numbers seem to be in flux sometimes for no obvious reason.

                  Before    After    Worse
JSON              0.2ms  -> 0.7ms  ~ 3x
Single query      0.6ms  -> 0.4 ms
Multiple queries  55ms   -> 309ms  > 5x
Fortunes          1.3ms  -> 173ms  > 100x (!!!)
Data updates      426sm  -> 535ms  ~ 1.2x
Plain Text        4.3ms  -> 13.9ms ~ 3x
vlazar added a commit to vlazar/FrameworkBenchmarks that referenced this pull request Nov 11, 2018
Lower DB pool size from TechEmpower#4160 results in better RPS on Citrine.

Before https://www.techempower.com/benchmarks/#section=test&runid=56076e97-0658-46a1-81bb-6f8890f2e85e
After https://www.techempower.com/benchmarks/#section=test&runid=5191fd86-6a2a-405b-b326-f160fc6781b7

                  Before    After    Better
JSON              345k   -> 1016k  ~ 3x
Single query      178k   -> 261k   ~ 1.5x
Multiple queries  9.2k   -> 11.9k  ~ 1.3x
Fortunes          87.5k  -> 258.4k ~ 3x
Data updates      1.2k   -> 3.1k   ~ 2.7x
Plain Text        740k   -> 2025k  ~ 2.7x

Note:

Keep an eye on Latency, since it's dropped a lot in some cases.

Might be a good idea to try average latency from multiple runs,
as latency numbers seem to be in flux sometimes for no obvious reason.

                  Before    After    Worse
JSON              0.2ms  -> 0.7ms  ~ 3x
Single query      0.6ms  -> 0.4 ms
Multiple queries  55ms   -> 309ms  > 5x
Fortunes          1.3ms  -> 173ms  > 100x (!!!)
Data updates      426sm  -> 535ms  ~ 1.2x
Plain Text        4.3ms  -> 13.9ms ~ 3x
NateBrady23 pushed a commit that referenced this pull request Nov 12, 2018
Lower DB pool size from #4160 results in better RPS on Citrine.

Before https://www.techempower.com/benchmarks/#section=test&runid=56076e97-0658-46a1-81bb-6f8890f2e85e
After https://www.techempower.com/benchmarks/#section=test&runid=5191fd86-6a2a-405b-b326-f160fc6781b7

                  Before    After    Better
JSON              345k   -> 1016k  ~ 3x
Single query      178k   -> 261k   ~ 1.5x
Multiple queries  9.2k   -> 11.9k  ~ 1.3x
Fortunes          87.5k  -> 258.4k ~ 3x
Data updates      1.2k   -> 3.1k   ~ 2.7x
Plain Text        740k   -> 2025k  ~ 2.7x

Note:

Keep an eye on Latency, since it's dropped a lot in some cases.

Might be a good idea to try average latency from multiple runs,
as latency numbers seem to be in flux sometimes for no obvious reason.

                  Before    After    Worse
JSON              0.2ms  -> 0.7ms  ~ 3x
Single query      0.6ms  -> 0.4 ms
Multiple queries  55ms   -> 309ms  > 5x
Fortunes          1.3ms  -> 173ms  > 100x (!!!)
Data updates      426sm  -> 535ms  ~ 1.2x
Plain Text        4.3ms  -> 13.9ms ~ 3x
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants