lundi 23 août 2021

How efficiently process requests in Clojure?

I'm a beginner in Clojure and I am interested in how to efficiently process requests. As a node.js developer, I use an event loop (promises/callback/async-await) to access the database to efficiently process user requests, which means the main thread won't be blocked and I can process another user's requests without waiting for a DB response. How I can efficiently process user request in Clojure if I make a request to the database, that means my thread would be blocked and I can't process any others users? Should I create a new thread for each user to efficiently process requests? I know that I can use futures in Clojure to create a new thread, but how can I use it for example with one request to DB, if create a new thread my main thread will be blocked to wait for a children thread which requests the database, don't understand how futures can help me in this situation. What is the best practice or maybe servers such as jetty provide better processing out of the box? I would be very grateful if you can help me in this matter




Aucun commentaire:

Enregistrer un commentaire