GO请求后端为什么这么慢

michael_xu · · 2788 次点击
怎么慢法?QPS和RT能到多少?服务器端什么实现?技术问题不应该只提供情绪和感受吧?
#2
更多评论
```go package main import ( "fmt" "time" "net/http" ) var netClient = &http.Client{} func init() { tr := &http.Transport{ MaxIdleConns: 100000000, MaxIdleConnsPerHost: 100000000, } netClient = &http.Client{Transport: tr} } func R(logid string){ timer_1 := time.Now().UnixNano() _, err := netClient.Get("http://127.0.0.1:8080/profile/encrypt?keys=1") timer_2 := time.Now().UnixNano() fmt.Println(logid, ((timer_2 - timer_1)/1000000), "ms", err) } func main() { for n := 0; n <= 500; n++ { //time.Sleep(time.Microsecond * 2) go R(fmt.Sprintf("%d-%d",n, time.Now().UnixNano())) } time.Sleep(15 * time.Second) } ```
#1
代码都贴上了,你可以测试一下啊。
#3