I faced a mention of "half-sync/half-async" template in context of tuning performance of three tier application (front-end - backend-server - db):
One way to multi-thread a OLTP back-end database server is to create a thread pool based on the “half-sync/half-reactive” variant of the Half-Sync/Half-Async pattern.
I've read an article about "half-sync/half-async" pattern. The pattern was explained there via example:
//Represent synchronous layer
public class AsciiArtGenerator {
// Convert image to ASCII, long term operation
public boolean convertToAscii(String imgPath, String outPath) {..}
}
// Represents an asynchronous layer, as it forwards client requests for further
// processing and returns immediately. It receives results via notifications.
public class NonBlockingDispatcher {
//Sends a request to the queue and returns instantly.
public void dispatch(final String imgPath, final String outPath) {..}
//Captures processing result and notifies the subscribed client
public void onResult(boolean result) {..}
}
That use case appears very unconvincing to me.
Questions:
- Why just don't use AJAX / promises on client side (I suppose it's on JS)?!
- When do we need
NonBlockingDispatcherat all? - May you provide some more use cases from web development?
Aucun commentaire:
Enregistrer un commentaire