B
B
Bur Ov2021-12-23 22:38:07
PHP
Bur Ov, 2021-12-23 22:38:07

Why is the server giving out more data than expected in the API?

Good afternoon. The essence of the question is this. Let's say there is an API (PHP\mysqli), there is a request in which the user specifies his key and makes a request. For 1 request, 0.3r is removed from its balance and some information is issued from the database, when the balance is 30r, the user runs this request 100 times simultaneously (in 100 threads) and the API should, in theory, issue information only 100 times and the balance should end, but it gives then 120-160 successful requests and only then the balance ends.
As I understand it, the server processes several requests in 1 second and does not have time to update the balance in the database? How then to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2021-12-23
@burov0798

Read what a "race condition" is and study database locks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question