Skip to content

[10SP] OpenCMW: Rework REST/ZeroMQ interface #365

Open
@frankosterfeld

Description

@frankosterfeld

The current cpp-httplib RestBackend implementation has severe issues that prevent it from scaling up to real-world usage as the primary interface of client->broker communication.
It uses a model where each get/set as well as every long-poll request occupies a thread in a cpp-httplib internal thread pool, where esp. long-poll requests easily exhaust the available threads and then make the server stop responding.

The current implementation of RestBackend being a ZeroMQ client talking to the broker as normal zmq creates unnecessary overhead. As the REST backend is central to real-world use in the near future, it should be as efficient as possible.

Thus, the following changes should be made:

  • Integrate RestBackend directly into Broker to avoid communication overhead, allowing to bind to a HTTP address analog to creating MDP/MDS endpoints, and handle HTTP connections inside the broker.
  • Avoid long-poll requests blocking resources and improve scalability: Move from a thread-based server to event-driven I/O, where the HTTP server socket is polled and connections are served with replies/subscription notifications similarly as it is done right now for ZeroMQ clients. As a first step, this will be probably single-threaded, but keep the option in mind to use a thread pool for the actual I/O.
  • Replace cpp-httplib with a suited replacement (probably nghttp2) to allows the aforementioned event-driven approach.
  • The backend must support HTTP/1.1, HTTP/2 and should support HTTP/3. (It should be evaluated whether HTTP/3 is worth the added complexity (QUIC vs. TCP))
  • Use the HTTP/2/HTTP/3 multiplexing support to use a single client->server connection for all of a client's subscriptions (instead of one connection per subscription).
  • Adapt the opencmw client REST client APIs (native and wasm) to support HTTP2/3/multiplexing.
  • Create a basic load test that allows to test the broker with the number of clients expected from production (10s-100s of clients), each subscribing to a few topics and using get/set commands.

Further requirements:

  • Existing MDP/MDS and HTTP1.1 clients should continue working.
  • External dependencies should be minimal (mostly OpenSSL)
  • Replacing the HTTP library should be as easy as possible. Optional: Consider a design where multiple backends could be supported in parallel/via compile-time switch.
  • Do not implement but keep in mind: WebSocket support

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

🏗 In progress

Relationships

None yet

Development

No branches or pull requests

Issue actions