Skip to content

Instantly share code, notes, and snippets.

@gankkank
Last active August 29, 2015 14:14
Show Gist options
  • Save gankkank/3a59513ea81cb5ec5e33 to your computer and use it in GitHub Desktop.
Save gankkank/3a59513ea81cb5ec5e33 to your computer and use it in GitHub Desktop.

ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux-gnu]

go version xgcc (Ubuntu 4.9.1-0ubuntu1) 4.9.1 linux/amd64

Sinatra

require 'sinatra'
require 'thin'

set :logging, false
set :bind, '0.0.0.0'

get '/' do
  '{"message":"Hello, World!"}'
end

rake

module MySinatra
  class Application
    def self.call(env)
      new.call(env)
    end 

    def call(env)
      headers = { 'Content-Type' => 'text/plain' }
      if env['PATH_INFO'] == '/' 
        status, body = 200, '{"message":"Hello, World!"}'
      else
        status, body = 404, "Sinatra doesn't know this ... ! "
      end 
      headers['Content-Length'] = body.length.to_s
      [status, headers, [body] ]
    end 
  end 
end

require 'thin'
Thin::Server.start MySinatra::Application, 4567
package main

import (
    "github.com/astaxie/beego"
)

type MainController struct {
    beego.Controller
}

func (this *MainController) Get() {
    this.Ctx.WriteString("{\"message\":\"Hello, World!\"}")
}

func main() {
    beego.Router("/", &MainController{})
    beego.Run()
}

go net/http

package main

import (
  "io"
  "net/http"
  "log"
)

// hello world, the web server
func HelloServer(w http.ResponseWriter, req *http.Request) {
  io.WriteString(w, "{\"message\":\"Hello, World!\"}")
}

func main() {
  http.HandleFunc("/hello", HelloServer)
  err := http.ListenAndServe(":8080", nil)
  if err != nil {
    log.Fatal("ListenAndServe: ", err)
  }
}
@gankkank
Copy link
Author

go bee (http://beego.me/quickstart)

wrk -c 100 -d 30s http://172.31.39.36:8080

Running 30s test @ http://172.31.39.36:8080
  2 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   995.25ms  660.82ms   1.45s    68.38%
    Req/Sec     1.48k     2.56k   10.58k    81.44%
  91762 requests in 30.00s, 14.96MB read
Requests/sec:   3058.75
Transfer/sec:    510.79KB

wrk -c 300 -d 60s http://172.31.39.36:8080

Running 1m test @ http://172.31.39.36:8080
  2 threads and 300 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   865.13ms  792.31ms   1.69s    26.97%
    Req/Sec     1.50k     1.93k    8.66k    88.45%
  183025 requests in 1.00m, 29.85MB read
Requests/sec:   3049.92
Transfer/sec:    509.31KB

@gankkank
Copy link
Author

go net/http

wrk -c 100 -d 60s http://172.31.39.36:8080/hello

Running 1m test @ http://172.31.39.36:8080/hello
  2 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     4.19ms    2.05ms  17.31ms   62.16%
    Req/Sec    12.42k     0.93k   17.93k    68.48%
  1431059 requests in 1.00m, 196.53MB read
Requests/sec:  23851.70
Transfer/sec:      3.28MB

wrk -c 200 -d 60s http://172.31.39.36:8080/hello

Running 1m test @ http://172.31.39.36:8080/hello
  2 threads and 200 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     8.50ms    3.38ms  31.90ms   64.57%
    Req/Sec    12.04k   787.66    16.33k    71.06%
  1412680 requests in 1.00m, 194.00MB read
Requests/sec:  23544.91
Transfer/sec:      3.23MB

wrk -c 300 -d 60s http://172.31.39.36:8080/hello

Running 1m test @ http://172.31.39.36:8080/hello
  2 threads and 300 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    12.75ms    3.64ms  35.49ms   65.38%
    Req/Sec    11.97k   630.63    15.68k    69.78%
  1412432 requests in 1.00m, 193.97MB read
Requests/sec:  23542.80
Transfer/sec:      3.23MB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment