Skip to content

Grpc transfer big data, one unary call is slower than streaming. #1080

@LiBingtao

Description

@LiBingtao

I'm trying to transfer a big data between two services using grpc.

The data size is about 23M and is composed by 42 big List.

Then I test the performance using one unary call vs server side streaming(stream one list at a time).

The unary call takes 276.59 ms.

The streaming call takes 126.64 ms.

But if I change the data to contains 1000 small list, each list just have one number, the streaming call is much more slower than unary call.

Is the result normal? And Why?

Here is the server side code:

public override Task<MemDtoToWbs> GetLargeMEM(Empty request, ServerCallContext context)
{
    return Task.FromResult(MemData.GrpcLargeMem);
}
public override async Task StreamLargeMem(Empty request, IServerStreamWriter<LogDtoToWbs> responseStream, ServerCallContext context)
{
    foreach (var log in MemData.GrpcLargeMem.Logs)
    {
         await responseStream.WriteAsync(log);
    }
}

I use the .net core 3.1 and grpc nuget package 2.32.0.
Run test in aks cluster
image

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions