D
It's worth an example. In one of the processors, we sent a request for OBD. The OBD processed it for five seconds.app.get('/syncRequestForTest', function(req, res){ // сервер может принять и обработать один запрос в 5 секунд.
let user = yourDB.users.findSync({_id: req.data.id}) // у нас очень много данных БД, поэтому БД обрабатывает такой запрос 5 секунд.
req.send(user)
}
app.get('/other', function(req, res){ // сервер не может обработать этот запрос, пока он занят синхронными вычислениями.
...
}
In this example, the programme will wait five seconds for the OBD response. For five seconds, it cannot process other requests, which is not acceptable in the sale.If the request is asynchronous, other requests can be processed at the time of the response from the OBD server:app.get('/asyncRequestForTest', async function(req, res){ // сервер может принимать сотни таких запросов в секунду.
let user = await yourDB.users.findAsync({_id: req.data.id}) // у нас очень много данных БД, поэтому БД обрабатывает такой запрос 5 секунд.
req.send(user)
}
app.get('/other', function(req, res){ // сервер может обработать этот запрос, пока где-то снаружи основного потока приложения выполняются асинхронные задачи.
...
}
Usually, the asynchronous approach is used to request side-by-side programmes (fetch, browser, reading and recording of files, OBD queries). Because these requests are usually relatively long and do not load resources (all of which the annex is waiting) and suspend the entire application (e.g. server) while the file is being read to process one of the requests, it is unacceptable.Here. https://www.baeldung.com/cs/async-vs-multi-threading with pictures describe the difference between synchronous and asynchronous performance, as well as multiplicity.Here. https://habr.com/ru/post/337528/ explaining the difference between these approaches.Here. https://ru.stackoverflow.com/questions/445768/%D0%9C%D0%BD%D0%BE%D0%B3%D0%BE%D0%BF%D0%BE%D1%82%D0%BE%D1%87%D0%BD%D0%BE%D0%B5-vs-%D0%B0%D1%81%D0%B8%D0%BD%D1%85%D1%80%D0%BE%D0%BD%D0%BD%D0%BE%D0%B5-%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5 where there are many good examples of the difference between multi-point, asynchronicity, synchronization and competition.I memorize the answer here:Multi-point programming implies that the annex code
is performed in different flows. Like, there's a major flow of UI, and
several workflows that perform heavy calculations,
the results of which are then released to UI.Asynchronous programming involves some initiation
The operation that the main flow will find out after some time.
time. Usually, this is used to work with the introduction system:
disk, network, etc. But if it's done right, no.
No flow. Also often under the expression "to fill asynchronous"
imply that some code will not be implemented in
the current flow, and the next one, with no current flow
locked. But I think it's not entirely correct.Parallel programming means the separation of one task
independent sub-tasks that can be calculated in parallel and then
combine results. One example is map-reduce. It's private.
Multi-point programming.