Last active
February 2, 2016 21:52
-
-
Save tailhook/e15b4908f09b4b61805f to your computer and use it in GitHub Desktop.
rotor-http vs proxygen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./httpserver/samples/echo/echo_server -http_port 3000 -ip 127.0.0.1 -threads 1 | |
proxygen a994f4a6f | |
> wrk -c 100 -d 60 -t2 http://localhost:3000 | |
Running 1m test @ http://localhost:3000 | |
2 threads and 100 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 3.53ms 588.05us 23.71ms 94.84% | |
Req/Sec 14.28k 1.36k 16.88k 56.67% | |
1706482 requests in 1.00m, 182.27MB read | |
Requests/sec: 28423.86 | |
Transfer/sec: 3.04MB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/proxygen/httpserver/samples/echo/EchoHandler.cpp b/proxygen/httpserver/samples/echo/EchoHandler.cpp | |
index 3390505..15aee8c 100644 | |
--- a/proxygen/httpserver/samples/echo/EchoHandler.cpp | |
+++ b/proxygen/httpserver/samples/echo/EchoHandler.cpp | |
@@ -36,9 +36,7 @@ void EchoHandler::onBody(std::unique_ptr<folly::IOBuf> body) noexcept { | |
void EchoHandler::onEOM() noexcept { | |
ResponseBuilder(downstream_) | |
.status(200, "OK") | |
- .header("Request-Number", | |
- folly::to<std::string>(stats_->getRequestCount())) | |
- .body(std::move(body_)) | |
+ .body("Hello World!") | |
.sendWithEOM(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> wrk -c 100 -d 60 -t2 http://localhost:3000 | |
Running 1m test @ http://localhost:3000 | |
2 threads and 100 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 1.76ms 493.33us 15.30ms 95.66% | |
Req/Sec 28.84k 3.84k 34.05k 71.83% | |
3443682 requests in 1.00m, 367.82MB read | |
Requests/sec: 57384.95 | |
Transfer/sec: 6.13MB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/examples/hello_world_server.rs b/examples/hello_world_server.rs | |
index 76818ed..9d5be4a 100644 | |
--- a/examples/hello_world_server.rs | |
+++ b/examples/hello_world_server.rs | |
@@ -6,7 +6,7 @@ extern crate time; | |
use rotor::Scope; | |
use rotor_http::status::StatusCode::{self, NotFound}; | |
-use rotor_http::header::ContentLength; | |
+use rotor_http::header::{ContentLength, Date, HttpDate, Connection}; | |
use rotor_stream::{Deadline, Accept, Stream}; | |
use rotor_http::server::{RecvMode, Server, Head, Response, Parser}; | |
use rotor_http::server::{Context as HttpContext}; | |
@@ -47,6 +47,8 @@ enum HelloWorld { | |
fn send_string(res: &mut Response, data: &[u8]) { | |
res.status(StatusCode::Ok); | |
res.add_header(ContentLength(data.len() as u64)).unwrap(); | |
+ res.add_header(Date(HttpDate(time::now()))).unwrap(); | |
+ res.add_header(Connection::keep_alive()).unwrap(); | |
res.done_headers().unwrap(); | |
res.write_body(data); | |
res.done(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment