las2peer
las2peer copied to clipboard
[ENH] Asynchronous Requests
- Motivation - Since we have a peer to peer microservice infrastructure, several Web requests stacked together lead into long waiting times.
Request processing on the server works by default in a synchronous processing mode, which means that a client connection of a request is processed in a single I/O container thread
https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/async.html
- Specification - I played around with it a little bit and can confirm that requests are handled synchronously. We should enable async functionality at the webconnector. I also tried to use described functions:
@GET
public void asyncGet(@Suspended final AsyncResponse asyncResponse) {
new Thread(new Runnable() {
@Override
public void run() {
String result = veryExpensiveOperation();
asyncResponse.resume(result);
}
private String veryExpensiveOperation() {
// ... very expensive operation
}
}).start();
}
But they lead to 500 errors with no logs. Although using jersey 2.35 it won't work. Could be worth exchanging the HTTP Server with a modern solution? https://github.com/rwth-acis/las2peer/blob/master/webconnector/src/main/java/i5/las2peer/connectors/webConnector/WebConnector.java#L421-L425 and https://github.com/rwth-acis/las2peer/blob/master/webconnector/src/main/java/i5/las2peer/connectors/webConnector/WebConnector.java#L455-L460
At least it worked when I tried the GrizzlyHttpServerFactory.createHttpServer(...)
, but this would need some small adjustments
- Finalised state - Asynchronous functions as described in 2 should work.
@lakhoune @fxjordan @FBasels @phil-cd does one of you know a better HTTP Server that we should use? At the moment the WebConnector uses JdkHttpServerFactory