问题描述
我故意运行长达60秒我的服务器上,每个运行之间的延迟一个PHP脚本。问题是,向服务器发送任何其他请求而在脚本执行被延迟,直到脚本完成。
I am intentionally running a php script that last up to 60 seconds on my server with a delay between each run. The issue is that any other requests sent to the server while the script is executing are delayed until the script finishes.
反正是有线(?)PHP允许Apache将采取需要的PHP脚本运行时的请求?
Is there anyway to 'thread'(?) php to allow apache to take requests that require php while the script is running?
推荐答案
Apache和PHP将被默认为许多并发连接就好了。我要一刺到黑暗和猜测,你是的启动会话。默认的会话处理程序是基于文件,并且将获得的会话文件的独占锁定,以阻止那些试图使用同一个会话文件中的所有并发请求。你拿去 session_write_close
做长时间运行的任务之前关闭会话一>
Apache and PHP will by default serve many concurrent connections just fine. I'll take a stab into the dark and guess that you are starting a session. The default session handler is file based, and will acquire an exclusive lock on the session file, which blocks all concurrent requests that try to use that same session file. Close the session before you go off doing long-running tasks with session_write_close
.
这篇关于PHP执行时间造成响应延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!