Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve PlayServerInterpreter.toRoutes #3838

Conversation

dmtran-g
Copy link
Contributor

Related issue: #3549

This PR makes the following changes:

  • in PlayServerInterpreter.toRoutes, avoid instantiating a ServerInterpreter for each request.
  • Fix scenario names in Simulations.scala, to avoid a runtime error related to duplicate names.

I ran some of the gatling tests a couple times (as explained in the perf-tests README), and this change seems to increase throughput.

I started a server using

perfTests/runMain sttp.tapir.perf.apis.ServerRunner play.Tapir

Then I ran the tests using

perfTests/Gatling/testOnly sttp.tapir.perf.SimpleGetSimulation
perfTests/Gatling/testOnly sttp.tapir.perf.PostLongBytesSimulation

SimpleGetSimulation

  1. Without the changes of this PR
================================================================================
---- Global Information --------------------------------------------------------
> request count                                    1174121 (OK=1174121 KO=0     )
> min response time                                      0 (OK=0      KO=-     )
> max response time                                    427 (OK=427    KO=-     )
> mean response time                                     1 (OK=1      KO=-     )
> std deviation                                          5 (OK=5      KO=-     )
> response time 50th percentile                          1 (OK=1      KO=-     )
> response time 75th percentile                          1 (OK=1      KO=-     )
> response time 95th percentile                          2 (OK=2      KO=-     )
> response time 99th percentile                          5 (OK=5      KO=-     )
> mean requests/sec                                27955.26 (OK=27955.26 KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                       1174121 (   100%)
> 800 ms <= t < 1200 ms                                  0 (     0%)
> t >= 1200 ms                                           0 (     0%)
> failed                                                 0 (     0%)
================================================================================

================================================================================
---- Global Information --------------------------------------------------------
> request count                                    1238179 (OK=1238179 KO=0     )
> min response time                                      0 (OK=0      KO=-     )
> max response time                                    386 (OK=386    KO=-     )
> mean response time                                     1 (OK=1      KO=-     )
> std deviation                                          5 (OK=5      KO=-     )
> response time 50th percentile                          1 (OK=1      KO=-     )
> response time 75th percentile                          1 (OK=1      KO=-     )
> response time 95th percentile                          2 (OK=2      KO=-     )
> response time 99th percentile                          5 (OK=5      KO=-     )
> mean requests/sec                                29480.45 (OK=29480.45 KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                       1238179 (   100%)
> 800 ms <= t < 1200 ms                                  0 (     0%)
> t >= 1200 ms                                           0 (     0%)
> failed                                                 0 (     0%)
================================================================================

================================================================================
---- Global Information --------------------------------------------------------
> request count                                    1259757 (OK=1259757 KO=0     )
> min response time                                      0 (OK=0      KO=-     )
> max response time                                    449 (OK=449    KO=-     )
> mean response time                                     1 (OK=1      KO=-     )
> std deviation                                          5 (OK=5      KO=-     )
> response time 50th percentile                          1 (OK=1      KO=-     )
> response time 75th percentile                          1 (OK=1      KO=-     )
> response time 95th percentile                          2 (OK=2      KO=-     )
> response time 99th percentile                          4 (OK=4      KO=-     )
> mean requests/sec                                29994.21 (OK=29994.21 KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                       1259757 (   100%)
> 800 ms <= t < 1200 ms                                  0 (     0%)
> t >= 1200 ms                                           0 (     0%)
> failed                                                 0 (     0%)
================================================================================
  1. With the changes of this PR
================================================================================
---- Global Information --------------------------------------------------------
> request count                                    1210686 (OK=1210686 KO=0     )
> min response time                                      0 (OK=0      KO=-     )
> max response time                                    514 (OK=514    KO=-     )
> mean response time                                     1 (OK=1      KO=-     )
> std deviation                                          5 (OK=5      KO=-     )
> response time 50th percentile                          1 (OK=1      KO=-     )
> response time 75th percentile                          1 (OK=1      KO=-     )
> response time 95th percentile                          2 (OK=2      KO=-     )
> response time 99th percentile                          5 (OK=5      KO=-     )
> mean requests/sec                                28825.86 (OK=28825.86 KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                       1210686 (   100%)
> 800 ms <= t < 1200 ms                                  0 (     0%)
> t >= 1200 ms                                           0 (     0%)
> failed                                                 0 (     0%)
================================================================================

================================================================================
---- Global Information --------------------------------------------------------
> request count                                    1287812 (OK=1287812 KO=0     )
> min response time                                      0 (OK=0      KO=-     )
> max response time                                    427 (OK=427    KO=-     )
> mean response time                                     1 (OK=1      KO=-     )
> std deviation                                          5 (OK=5      KO=-     )
> response time 50th percentile                          1 (OK=1      KO=-     )
> response time 75th percentile                          1 (OK=1      KO=-     )
> response time 95th percentile                          2 (OK=2      KO=-     )
> response time 99th percentile                          4 (OK=4      KO=-     )
> mean requests/sec                                30662.19 (OK=30662.19 KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                       1287812 (   100%)
> 800 ms <= t < 1200 ms                                  0 (     0%)
> t >= 1200 ms                                           0 (     0%)
> failed                                                 0 (     0%)
================================================================================

================================================================================
---- Global Information --------------------------------------------------------
> request count                                    1314742 (OK=1314742 KO=0     )
> min response time                                      0 (OK=0      KO=-     )
> max response time                                    382 (OK=382    KO=-     )
> mean response time                                     1 (OK=1      KO=-     )
> std deviation                                          6 (OK=6      KO=-     )
> response time 50th percentile                          1 (OK=1      KO=-     )
> response time 75th percentile                          1 (OK=1      KO=-     )
> response time 95th percentile                          2 (OK=2      KO=-     )
> response time 99th percentile                          4 (OK=4      KO=-     )
> mean requests/sec                                31303.38 (OK=31303.38 KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                       1314742 (   100%)
> 800 ms <= t < 1200 ms                                  0 (     0%)
> t >= 1200 ms                                           0 (     0%)
> failed                                                 0 (     0%)
================================================================================

PostLongBytesSimulation

  1. Without the changes of this PR
================================================================================
---- Global Information --------------------------------------------------------
> request count                                      17099 (OK=17099  KO=0     )
> min response time                                      7 (OK=7      KO=-     )
> max response time                                   1227 (OK=1227   KO=-     )
> mean response time                                    70 (OK=70     KO=-     )
> std deviation                                         77 (OK=77     KO=-     )
> response time 50th percentile                         49 (OK=49     KO=-     )
> response time 75th percentile                         84 (OK=84     KO=-     )
> response time 95th percentile                        158 (OK=158    KO=-     )
> response time 99th percentile                        388 (OK=388    KO=-     )
> mean requests/sec                                 407.12 (OK=407.12 KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                         17072 ( 99.84%)
> 800 ms <= t < 1200 ms                                 21 (  0.12%)
> t >= 1200 ms                                           6 (  0.04%)
> failed                                                 0 (     0%)
================================================================================


================================================================================
---- Global Information --------------------------------------------------------
> request count                                      21473 (OK=21473  KO=0     )
> min response time                                      2 (OK=2      KO=-     )
> max response time                                    836 (OK=836    KO=-     )
> mean response time                                    55 (OK=55     KO=-     )
> std deviation                                         62 (OK=62     KO=-     )
> response time 50th percentile                         33 (OK=33     KO=-     )
> response time 75th percentile                         70 (OK=70     KO=-     )
> response time 95th percentile                        143 (OK=143    KO=-     )
> response time 99th percentile                        367 (OK=367    KO=-     )
> mean requests/sec                                 511.26 (OK=511.26 KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                         21470 ( 99.99%)
> 800 ms <= t < 1200 ms                                  3 (  0.01%)
> t >= 1200 ms                                           0 (     0%)
> failed                                                 0 (     0%)
================================================================================

  1. With the changes of this PR
================================================================================
---- Global Information --------------------------------------------------------
> request count                                      32840 (OK=32840  KO=0     )
> min response time                                      3 (OK=3      KO=-     )
> max response time                                    477 (OK=477    KO=-     )
> mean response time                                    36 (OK=36     KO=-     )
> std deviation                                         37 (OK=37     KO=-     )
> response time 50th percentile                         24 (OK=24     KO=-     )
> response time 75th percentile                         35 (OK=35     KO=-     )
> response time 95th percentile                        124 (OK=125    KO=-     )
> response time 99th percentile                        168 (OK=168    KO=-     )
> mean requests/sec                                  781.9 (OK=781.9  KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                         32840 (   100%)
> 800 ms <= t < 1200 ms                                  0 (     0%)
> t >= 1200 ms                                           0 (     0%)
> failed                                                 0 (     0%)
================================================================================



================================================================================
---- Global Information --------------------------------------------------------
> request count                                      35517 (OK=35517  KO=0     )
> min response time                                      3 (OK=3      KO=-     )
> max response time                                    856 (OK=856    KO=-     )
> mean response time                                    33 (OK=33     KO=-     )
> std deviation                                         36 (OK=36     KO=-     )
> response time 50th percentile                         22 (OK=22     KO=-     )
> response time 75th percentile                         31 (OK=31     KO=-     )
> response time 95th percentile                        121 (OK=121    KO=-     )
> response time 99th percentile                        161 (OK=161    KO=-     )
> mean requests/sec                                 845.64 (OK=845.64 KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                         35515 ( 99.99%)
> 800 ms <= t < 1200 ms                                  2 (  0.01%)
> t >= 1200 ms                                           0 (     0%)
> failed                                                 0 (     0%)
================================================================================

@kciesielski
Copy link
Member

Thanks! As mentioned in #3549 (comment), this doesn't solve the issue but is definitely worth applying, to avoid unnecessary instantiations.

@kciesielski kciesielski merged commit c5c59e1 into softwaremill:master Jun 13, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants