I'm the maintainer of the TodoBackend project, assembling a shared set of examples on how to build a basic web API in different tech stacks. As of today we have 28 implementations in everything from node.js to Prolog (yes, really!). But we don't have any examples showing how to use Rust to build HTTP APIs
Happily, this is where you can help. Creating a TodoBackend implementation is pretty straight-forward. If you know the tech stack you're working with it's a few hours of work which will become a nice reference implementation for future developers. On the other hand if you're not super familiar with building web APIs using Rust this is a great toy problem to use as a way to build experience. Don't feel that you need to be a Rust guru to contribute; a working example of any sort is a great way to get the ball rolling.
There's more information on contributing an implementation here. The basic process is to use a standard set of web-based specs which run against your implementation. Getting the tests to pass one at a time will guide you through the implementation process one step at a time, sort of like a coding kata.
I'm standing by to help in whatever way I can - just ask! Looking forward to having a few interesting Rust implementation up on todobackend.com soon.
There's a big problem when it comes to Rust and HTTP servers: there is no non-blocking I/O in the stdlib yet.
As far as I know, there are two HTTP servers today: hyper and tiny-http (most people only know hyper, but I want to illustrate a point).
The former chose the road for maximum performances and uses callbacks, which doesn't take advantage of Rust's borrow checker and has the consequence of producing non-idiomatic Rust code like this. Iron and nickel use hyper and have the same problem.
The latter provides a more idiomatic API but is consequently slower (6ms response time vs 50ยตs for hyper, and 60k requests/sec for a "hello world" vs 80k for hyper).
So what do we do? Use fast but non-idiomatic Rust code? Use slow but idiomatic code? I'd be in favor of waiting for non-blocking I/O to finally reach the stdlib.
Hello, How do you got 80k req/s with hyper? In apache benchmark I can reach only 3,5k in a Core I5 Dual Core running: Paste.ee It is so slow that I can easly reach this mark in interpreted langs like python. Thank you.