Thank you Kannan,

I think you are saying that the multi-threaded nature is for handling 
parallel streams of communication, but a single stream will be handled in a 
way that ensure it is serialized correctly?

Is my understanding correct?

On Thursday, November 27, 2025 at 12:15:48 AM UTC-8 Kannan Jayaprakasam 
wrote:

> Saying gRPC server is multi-threaded is a vague statement. At the 
> transport level all messages from a stream are handled by the same 
> transport thread. When dispatching deframed messages from a stream to the 
> application, gRPC dispatches messages to the StreamObserver implemented by 
> the application via the call executor (that can be supplied to the Grpc 
> server builder). It is here that different messages could be handled by 
> different threads in the call executor. The code supplied to the call 
> executor however is a wrapper code that calls the StreamObserver in a 
> serialized 
> manner 
> <https://github.com/grpc/grpc-java/blob/02e98a806d4738a113519115d55fc242243e98d6/core/src/main/java/io/grpc/internal/ServerImpl.java#L842>
>  
> by serializing them in the call's *Context*. This makes sure that 
> different messages from the same stream are still handled in the received 
> order. 
> Note: The above answer elucidates using Java but the idea will be similar 
> in other languages.
>
> On Thu, Nov 27, 2025 at 3:56 AM Rocha Stratovan <[email protected]> 
> wrote:
>
>> Hello,
>>
>> I am working with a gRPC server implementation that receives a streamed 
>> binary file.
>>
>> I understand that the gRPC server is multi-threaded and so the "receive" 
>> callback can be invoked by by multiple threads at the same time.
>>
>> How is order maintained in this scenario? I thought I saw that gRPC also 
>> guarantees order, implying that the 3rd gRPC message in a stream won't be 
>> processed before the 2nd or 1st.
>>
>> Thank you,
>>
>> John Rocha
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "grpc.io" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion visit 
>> https://groups.google.com/d/msgid/grpc-io/24a2a141-1700-4df9-bd23-72a866b73872n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/grpc-io/24a2a141-1700-4df9-bd23-72a866b73872n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/grpc-io/91aabeb4-1bf3-422d-9353-a6d24b2c92abn%40googlegroups.com.

Reply via email to