-
Notifications
You must be signed in to change notification settings - Fork 8
Reimplement REST interface using HTTP/2, HTTP3 #371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8c9e077
to
ea54134
Compare
ea54134
to
7c0e266
Compare
7c0e266
to
67440f0
Compare
Instead of using the httplib-based HTTP server using blocking I/O in a thread per client, implement a nghttp2-based HTTP/2 server, using single-threaded non-blocking I/O directly integrated into the Broker zmq_poll() loop. Signed-off-by: Frank Osterfeld <[email protected]>
Implements HTTP/3 support in the server, following the implementation in ngtcp2's server.cc example. A lot of the function logic and structure from there has been preserved for easier debugging and comparing to the example if needed. Signed-off-by: Frank Osterfeld <[email protected]>
Use CRTP to prepare for a Http3ClientSession (not implemented yet). Signed-off-by: Frank Osterfeld <[email protected]>
Signed-off-by: Frank Osterfeld <[email protected]>
HTTP GET is majordomo Get, HTTP PUT/POST is majordomo Set, GET with "LongPollingIdx" query parameter retrieves cached NOTIFY messages, we don't need more at the moment. Signed-off-by: Frank Osterfeld <[email protected]>
a234878
to
e715d22
Compare
Replace hardcoded paths with cmake variables. Since these are also used in the upstream project, otherwise compilation will fail if they have a different value than what was hardcoded. (lib vs lib64) Signed-off-by: Alexander Krimm <[email protected]>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this big improvement. We did some real-world testing and it improved a lot of long-standing issues, thanks a lot 👍
There are still some small issues and we have to rethink how to handle dependencies, but this can be tackled in individual small PRs.
PR #371 introduced that long polling subscriptions would always fetch the next n (defaulted to 3) long polling indices to reduce the latency from roundtrip to single trip. For the happy path this works well, but in case of errors, the logic has to be improved to correctly handle responses arriving out of order. With the current logic this will re-fetch already received updates and lead to avalanches of requests, as these re-fetched requests will then also again arive out of order and refetch old data. Before increasing this value again, it should be ensured that the responses are either re-sorted on arrival or older updates correctly dropped without scheduling new requests. This change restores the behaviour from before the changes but keeps the logic in place so it can be reenabled after fixing the error-handling. Signed-off-by: Alexander Krimm <[email protected]>
PR #371 introduced that long polling subscriptions would always fetch the next n (defaulted to 3) long polling indices to reduce the latency from roundtrip to single trip. For the happy path this works well, but in case of errors, the logic has to be improved to correctly handle responses arriving out of order. With the current logic this will re-fetch already received updates and lead to avalanches of requests, as these re-fetched requests will then also again arive out of order and refetch old data. Before increasing this value again, it should be ensured that the responses are either re-sorted on arrival or older updates correctly dropped without scheduling new requests. This change restores the behaviour from before the changes but keeps the logic in place so it can be reenabled after fixing the error-handling. Signed-off-by: Alexander Krimm <[email protected]>
Implements a new REST interface using HTTP/2, for lower latency and multiplexing of multiple requests on a single connection.
Instead of multithreading + blocking I/O, where each (long-poll) client occupies a thread, using event-driven non-blocking I/O, and poll() the HTTP-related sockets (server socket and client connections) together with the ZMQ sockets. For that, integrate the server more closely with the Broker.
The HTTP/3 implementation has been tested manually using Chrome and curl (see README) but is not covered by unit tests yet, as the native HTTP/3 client implementation would be considerable effort (and probably some more kloc's of code...). As agreed upon with @RalphSteinhagen , the native client might be done later possibly with other libraries like libcurl/CPR that require less code than ngtcp2, given that the client side is not the performance-critical part.