在生产服务器上启用XDebug是否会使PHP变慢? [英] Will enabling XDebug on a production server make PHP slower?

查看:87
本文介绍了在生产服务器上启用XDebug是否会使PHP变慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题几乎说明了一切……这是一个坏主意吗?我想要XDebug在服务器上提供的增强调试消息.

The title pretty much says it all...is it a bad idea ? I'd like to have the enhanced debug messages that XDebug provides on the server.

只是为了弄清楚.我知道其中涉及安全风险.也许我应该补充我的问题,并给出为什么要这样做的更确切的原因.

[edit] Just to make things clear. I'm aware there are security risks involved. Perhaps I should complement my question and give more precise reasons why I would want to do this.

我们的生产服务器还托管一个测试平台.有时,我们使用它来在尽可能接近生产环境的环境中测试事物.我要寻找的主要内容是使用XDebug的增强型var_dump().

Our production server hosts a testing platform also. Sometimes we use it to test things on a environment as close to production as possible. The main thing I'm looking for is using XDebug's enhanced var_dump().

这不是用于高流量应用程序的应用程序服务器,性能也不是什么大问题.我只是想知道XDebug是否会显着影响性能.

This is not an app server for high traffic apps and performance is not that big of an issue. I was just curious if performance would be noticeably impacted by XDebug.

此外,我想我只能为定义测试站点的VirtualHost启用它.

Besides, I guess I could enable it only for the VirtualHost that defines the testing sites.

推荐答案

除了显而易见的事实,即调试消息无法在已经投入生产的应用程序中显示,而且我不知道为什么要这么做那有几件事真的很糟糕.

Besides the obvious fact that debug messages cannot be displayed in a application that is already in production, and also the fact that I don't know why would you like that, there a couple of things really bad about it.

第一个是,当您向服务器中添加调试行为时,调试引擎会附加"到PHP进程,并接收该引擎的消息以在断点处停止,这就是BAD,因为这会对性能造成严重的打击.让另一个进程停止或保留" PHP解析器.

The first one is that when you add debugging behavior to your server, the debug engine "attaches" to the PHP process and receive messages of the engine to stop at breakpoints, and this is BAD, because introduces a high performance blow to have another process stopping or "retaining" the PHP parser.

另一个大问题是,当安装调试器时,至少大多数调试器倾向于在服务器中打开端口,这是讨厌的习惯,因为它们不适合生产环境,并且您可能知道,在服务器中打开端口的软件为周围的所有黑客打开了一扇门.

Another big issue is that when a debugger is installed, at least most of them, they tend to have the nasty habit of opening ports in your server, because they are not intended for production environments, and as you may know, any software that opens ports in your server is opening a door for any hacker around.

如果您需要在代码中进行调试,则在您的应用程序中实施一个调试系统(如果不可用),因为大多数框架都是内置的.请设置配置值,例如DEBUG_ENABLED,并在引发异常时进行设置,如果是如果未启用,请重定向到一个小页面,否则将重定向到一个带有调试信息的丑陋页面,但请务必注意您在服务器中显示的调试信息. 我希望这可以澄清一切.

If you need to have debugging in your code, then in your application, implement a debugging system, if is not available, since most frameworks have this built in. Set a configuration value, say DEBUG_ENABLED and when throwing exceptions, if is not enabled, redirect to a petty page, else to a ugly page with debugging information, but take good care of what debugging information you display in your server. I hope this clarifies everything.

编辑,显然我的回复记录不足,因此您应该检查这些来源

EDIT As apparently my response is not documented enough, you should check these sources

  • PHPs XDebug tracing overhead in production
  • Careful: XDebug can skew your performance numbers

最后,我没有说一件事,因为我认为那是隐性的:不这样做是常识!您不会将调试工具放在生产服务器上的原因与将调试工具放在不同环境中的原因相同,因为您需要避免不必要的东西.在服务器上运行的任何进程,无论它多么轻,都会影响您的性能.

Finally, there is one thing I didn't said as I thought it was sort of implicit: It's common sense not do it! You don't put debugging instruments on your production server for the same reason that you keep them on a different environment, because you need to keep unnecessary stuff away from it. Any process running on a server, no matter how light it is, will impact your performance.

这篇关于在生产服务器上启用XDebug是否会使PHP变慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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