Answer the question
In order to leave comments, you need to log in
PHP. How to implement a shared counter between multiple scripts?
Several daemons (endless php loops) are constantly running on a dedicated server + new ones are periodically launched + several scripts on the crown.
To implement some algorithm, it is necessary to use a common counter for each script/process while they are running. For example:
Answer the question
In order to leave comments, you need to log in
For example, like this: php.net/manual/en/memcached.increment.php
I tried to maintain the value in the file - at some points the value is simply not read and everything goes astray (I could not figure out the reason)most likely a banal blocking of an open file.
I'm afraid to use a database (MySql), because the calls will be very frequent and the frequency is growing.well, I don't know, requesting an indexed field from the database takes about 0.0013 seconds on my not the most powerful machine, + non-blocking updates. In production, there are machines processing up to ~ 100 requests per second. Another thing is that this is shooting sparrows from a cannon.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question