Async Not Required 🦀

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 พ.ย. 2024

ความคิดเห็น • 16

  • @caelis512
    @caelis512 ปีที่แล้ว +12

    Thanks for the video. While I agree with the conclusion (often async is not necessary), the benchmarks are a bit misleading. As long as no I/O bound things are executed (like DB access, network access or file access) and only CPU bound things (json serialization), async brings no performance advantage. ... So a (more realistic) benchmark where each request executes a DB call (which takes 50ms) would be interesting.

  • @jcbritobr
    @jcbritobr ปีที่แล้ว

    Very nice framework. I like minimalistics to embed in other devices. Will read about rouille

  • @clintonbowen
    @clintonbowen ปีที่แล้ว +1

    TIL wrk! This was great!
    is there an analog for this for the C10k problem in rust?

    • @timClicks
      @timClicks  ปีที่แล้ว

      The source code for wrk is here, btw: github.com/wg/wrk/
      The C10k problem is actually less of a problem these days because operating systems are much faster than they used to be. There's no special case needed for Rust.

  • @johnwilliams7999
    @johnwilliams7999 ปีที่แล้ว

    struct JamJar { volume: Oz }

  • @avalagum7957
    @avalagum7957 ปีที่แล้ว +1

    Is Async not needed because that library converts a struct to a json string too fast? What will happen if we sleep for 500ms in each request? I really want to try it by myself but my Rust level is not enough to write such a simple Rust file 😞

    • @timClicks
      @timClicks  ปีที่แล้ว

      The latency is impacted much more than the throughput, although the picture is unclear from short benchmarking runs.
      If you sleep for 500ms in each request, it severely impacts performance using the benchmarking system that we're using.
      If you increase the concurrency parameter, you can still easily reach 1000 reqs/sec though, e.g. `wrk -t 4 -c 1000 localhost:10000`.

    • @avalagum7957
      @avalagum7957 ปีที่แล้ว

      @@timClicks Then in real life, we still need async/reactive or virtual/green thread (like in the Java project Loom) as each request will need to talk to the db or other services. (i.e. each request needs about 2-300ms to finish). Is that correct? If yes, what's Rust solution for serving a lot of requests which spend more time in waiting than in computing stuff?

    • @timClicks
      @timClicks  ปีที่แล้ว

      No, not necessarily. That's the point of the video. In the case that you're accessing a backend service, such as a database, your thread will simply block and consume no resources.
      If you're convinced by the async model, then I recommend frameworks that are build on top of the Tokio project, such as Axum and Actix Web.

    • @abhibhagat7767
      @abhibhagat7767 ปีที่แล้ว

      @@avalagum7957 the thumb rule is to use async programming for something that can block (io) and thread programming for something that needs the cpu (computations)

    • @nubunto
      @nubunto 11 หลายเดือนก่อน

      If the thread blocks, it can no longer serve requests, right?