Async endpoints are much slower compared to equivalent ones written with `{plumber}`.

Đang mở
#61 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
r
Lĩnh vực
api, backend, performance

Hướng nghiên cứu

Start with the linked performance-optimization-for-plumber-apis repository and reproduce its plumber2 synchronous and asynchronous load tests. Compare those results with the plumber/mirai case and inspect the plumber2 async entry points involved. Done means identifying why the async endpoint is slower and confirming the fix with comparable throughput measurements.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Very excited about this package; thanks for all the great work so far. While load testing an app with an async endpoint written with {plumber2}, I noticed unusually low throughput (see summary stats below). When I ran a similar {plumber2} app without async, the performance improved. This is odd because both apps contain a single I/O bound endpoint, so I would expect the async version to have better throughput. For comparison, I ran a third app written with {plumber} instead of {plumber2} that uses {mirai} for async processing. This third app performed better than the synchronous app, which is expected. But the first app and the third app both use {mirai} for async processing, so I'm stumped why the async app written with {plumber2} would be slower.

Summary stats from each load test are as follows. Each load test simulated 200 users with 1-2 seconds between requests for a duration of 1 minute.

load_test min_response_time_ms med_response_time_ms max_response_time_ms total_seconds total_requests rps
plumber2-sync 6.86 465.80 689.46 59.68 5325 89.23
plumber2-async 51.83 8203.13 8600.50 59.20 1130 19.09
plumber-async 3.46 8.82 150.68 59.70 6770 113.40

I've compiled my findings in the repo here. I couldn't think of a better way to package this as a minimally reproducible example, so if the above isn't actionable please let me know and I'll take another stab at it.

The following is the output from sessioninfo::session_info() from inside one of the API containers.

─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.5.1 (2025-06-13)
 os       Ubuntu 24.04.2 LTS
 system   aarch64, linux-gnu
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Berlin
 date     2025-11-08
 pandoc   3.1.3 @ /usr/bin/pandoc
 quarto   NA

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────
 package        * version   date (UTC) lib source
 base64enc        0.1-3     2015-07-28 [1] CRAN (R 4.4.1)
 brio             1.1.5     2024-04-24 [1] CRAN (R 4.4.1)
 brotli           1.3.2     2025-03-18 [1] CRAN (R 4.4.2)
 cli              3.6.5     2025-04-23 [1] CRAN (R 4.4.3)
 codetools        0.2-20    2024-03-31 [1] CRAN (R 4.5.1)
 DBI            * 1.2.3     2024-06-02 [1] CRAN (R 4.4.1)
 digest           0.6.37    2024-08-19 [1] CRAN (R 4.4.1)
 evaluate         1.0.5     2025-08-27 [1] CRAN (R 4.4.3)
 fiery            1.3.0     2025-08-20 [1] CRAN (R 4.4.3)
 firesafety       0.1.0     2025-09-10 [1] CRAN (R 4.4.3)
 firestorm        0.1.0     2025-09-01 [1] CRAN (R 4.4.3)
 future           1.67.0    2025-07-29 [1] CRAN (R 4.4.3)
 getopt           1.20.4    2023-10-01 [1] CRAN (R 4.4.1)
 globals          0.18.0    2025-05-08 [1] CRAN (R 4.4.3)
 glue             1.8.0     2024-09-30 [1] CRAN (R 4.4.1)
 httpuv           1.6.16    2025-04-16 [1] CRAN (R 4.4.3)
 jsonlite         2.0.0     2025-03-27 [1] CRAN (R 4.4.2)
 knitr            1.50      2025-03-16 [1] CRAN (R 4.5.1)
 later            1.4.4     2025-08-27 [1] CRAN (R 4.4.3)
 lifecycle        1.0.4     2023-11-07 [1] CRAN (R 4.4.1)
 listenv          0.9.1     2024-01-29 [1] CRAN (R 4.4.1)
 magrittr         2.0.4     2025-09-12 [1] CRAN (R 4.4.3)
 mirai          * 2.5.1     2025-10-06 [1] CRAN (R 4.4.3)
 nanonext         1.7.1     2025-10-01 [1] CRAN (R 4.4.3)
 optparse       * 1.7.5     2024-04-16 [1] CRAN (R 4.4.1)
 otel             0.2.0     2025-08-29 [1] CRAN (R 4.4.3)
 palmerpenguins * 0.1.1     2022-08-15 [1] CRAN (R 4.4.1)
 parallelly       1.45.1    2025-07-24 [1] CRAN (R 4.4.3)
 pillar           1.11.1    2025-09-17 [1] CRAN (R 4.4.3)
 pkgconfig        2.0.3     2019-09-22 [1] CRAN (R 4.4.1)
 plumber        * 1.2.2     2024-03-26 [1] CRAN (R 4.4.1)
 plumber2       * 0.1.0     2025-09-22 [1] CRAN (R 4.4.3)
 promises       * 1.4.0     2025-10-22 [1] CRAN (R 4.4.3)
 purrr            1.1.0     2025-07-10 [1] CRAN (R 4.4.3)
 R6               2.6.1     2025-02-15 [1] CRAN (R 4.5.1)
 ragg             1.5.0     2025-09-02 [1] CRAN (R 4.4.3)
 rapidoc          9.3.4     2023-11-17 [1] CRAN (R 4.4.1)
 Rcpp             1.1.0     2025-07-02 [1] CRAN (R 4.4.3)
 reqres           1.0.0     2025-08-20 [1] CRAN (R 4.4.3)
 rlang            1.1.6     2025-04-11 [1] CRAN (R 4.4.3)
 routr            1.0.0     2025-08-21 [1] CRAN (R 4.4.3)
 roxygen2         7.3.3     2025-09-03 [1] CRAN (R 4.4.3)
 sessioninfo      1.2.3     2025-02-05 [1] CRAN (R 4.4.2)
 sodium           1.4.0     2024-12-16 [1] CRAN (R 4.4.2)
 stringi          1.8.7     2025-03-27 [1] CRAN (R 4.4.3)
 stringr          1.5.2     2025-09-08 [1] CRAN (R 4.4.3)
 svglite          2.2.2     2025-10-21 [1] CRAN (R 4.4.3)
 swagger          5.17.14.1 2024-06-28 [1] CRAN (R 4.4.1)
 systemfonts      1.3.1     2025-10-01 [1] CRAN (R 4.5.1)
 textshaping      1.0.4     2025-10-10 [1] CRAN (R 4.4.3)
 tibble           3.3.0     2025-06-08 [1] CRAN (R 4.4.3)
 triebeard        0.4.1     2023-03-04 [1] CRAN (R 4.4.1)
 urltools         1.7.3.1   2025-06-12 [1] CRAN (R 4.4.3)
 vctrs            0.6.5     2023-12-01 [1] CRAN (R 4.4.1)
 websocket        1.4.4     2025-04-10 [1] CRAN (R 4.4.3)
 webutils         1.2.2     2024-10-04 [1] CRAN (R 4.4.1)
 xfun             0.54      2025-10-30 [1] CRAN (R 4.4.3)
 xml2             1.4.1     2025-10-27 [1] CRAN (R 4.4.3)

 [1] /opt/R/4.5.1/lib/R/library
 * ── Packages attached to the search path.
Ngôn ngữ chính
R
Star
119
Fork
17
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của posit-dev/plumber2

Tất cả issue của posit-dev/plumber2

Issue tương tự

Thêm issue về R

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.