How to create multiple TCP connections in C++ grpc

333 views
Skip to first unread message

hao jiang

unread,
Apr 10, 2022, 1:10:58 AM4/10/22
to grpc.io
Hi,

I have an application which retrieves data from service. `iperf` shows download throughout for one single TCP connections is only 20MBps, but the requirement is 100MBps.

I tried `iperf` with 10 TCP connections (`iperf -c <IP port> -P 10`), and it shows the bandwidth could be 100MBps. So I want to use multiple TCP connections.

I use grpc to transfer data. I know
- grpc leverages HTTP/2, which natively supports IO multiplexing, but the limitation for my application is TCP b/w, so have to use multiple TCP connections
- `channel` is the abstraction which represents TCP connection
- `stub` is for client use. So it should be possible to have multiple stubs sharing one single `channel`

My way of doing it is
 

      grpc::ChannelArguments args;
      args.SetInt(GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL, 1);
      std::shared_ptr<Channel> channel(grpc::CreateCustomChannel(
          ip_port, grpc::InsecureChannelCredentials(), args));
      stub_ = NewStub(channel);

But from `ss`, I only see a few TCP connections created.

    > ss -antp | grep 443 | wc -l
    3

And not all of them are from my program.

My question is: how to create multiple TCP connection in grpc in C++?

Thank you!
Reply all
Reply to author
Forward
0 new messages