L
L
loker2017-01-19 18:50:47
Computer networks
loker, 2017-01-19 18:50:47

Node.JS Express. Simultaneous requests, an opinion is required. How to be?

I describe my problem that haunts me.
In general, I make 2 POST requests with the same data at the same time.
The server logic is such that the data in the request is unique. As a result, when sending two requests, no error occurs - this is not normal behavior, in my opinion, since both requests were successfully completed. Next, I did a sleep for 10 milliseconds, and everything began to work fine.
My concern is, is it possible to send n-th number of simultaneous requests from different users and how to prevent the same data from getting into the database?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
rustler2000, 2017-01-20
@loker

Физически не возможно принять два и более запроса одновременно.
Физически не возможно в одном инстансе ноды одновременно их принять из сокета.
Как правильно написали - в очередь, или базу точить (фактически база будет очередью).

Виталий, 2017-01-19
@vitali1995

Думаю, нужно использовать очереди. Обрати внимание на RabbitMQ

Александр Бубликов, 2017-01-19
@bublik462

Куда они записываются ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question