Will enabling XDebug on a production server make PHP slower?

后端 未结 11 1420
孤独总比滥情好
孤独总比滥情好 2020-11-28 12:47

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 c

相关标签:
11条回答
  • 2020-11-28 13:11

    Removing xdebug completely (even when it was not enabled) gave us 50% in page load boost (down from 60ms to 30ms). We had xdebug sitting "dormant" (waiting for trigger). We thought that since it's dormant it won't cause any harm, but boy were we wrong.

    We commented out the zend_extension line in the php config at around 21:43. Average load dropped from 0.4 to 0.2 per core as well:

    0 讨论(0)
  • 2020-11-28 13:12

    You should never keep that on production.

    Your application shoud never need to print out "those nice debug messages", as they are not nice at all to your users. They are a sign of poor testing and they will kill user's trust, especially in a enterprise/ecommerce environment.

    Second, the more detailed technical information you reveal, the more you are likely to get hacked (especially if you are already revealing that there ARE in fact problems with your code!). Production servers should log errors to files, and never display them.

    Speed of execution is your least concern, anyway it will be impacted by it, as will memory.

    0 讨论(0)
  • 2020-11-28 13:12

    You can use XDebug in production if you "do it right". You can enable the extension in a "dormant" mode that is only brought to live through requests that go through a specific HOSTS name. Se details here:

    http://www.drupalonwindows.com/en/content/remote-debugging-production-php-applications-xdebug

    0 讨论(0)
  • 2020-11-28 13:13

    Slow down by factor 4

    I made some tests just enabling the module, without actually debugging, makes slows down a request on my development machine from 1 second to around 4 seconds

    0 讨论(0)
  • 2020-11-28 13:18

    You could always clone your live server with the exactly same configuration, except that it wouldn't be public. Then you can install XDebug on it and debug things with the almost exactly the same conditions (well, load will be different between real life and the clone, but the rest will be the same). In that case you debug things on a live environment, but real live is not affected.

    Note: Obviously it does not apply to anyone. Not everyone can easily clone a server. If you use cloud services like AWS etc. it would be very easy. If you use server configuration tools like Ansible, Chef, Puppet for building your server this is a piece of cake as well.

    0 讨论(0)
提交回复
热议问题