Process multiple concurrent requests and store in DB

2

I am dealing with a new problem due to some new challenges that I prostrate ...

I have developed a registration system and obviously in the future it may come to have more than 100 registrations per day or even per hour or second. Thinking about it, I did a test on different pcs and did the registration at the same time using the two pcs, what happened was, the pc1 requisition stored but the pc2 not requisition.

I would like help with how I can queue and then process the requests, if they are more than 1 at a time ...

I use jQuery to send the PHP form and DB is mysql.

In PHP code, is the normal code to insert data into a DB with PDO

JS Code

    $.post("https://servidor/pasta/codigo.php", {
        nome: $nome,
        idade: $idade
}, function(dado){
      $("#msg").html("Inserido com sucesso");
})

Hugs and thanks in advance

    
asked by anonymous 22.02.2015 / 13:37

1 answer

1

What you said does not make much sense, the server, depending on your configuration , can "serve" hundreds / thousands of concurrent requests. If you are using apache for example, the MaxClients directive speaks the following:

  

The MaxClients directive sets the number of concurrent requests that will be served.   When this total is reached, the surplus connection will join a queue, the size of that queue can be configured by the ListenBacklog directive.

The fact that two clients make a simultaneous request to the server is not a problem. If this happens, the server will create another process that will be responsible for processing.

The issue is, unless both scripts perform disk operations that require a lock (which is not your case), there is no synchronization technique that should be performed.

There are cases where it is necessary for transactional issues of the database to make a special treatment to prevent data from breaking integrity (which is also not the case following your example).

The problem in question is very broad, maybe it's a problem in your test, who knows. The question I wanted to demonstrate in this text is almost certainly not a synchronization problem unless your server is misconfigured.

    
22.02.2015 / 17:30