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

查看:376
本文介绍了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秒.四十八半秒!这太不可思议了!这可能是什么原因?这是常见的操作,为什么执行时间这么长?如何解决这种行为,要编辑哪些配置?通过Google搜索,但没有找到好的答案(几乎到处都有问题,但没有答案).谢谢你!

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()函数内部运行.也许您所做的事情可以保留许多旧的会话文件,例如更改了最长生存时间?或者,也许您已经决定将它们存储在数据库中是个好主意,但是却忘记创建合适的索引了吗?本机GC例程stat()的每个会话文件都要检查是否到期.如果建立了很多文件,这很费时间.

My guess would be the garbage collection routine, which gets run inside of the native session_start() function. Maybe you've done something that keeps many old session files around, like changed the max life time? Or maybe you've decided it would be a good idea to store them in a database, but forgot to create a suitable index? The native GC routine stat()'s every single session file to check for expiration. This is time consuming if there's a lot of files built up.

编辑:为了帮助您仅用于调试,请通过临时设置

edit: to help you for debugging only, disable garbage collection by temporarily setting session.gc-probability:

session.gc-probability = 0

确保设置不变,我不知道zend框架在这里可能在做什么.

Make sure the settings stick, I don't know what the zend framework might be doing here.

P.S.不知道原因就很难提出修复建议.我的回答旨在指导您确定原因.

P.S. It's difficult to suggestion a fix without knowing the cause. My answer is meant to guide you towards identifying the cause.

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

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