GO请求后端为什么这么慢

michael_xu · · 2847 次点击
90design
狗狼都是神
<a href="/user/saberuster" title="@saberuster">@saberuster</a> 666 楼主竟然跑起来了
#5
更多评论
```go package main import ( &#34;fmt&#34; &#34;time&#34; &#34;net/http&#34; ) var netClient = &amp;http.Client{} func init() { tr := &amp;http.Transport{ MaxIdleConns: 100000000, MaxIdleConnsPerHost: 100000000, } netClient = &amp;http.Client{Transport: tr} } func R(logid string){ timer_1 := time.Now().UnixNano() _, err := netClient.Get(&#34;http://127.0.0.1:8080/profile/encrypt?keys=1&#34;) timer_2 := time.Now().UnixNano() fmt.Println(logid, ((timer_2 - timer_1)/1000000), &#34;ms&#34;, err) } func main() { for n := 0; n &lt;= 500; n++ { //time.Sleep(time.Microsecond * 2) go R(fmt.Sprintf(&#34;%d-%d&#34;,n, time.Now().UnixNano())) } time.Sleep(15 * time.Second) } ```
#1
怎么慢法?QPS和RT能到多少?服务器端什么实现?技术问题不应该只提供情绪和感受吧?
#2