Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /
Document Length: 11 bytes
Concurrency Level: 1000
Time taken for tests: 446.730 seconds
Complete requests: 5000000
Failed requests: 0
Write errors: 0
Total transferred: 595000000 bytes
Total body sent: 735000000
HTML transferred: 55000000 bytes
Requests per second: 11192.44 [#/sec] (mean)
Time per request: 89.346 [ms] (mean)
Time per request: 0.089 [ms] (mean, across all concurrent requests)
Transfer rate: 1300.68 [Kbytes/sec] received
1606.73 kb/s sent
2907.41 kb/s total
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 44 29.5 42 3044
Processing: 3 45 10.6 44 814
Waiting: 1 33 8.4 31 813
Total: 10 89 30.8 85 3103
Percentage of the requests served within a certain time (ms)
50% 85
66% 91
75% 96
80% 99
90% 108
95% 115
98% 124
99% 129
100% 3103 (longest request)
[package]
name = "rust"
version = "0.1.0"
authors = ["vagrant"]
edition = "2018"
[dependencies]
env_logger = "*"
futures = "0.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
json = "*"
actix = "0.7"
actix-web = "^0.7"
use actix_web::{
http, middleware, server, App, Json, Result,
};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
struct Obj {
value: i32,
}
fn index(info: Json<Obj>) -> Result<Json<Obj>> {
Ok(Json(Obj{ value: info.0.value + 1 }))
}
fn main() {
::std::env::set_var("RUST_LOG", "actix_web=info");
env_logger::init();
let sys = actix::System::new("json-example");
server::new(|| {
App::new()
.middleware(middleware::Logger::default())
.resource("/", |r| r.method(http::Method::POST).with(index))
}).bind("127.0.0.1:8080")
.unwrap()
.shutdown_timeout(1)
.start();
println!("Started http server: 127.0.0.1:8080");
let _ = sys.run();
}
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /
Document Length: 11 bytes
Concurrency Level: 1000
Time taken for tests: 452.459 seconds
Complete requests: 5000000
Failed requests: 0
Write errors: 0
Total transferred: 670000000 bytes
Total body sent: 735000000
HTML transferred: 55000000 bytes
Requests per second: 11050.73 [#/sec] (mean)
Time per request: 90.492 [ms] (mean)
Time per request: 0.090 [ms] (mean, across all concurrent requests)
Transfer rate: 1446.09 [Kbytes/sec] received
1586.38 kb/s sent
3032.48 kb/s total
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 43 42.2 41 3062
Processing: 8 47 13.3 46 249
Waiting: 2 32 12.2 31 245
Total: 29 90 42.9 86 3114
Percentage of the requests served within a certain time (ms)
50% 86
66% 93
75% 97
80% 100
90% 109
95% 117
98% 125
99% 131
100% 3114 (longest request)
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
type Obj struct {
Value int32 `json:"value"`
}
func main() {
r := gin.Default()
r.POST("/", func(c *gin.Context) {
var obj Obj
if err := c.ShouldBindJSON(&obj); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, Obj{Value: obj.Value + 1})
})
r.Run() // listen and serve on 0.0.0.0:8080
}