问题
I have my PHP scripts running on the WAMP server. Here's what i am doing
- PHP script A that queries the database and gets a set of rows (I have set the set_time_limit (0) // unlimited time for the script to execute )
- Based on the result set I execute a tcl script for each row of the result set
- The TCL script takes about a minute to execute , it also inserts some data to the same database
- Now simultaneously when the TCL script is executing , if i execute another PHP script that writes in to the database , I am not able to do it as the response time is too slow. It infact waits for the PHP script A/TCL script to complete
- However during this time, reads from the database is fine and quick
Does anyone has any suggestions ?
Regards, Mithun
回答1:
A Session cannot be shared by concurrent scripts. Any new requests which try to session_start()
will hang at this point waiting for the previous script end.
As your script is taking undetermined time to end, its a good idea to session_write_close()
right after obtaining all information it needs from the $_SESSION superglobal, so concurrent requests won't hang anymore.
来源:https://stackoverflow.com/questions/1316054/slow-response-to-database-write-from-php