3

I found a very interesting post on self hosted Rust apps, they look good.

I am interested on how to host it in a web server like IIS, or is it impossible at the moment?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Juan Carlos
  • 490
  • 5
  • 17
  • 1
    Just create a Rust application that behaves like any other kind of binary that IIS could execute. This has been possible for decades with technologies like CGI or FastCGI. – Shepmaster May 29 '16 at 18:12
  • 1
    That's right, you do an app that implements either HTTP, FastCGI or SCGI (https://crates.io/crates/scgi) protocol, then you point the ISS to that app's HTTP (http://stackoverflow.com/questions/34684711/iis-reverse-proxy; http://stackoverflow.com/questions/26947595/iis-reverse-proxy-to-node-js), FastCGI or SCGI port. – ArtemGr May 29 '16 at 18:50
  • Ok! thank you very much, i will try it right away. – Juan Carlos May 29 '16 at 19:00
  • Gonna ask you guys. What's better? To do this, or to self host a rust web service? Is it mature enough for production? sorry if this is not the place to ask. – Juan Carlos May 30 '16 at 20:18

1 Answers1

3

Yes, it is possible to host a Rust application in IIS.

I used the same approach used to host Suave applications in IIS and it worked.

On IIS the key is to read the port where IIS expects your application to listen

let port = match env::var("HTTP_PLATFORM_PORT") {
    Ok(val) => val,
    Err(e) => "6767".to_string(),
};

I created a small crate iis to make it easier to use in a real Rust application like here for Nickel

let port = iis::get_port();
let listen_on = format!("127.0.0.1:{}", port);
server.listen(listen_on);

I believe this would be mature enough for production exactly the same way self hosted Rust app given HttpPlatformHandler and IIS are mature and stable.

I also did some very basic and unscientific performance tests on the Free App Service plan in Azure and got stable roughly 60 hits per second with avg. response time 100-200 ms.

davidpodhola
  • 1,030
  • 10
  • 17
  • Hi Juan, how it went for you? Also note SSL is supported in Azure so https://rust-nickel-azure-web-app.azurewebsites.net/ works as well. – davidpodhola May 09 '17 at 17:16
  • Hello David. Went well. Project didnt took off, but got some knowledge with me along the way. Can you share the rust test you deployed in azure? have you compared it to C# using similar test ? Thanks for your answers! – Juan Carlos May 09 '17 at 21:38
  • Hi Juan, sorry it took so long. In the meantime I [change the sample to run on Hyper](https://github.com/hsharpsoftware/rust-realworld-example-app/issues/27#issuecomment-302796569) and I am still getting the same results. Also did some basic tests to compare with C# and the results were the same, I think the Azure infrastructure is really cutting the throughput on Free. – davidpodhola May 27 '17 at 09:27
  • I see!! I had a win server box in my old laptop. But it just died right before I started testing. Will try on azure when I get some free time. Thanks a lot! – Juan Carlos Jun 04 '17 at 22:06
  • Azure does throttle bandwidth for low-end subscriptions. This has been my experience as well. – G S Jul 12 '18 at 00:54