drryyiuib43562604 2019-03-12 13:46
浏览 179

gRPC服务器通过以太网的响应时间长

I was testing client-server connection with gRPC client written in C# and a bunch of servers (written in c++, C#, rust and go). As I was testing it locally everything went okay (average GO response around 0.12ms) but when I test it over local network it gets really slow, like REALLY slow. Average time goes to 40ms per request! To be clear: I am using a simple HelloWorld proto with simplest connection possible. Other servers get about 1ms per request but Go - around 40ms.

My Go server code:

 package main

import (
    "context"
    pb "descriptions"
    "log"
    "net"

    "google.golang.org/grpc"
)

type server struct{}

// SayHello implements helloworld.GreeterServer
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
    //log.Printf("Received: %v", in.Name)
    return &pb.HelloReply{Message: ""}, nil
}

func main() {
    //  lis, err := net.Listen("tcp", port)
    lis, err := net.Listen("tcp", "0.0.0.0:50051")
    if err != nil {
        log.Fatalf("failed to listen: %v", err)
    }
    s := grpc.NewServer()
    log.Printf("Server listening on: " + lis.Addr().String())
    pb.RegisterGreeterServer(s, &server{})
    if err := s.Serve(lis); err != nil {
        log.Fatalf("failed to serve: %v", err)
    }
}

I do not suspect that it is client side issiue because it works well with other servers. Have anyone had the same issiue with golang? Please let me know! I was also thinking if that might be like HTTP 1.1 issue but gRPC supports HTTP2 so I suspect it is already used when running this code.

  • 写回答

1条回答 默认 最新

  • dphfwzn8269 2019-03-13 18:26
    关注

    According to the benchmark here, Go and C++ shouldn't have such big difference (over ethernet). Could you please file an issue in the grpc-go repo, https://github.com/grpc/grpc-go/issues/new? And it will be very helpful if you can provide more context about how client side works. Thanks!

    评论

报告相同问题?

悬赏问题

  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复