msgpack-rpc has two major benefits: asynchronous arch & multi language support, which makes it a good candidate for our use case.
https://github.com/msgpack-rpc/msgpack-rpc-java but its java implementation has some drawbacks, namely, the busy waiting Future implementation & its wasteful tcp pipeline. using its own test case, we could verify both points, and the average transaction time was around 300 micros, which does seem to have some overhead (expecting it closer to 100 micros)
For #1 we could use the new spring reactor or similar to replace its current eventloop to provide truly asynchronous transport based on Consumer, or Stream.
For #2, reactor-tcp also provides some nice way of handling the pipeline, the major waste was sort of a limitation of msgpack’s unpacker or buffered unpacker, both required the buffer to be ready. that’s contradictory with the input’s streaming design, the outcome is that, the unpack could fail, multiple times before the buffer could be parsed to an actual Value (Request). That forces the reset of buffer, and retries of the procedure when more bytes arrive. This requires a better Unpacker in the end, which could consume the buffer partially, stop only when have to, which happens everywhere according to https://github.com/msgpack/msgpack/blob/master/spec.md
- insufficient bytes to get all raw bytes
- insufficient bytes to parse string
- insufficient bytes to parse all primitives (boolean, numbers)
- insufficient bytes to get array length
- insufficient bytes to parse array element (recursively)
- insufficient bytes to get map length
- insufficient bytes to parse map element (recursively)
the ideal Unpacker doesn’t have to return the unpacked Value (synchronously), itself could be a Consumer of the buffer, which holds till the entirety of the Value gets parsed, and then pass on to the next Consumer, in rpc case, an rpc invoker. Then the rpc invoker should hold to the tcp connection and send the result when it’s fulfilled, for our use case, the result type isn’t likely to be streamable, and I don’t have the urge to apply the same as the Unpacker to the Packer for the output stream.
Reactor is an interesting project, still evaluating its performance, and would like to get a comparison with Akka, whether java or scala runtime.