I have a fwrite function to write log for delay insert to the database.
We have a visit rate of 20,000 Visits per hour.
so it’s 0.18s per fwrite.
My question is that is it possible that PHP will miss several log when there are 2 or 3 visitor come in at the same time?
If it’s then how can I make this concurrent?
My code is just normal Fopen fwrite fclose.
I would avoid this if I was you. If you must log something for each request, either use something like Gearman to queue the data for later processing, or store it in a database (or a NoSQL db) for later processing. Don’t forget that databases were designed to solve this very problem. Don’t try to re-invent a db using log files.
Not to mention that 0.18s per write is likely a lot more expensive than an insert into a DBM (MySQL for me typically returns writes inside of 0.01 seconds, depending on the table, MongoDB can be a LOT faster).