In the case of high concurrency, multiple clients request to write to the same file at the same time, which may cause file locking, resulting in write conflicts and data loss. Therefore, you need to use file locking(flock) when writing files to ensure that only one process is reading or writing to the file at a time to avoid data conflicts. The timeout setting is to prevent the occurrence of deadlock. If a process fails to obtain a file lock but does not release the lock when the timeout time expires, the timeout processing is needed to prevent other processes from waiting and blocking. The timeout setting can effectively avoid the long waiting time of the process and improve the concurrent performance of the program. Even if client1 has not finished within the timeout period, client2 can continue writing to files after the timeout without having to wait.