limiting grpc memory usage

398 views
Skip to first unread message

amandee...@gmail.com

unread,
May 26, 2022, 2:52:14 PM5/26/22
to grpc.io
We have a mechanism to limit the memory used by a process. To make sure that there are no violators, we rely on maxrss of the process. We check maxrss every few mins to see if we had seen a spike in memory which was beyond the permitted value.

We have a grpc server and what we are seeing is that for a request with 4MB of payload, the maxrss of the process is becoming slightly greater than 8MB. This limits our effective memory utilization to just half in most of the scenario without violating the memory limit. My guess it that this is because grpc is not zero copy. Is there a way to make grpc zero copy? If not, is there a way to limit the spike in memory when multiple requests come in? 

amandee...@gmail.com

unread,
Jun 6, 2022, 2:42:26 PM6/6/22
to grpc.io
So, we identified that it might be because of CodedInputStream::ReadStringFallback in protocol buffers.
We do not reserve the buffer upfront and use string's append repeatedly for some reason. This leads to a string capacity of 8MB for a 4MB string.

Any pointers would be helpful.

AJ Heller

unread,
Jun 13, 2022, 9:41:21 PM6/13/22
to grpc.io
Which gRPC library are you using? And which language? C++, Java, Python, etc

naser neno

unread,
Jul 31, 2022, 8:14:18 AM7/31/22
to grpc.io
hlo
Reply all
Reply to author
Forward
0 new messages