debonair
debonair

Reputation: 2593

gRPC cpp synchronous vs asynchronous server performance

I understand the differences between sync and async server however I am wondering if have these 2 cases, which one would be more performant async or sync?

  1. Sync: Write call will be blocking till message is ready to be sent on the wire from the internal completion queue. Async : write call immediately returns and we need to wait on completion queue. In Sync server what if we add queue which basically populated for evry Write call and other thread draining it and doing stream.write then performance will be same?

  2. Sync: gRPC internally creats threadpool with threads equal to number of CPUs Async: threading is upto implementation. So if for each client if we create separate thread and completion queue, would the performance wil be same for sync and async?

Upvotes: 0

Views: 1630

Answers (1)

drfloob
drfloob

Reputation: 3274

It's difficult to compare performance theoretically. As a rule of thumb, if your choices are between letting gRPC handle concurrent calls internally in a way it's designed to handle, vs managing gRPC call concurrency yourself with the sync API, chances are gRPC internals will be better tuned for performance than you can manage yourself. There may be exceptions to that advice, depending on many variables ... for example, if the server is doing something very fast and inexpensive and the messages are small, the sync API might be fine.

In the end, benchmarks are your friends.

gRPC performance advice: https://grpc.io/docs/guides/performance/#c

The official gRPC benchmarks (under development): https://performance-dot-grpc-testing.appspot.com/explore?dashboard=5180705743044608. The tests that underly those benchmarks may be informative in your design choices.

Upvotes: 2

Related Questions