session_start() 需要很长时间 [英] session_start() takes VERY LONG TIME

查看:58
本文介绍了session_start() 需要很长时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站运行非常缓慢(我不知道为什么).它是基于 Zend Application 的,我以前做过几十个这样的网站,所以我确定我的代码是没问题的.

Mys site works very slowly (and I didn't have any idea about why). It is based on Zend Application, I used to make about tens of such sites, so I'm sure that MY code is OK.

我在服务器上安装了 xdebugger,尝试对其进行分析并猜猜是什么?php::session_start() 耗时 48.675 秒.四十八秒半!这太不可思议了!这可能是什么原因?很普通的操作,怎么会执行这么久?如何解决这种行为,要编辑哪些配置?通过谷歌搜索,但没有找到好的答案(几乎到处都有问题,但没有答案).之前谢谢!

I installed xdebugger on server, tried to profile it and guess what? php::session_start() took 48.675 seconds. Fourty Eight and a Half Seconds! It's unbelievable! What could be the reason of this? It's common operation, why could it execute SO long? How to fix such behaviour, which configs to edit? Searched over Google, but found no good answer (almost everywhere there's a question, but no answer). Thanks in before!

推荐答案

session_start(会话存储在文件中)在 PHP 中被阻塞,因此如果您尝试启动多个服务器会话,则会出现此问题对于同一个浏览器会话(AJAX 或多个浏览器选项卡/窗口).每个 session_start 将等到其他会话关闭.

session_start (with sessions stored in files) is blocking in PHP, so this issue will appear if you try to start several server sessions for the same browser session (AJAX or multiple browser tabs/windows). Each session_start will wait until the other sessions have been closed.

见这里:http://konrness.com/php5/how-to-prevent-blocking-php-requests/

尝试从文件更改为会话的数据库存储.

Try changing from files to database storage of sessions.

这篇关于session_start() 需要很长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆