Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Short answer: 1) - no (but might be yes if db protocol itself requires previous command to complete before accepting next, this is the case for Mysql); 2) - no, from the user point of view they run in parallel</p> <p>Long answer:</p> <p>Imagine that your job is to accept phone calls from client and depending on question dispatch it to corresponding customer support (you have 10 3rd party services each with customer support line). All lines are quite busy and it takes several minutes until answer. Answer itself is usually short.</p> <h3>Scenario 1 (20 threads, thread pool):</h3> <p>You have 10 phone lines for incoming calls. You have 10 phone lines for outgoing calls. You receive incoming call, listen question and make outgoing call. "Please wait for the answer" to the client. In the meantime, you have 20 other lines in your hand, and before switching to check next line you ask client or support to wait.</p> <h3>Scenario 2 (no thread pool)</h3> <p>Same as scenario 1, but initially you have one outgoing line. If you have incoming call and you have outgoing line busy you ask all clients to wait and you go to phone company to arrange new line (create new thread).</p> <h3>Scenario 3 (async io, callbacks)</h3> <p>One line (= execution thread). You accept call, write down question and caller id and end call with "thank you for your question, I'll call you back in few minutes with answer" reply. You call you "async" customer support, but don't wait in a queue and instead just tell short message: "my id is xxx, the question is yyy" and end call. </p> <p>Each time you get reply (call back) from customer support you write it down, then lookup client id in the list of client questions, call client, tell him answer and discard the record with associations client id &lt;-> question &lt;-> answer. Each time you listen for client's question or call support to send question or receive answer or call client with answer - other clients wait in the queue. (You are blocking event loop), so for you it is important to use line as little time as possible, while support answer time is less important.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload