Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

enabling xdebug remote debug makes apache server very slow

If I enable xdebug by settting xdebug.remote_enable=1, the apache server becomes very slow; once I change the setting to 0, it's normal.

I found a same question here: XDebug really slow, but the answer isn't helpful. I didn't enable profiling:

xdebug.profiler_enable=0 xdebug.auto_trace = 0 xdebug.trace_output_dir = /tmp/xdebug xdebug.trace_output_name = trace.%c 

I checked there's nothing under /tmp/xdebug folder.

When xdebug remote debug is enabled and I enable debug listening in PHPStorm, it takes a short while to stop at the breakpoint, but not as slow as disabling phpstorm debug listening.

My environment is: php + apache + xdebug on local centos VM, my mysql db and PHPStorm are on Windows desktop for development. MySQL is not slow.

Appreciate for help.

like image 757
Will-i-Am-Davidon Avatar asked Jul 19 '13 00:07

Will-i-Am-Davidon


People also ask

Does xdebug slow PHP?

Yes, debuggers like XDebug reduce the performance of the PHP server. This is the reason why debuggers are not placed in server environment.

What is xdebug Remote_host?

Xdebug is an extension for PHP to assist with debugging and development. It was determined that Xdebug is configured with xdebug. remote_connect_back option enabled as shown in the following example. xdebug.remote_enable= true xdebug.remote_connect_back= true xdebug.remote_host= 127.0.


2 Answers

In my case this was caused by having

xdebug.remote_autostart = 1 

set in php.ini. That causes xdebug to try to connect to remote debugger on every request. I had some PHP handled styles, auto_preppend_file and other PHP files in the request and for each of them it waited approximately 2secs, which added up to sth. like 15 seconds or so. Setting

xdebug.remote_autostart = 0 

solved the problem completely. xdebug connects only when debug cookie is present. Please note you need to remove the debug cookie/param if you are not in debug session for this fix to work.

Here is my config that I use to setup xdebug.

like image 81
Tomáš Fejfar Avatar answered Nov 11 '22 14:11

Tomáš Fejfar


Experienced also low performance with XDebug (loading Captcha in 6 seconds instead of milliseconds) Remarks on this page got me on the way to identify the cause.

Turned off the profiler and loading time was divided by 3. Still slow, but better already.

xdebug.profiler_enable = 0 
like image 38
user2992220 Avatar answered Nov 11 '22 14:11

user2992220