N
N
nepster-web2014-07-11 03:03:57
PHP
nepster-web, 2014-07-11 03:03:57

How does the server react to the execution of bold scripts?

I'm doing a game project where you need to work with the user structure. Namely:
The first thing you need is a user structure. That is, players invite other players and a large nesting tree appears. For example, the user base will be 1,000,000 users.
The best option is to use nesting tree technology such as nested set. But even so, recalculating keys on such a structure takes a long time (several seconds). In addition to this, I need to distribute bonuses to entire structures. That is, if a player invited another player, and he made a certain achievement, you need to give bonuses to all higher players (parent elements of the current one).
From here it turns out that the script that gives out bonuses, for example, runs for 20 seconds, and as the structure of users increases, its time grows a little. That is, when a user, for example, has made an achievement, you need to run a 20-second script that will get all his ancestors, give them bonuses, write down the history, in general, arrange everything as it should.
Here I had such a question: what will happen if we run the script for one player, and during its execution it will be necessary to run the script for several more users. Well, or let's say it will come to the point that the processing of one player will take 20 seconds, and it will be necessary to process 10 players per minute.
What will happen in such a situation? Will the whole site slow down?
Let me clarify a bit what we are dealing with. Everything is written in Yii2 and with such actions a console command is called. Another 1 example with which there will be a problem is with the recalculation of keys. For example:
- the user is registered, I start up the console command "Update the structure", for example, the keys are updated for 5 seconds.
- what will happen if several users register at the same time? Will the keys be placed correctly?
In general, the main essence of the question is, how does the server, php and database respond to several requests in a row, while executing all these scripts?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Deerenaros, 2014-07-11
@nepster-web

The main problem will be only with the record. That is, when using traditional SQL, you can shoot yourself not only in your legs, but also in your head with one movement of your hand, suddenly discovering the consequences of dirty, phantom and other readings .
In terms of performance, a normal server runs at least on processes (cgi-bin), so everyone gets at least an equal share. In other words - if the server drags, then the delays will be (if any) very small. Asynchronous magic - the CPU waits most of the time, not splits the numbers, from here the pipeline will be able to build the chain more efficiently, and so on.
Well, then. 10 seconds per million users. Lot. Too much. Yes, and about a million, comrade, you are lying.

M
Mikhail Osher, 2014-07-11
@miraage

The numbers are taken from the ceiling. The hailod tag is generally out of place here. Author's fantasy.
*presses complain button*

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question