日期:2014-05-17  浏览次数:20512 次

会是什么原因导致session_start启动慢。
PHP首次启动session_start非常慢。(等好几分钟)


客户端有生成PHPSESSID COOKIE后访问速度就恢复正常。
把PHPSESSID COOKIE删除后打开又很慢了,当首次打开完成生成PHPSESSID后又恢复正常。

就这么两行代码:
<?php

session_start();
phpinfo();

?>

会是什么原因导致session_start首次启动这么慢? 
排查了很多的地方没找到原因……

------解决方案--------------------
首次 ???
再次吧?
------解决方案--------------------
没遇到过,多用几个浏览器测试看看。
------解决方案--------------------
4.6 min?...内牛满面....
------解决方案--------------------
不知道这文章能解决你问题否:
http://www.aiyiweb.com/operating-system/501202.html
------解决方案--------------------
引用手册上的,不知道对不对题目
引用
There are some posts around about session_start() beeing terribly slow on ntfs. for me the problem occured from one day to another, system was already running fine for 2 years.
to get around it implementing a custom session_set_save_handler could be an option, although for me it worked just to put a session_write_close() somewhere near the end of my script. (maybe IIS didn't kill the php-threads fast enough?!) 

------解决方案--------------------
继续手册上与“slow”相关的:

A note on Windows installations with an NTFS file structure:

Make sure you give your Internet user account (usually IUSR_MACHINENAME) "Modify" access to the session.save_path directory.  Otherwise session_start() will silently - and oh, so slowly - fail.

("Modify" is a Win2k term, but the concept translates to older IIS installs). 
------解决方案--------------------
引用:
PHP首次启动session_start非常慢。(等好几分钟)


客户端有生成PHPSESSID COOKIE后访问速度就恢复正常。
把PHPSESSID COOKIE删除后打开又很慢了,当首次打开完成生成PHPSESSID后又恢复正常。

就这么两行代码:
<?php

session_start();
phpinfo();

?>

会是……

同样的代码我在linux下测试没有这个状况.
所以你该考虑得问题应该是windows的问题,而不是php的问题.
------解决方案--------------------
如果你用linux出现这个问题的话,那么比较简单了,安装一个mrtg检测一下CPU,IO,磁盘,内存等等的使用状况就好了,这样你就能通过这个值了解到究竟是哪里导致此问题的发生.
------解决方案--------------------
重编译下或者换个版本?