nginx lua与go的ab压力测试hello world

测试机器 4核8G服务器 ab运行在内网另外一台服务器上面 

nginx lua代码    4个worker进程

server {
    listen 80;
    server_name 10.10.155.58;
    root /app/www/10.10.155.58;
    access_log /app/nginx/logs/10.10.155.58.log;
    error_log /app/nginx/logs/10.10.155.58_error.log;
    index index.html;

    location / {
        content_by_lua '
                ngx.say("hello world")
            ';   
    }

}

测试结果

go代码

package main

import (
    "io"
    "log"
    "net/http"
    "sync"
)
var m *sync.RWMutex

func HelloServer(w http.ResponseWriter, req *http.Request) {
    m.RLock()
    io.WriteString(w, "hello world\n")
    m.RUnlock()
}

func main() {
    m = new(sync.RWMutex)
    http.HandleFunc("/", HelloServer)

    err := http.ListenAndServe(":8080", nil)

    if err != nil {
        log.Fatal("ListenAndServer: ", err.Error())
    }
}

猜你喜欢

转载自blog.csdn.net/bestmover/article/details/81739868