Improve flow control on sender side (pre-requisite for credit-based flow control)

Summary: Currently, a sender worker will keep all open requests (and optionally up to a certain number of total open requests) in its own memory. This behavior may cause high memory usage in sender side. Also, since messages can arrive to a worker at an arbitrary rate, receiver may not have the ability to handle all incoming messages, hence we may see a large memory footprint in receiver as well. This diff addresses the problem by limiting the number of open requests per worker in sender side. Also, it provides a cache of unsent requests on sender in case the sender already sent enough messages to another worker but has not received any response back.

Test Plan: mvn clean verify

Reviewers: avery.ching, sergey.edunov, maja.kabiljo, dionysis.logothetis

Reviewed By: dionysis.logothetis

Subscribers: Alessio

Differential Revision: https://reviews.facebook.net/D43797
8 files changed