3 ms·
If you want to build a backend in Rust, Axum (which uses hyper underneath) is pretty recommended these days, as it's all in the tokio ecosystem. Actix Web is go
by satvikpendem 4y ago
If you want to build a backend in Rust, Axum (which uses hyper underneath) is pretty recommended these days, as it's all in the tokio ecosystem. Actix Web is good too, but it has its own ecosystem of libraries. I read the book Zero To Production in Rust [0] which was a great overview on not just Rust but scalable backend architectures as a whole.
Interestingly, Cloudflare wanted to use hyper but found that it was too correct, so they had to build their own [1].
[0] https://www.zero2prod.com https://www.zero2prod.com
[1] https://blog.cloudflare.com/how-we-built-pingora-the-proxy-that-connects-cloudflare-to-the-internet/#design-decisions https://blog.cloudflare.com/how-we-built-pingora-the-proxy-t...
- cschneid 4y agoWhat's the current state of database access? Last I looked a while back Diesel was really cool, but didn't play nice w/ Async.
- satvikpendem 4y agoI use Prisma Client Rust [0], coming from the Node.js world, it works great. Some people like to use sqlx though, I'm not too big into writing SQL for every little thing. [0] https://github.com/Brendonovich/prisma-client-rust https://github.com/Brendonovich/prisma-client-rust
- phaer 4y agoHaven't used it myself, but https://github.com/SeaQL/sea-orm https://github.com/SeaQL/sea-orm seems to be popular in some communities and async
- lwhsiao 4y agoSQLx [1] is commonly recommended. It has the nice feature that your queries can be verified at compile time. [1]: https://github.com/launchbadge/sqlx https://github.com/launchbadge/sqlx
- mattrighetti 4y agoThe first time I used SQLx I was completely blown away by this. It’s an incredibly useful feature that I’ve never seen before and now I’m actually spoiled by it! The only downside is that you have to install sqlx-cli and you have to run a couple of special commands to make your binary compile offline or on CI/CD where you don’t provide that database connection.
- Spartan-S63 4y agoDiesel now has an official async adapter: https://crates.io/crates/diesel-async https://crates.io/crates/diesel-async
- telios 4y agoI've used diesel async for personal projects, and while it does work seamlessly with diesel at times, there are some rough edges - I ran into an odd issue where the order of imports from the base diesel package and diesel async mattered, and it would compile with one above the other, but not the other way around.
- davidatbu 4y agoI've also used with diesel async for personal projects, and I have ran into no rough edges at all, fwiw.
- redman25 4y agoAsync is not necessarily as useful for database connections since connection counts will generally be in the 10s and handled with a thread pool. It's pretty low overhead to just use pooling.
- unshavedyak 4y agoYea but you still want a good async interface if you're already using async, even if it's mocked over an underlying threadpool. Otherwise you have to wrap all your DB clients in your own adhoc async wrappers which feels kinda bad, imo.
- laurencerowe 4y agoIt’s frustrating there seems to be no good threaded web server for Rust given how uniquely great Rust is at threading. You can adapt from async to sync but there is a definite complexity tax with all the pinning plus the runtime cost of the extra pinning. Async is great for more proxy like use cases though.
- laurencerowe 4y ago*runtime cost of the extra copying.
- tele_ski 4y agoWe interestingly ran into issues with actix and the AWS lb. The lb takes some liberty with how it handled connections and actix seems to be "to the spec" so we were seeing a lot of dropped connections. Placing nginx between the two resolved the issue but it's fairly disappointing that we need that layer when it should be unnecessary overhead. I'd love to give axum a try if we could find time and see if it behaves better.
- infogulch 4y ago> lb takes some liberty with how it handled connections Interesting, I'm curious about the details here. Does the lb reuse connections for multiple requests or something?
- scottlamb 4y ago> Interesting, I'm curious about the details here. Does the lb reuse connections for multiple requests or something? I'm curious too. There must be more to it than that because LBs reusing backhaul connections is standard practice. It's not only an optimization but in many cases you'll quickly hit ephemeral port exhaustion if you don't. TCP connections are distinguished by (src_ip, src_port, dst_ip, dst_port) tuple. For this leg you're probably only varying the src_port portion, and all of the valid options are cooling in time_wait state.
- skywal_l 4y agoI tried warp [0] and I am unimpressed so far. Pretty complex, limited documentation, buggy. The builder paradigm they used feels pretty constrained and, in my opinion, achieve the opposite of the simplicity it is supposed to bring. I was surprised it is so popular. Maybe I need more time or a favorable comparison to another framework to appreciate it. [0] https://github.com/seanmonstar/warp https://github.com/seanmonstar/warp
- satvikpendem 4y agoNot sure why you used warp, it's not really recommended by anyone these days for Rust backends. Try Actix Web or Axum, both have decent documentation and even online courses on YouTube, which is how I mainly learned them.
- dcormier 4y agoWe used warp originally, and ended up refactoring to axum. We’ve been much happier with it.