0

There is a little long background story about the problem in my socket reactive library working process.

The socket library mainly based on a reactive library named Monix(similar ReactiveX). Monix has the best practice to handle back-pressure by Ack(extends Future) type which emits the next message when the current message has been processed. It's a good mechanism to protect the system for large message rushed.

Currently design, every socket connection is an Observable( or Stream), the Observable will create a protocol message when TCP/IP network bytes stream is parsed, and then, push the protocol message to Subscriber.

The problem is Monix library only could do back-pressure for every Observable. If you consider there are thousands of client connected there cloud be so many Observable and back-pressure is meaningless.

So, how to design a back-pressure mechanism for such reactive system in terms of a global system other than a single Observable?

Thanks

Paras Korat
  • 2,011
  • 2
  • 18
  • 36
LoranceChen
  • 2,453
  • 2
  • 22
  • 48
  • why close the question? Is there has exist same problem or not clearly enough? – LoranceChen Apr 20 '19 at 14:02
  • My first guess would be to have `Observable[Observable[Request]]` as your core type, where the outer observable emits one inner `Observable` for each requester (or each IP address), and the inner `Observable` then describes the communication with that single client. – Markus Appel Apr 24 '19 at 07:35
  • For this question to receive a meaningful answer, though, you will need to provide code examples. Check [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) on the Help Center. – Markus Appel Apr 24 '19 at 07:37
  • Thanks @MarkusAppel. `Observable[Observable[Request]]` is a good point to do back-pressure, could you make a detail for how to limit Request counts to achieve back-pressure? and Sorry for I haven't find a good way to expression so many code in the library. I will give a refine code example if get it. – LoranceChen Apr 24 '19 at 15:05
  • For rate limiting you can simply `zip` your `Observable[Request]` with an `Observable.interval(...)` and ignore the right part of the resulting tuple. [Here's an example](https://scalafiddle.io/sf/DrNswZX/2). – Markus Appel Apr 24 '19 at 15:23

0 Answers0