Slow response to database write from php

好久不见. 提交于 2020-01-15 12:16:05

问题


I have my PHP scripts running on the WAMP server. Here's what i am doing

  1. 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 )
  2. Based on the result set I execute a tcl script for each row of the result set
  3. The TCL script takes about a minute to execute , it also inserts some data to the same database
  4. 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
  5. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!