Edgewall Software

Ticket #3481 (closed defect: fixed)

Opened 2 years ago

Last modified 22 months ago

Tracd HTTP response is very slow in windows between PCs.

Reported by: JoneyWu@… Owned by: cboos
Priority: high Milestone: 0.10.1
Component: web frontend/tracd Version: 0.9.6
Severity: normal Keywords: slow network
Cc:

Description

When I installed the trac in standalone way, I found it is very slow to response to browser. But this case only appear in connection from another PC. It means if I access the trac in the local machine, the speed is normal (about 0.0x seconds). I have traced the Trac code and found that: it is fine with good speed in handling the request but stuck in "send_response" step. This situation will add extra 12 seconds cost to response to the browser. Maybe is the IO/Network issue?

e.g. from my trac log-- "19:45:49 Trac[standalone] DEBUG: Total request time: 12.032000 s"

Attachments

Change History

  Changed 2 years ago by cboos

  • status changed from new to closed
  • resolution set to worksforme
  • milestone 0.9.7 deleted

The standard python HTTPServer used by TracStandalone will log each client request. While doing this, it tries to resolve the client's numerical IP address to a fully qualified name. You probably don't have a DNS server correctly setup in your environment, hence the slow down.

So either fix that (preferred solution) or, if it's not an option, apply the following patch (hack):

Index: trac/web/standalone.py
===================================================================
--- trac/web/standalone.py	(revision 3387)
+++ trac/web/standalone.py	(working copy)
@@ -249,6 +249,16 @@
         self.wfile = None
         self.rfile = None
 
+    def address_string(self):
+        """Return the client address formatted for logging.
+
+        This version doesn't look up the full hostname using
+        gethostbyaddr() ...
+        """
+
+        host, port = self.client_address[:2]
+        return host
+
     def do_POST(self):
         self._do_trac_req()
 

(patch on stable, something similar could be done on trunk; the method is added to the TracHTTPRequestHandler class)

  Changed 22 months ago by caoyanlong@…

  • status changed from closed to reopened
  • resolution worksforme deleted

Trac 0.10 release has same issue.

env:

os: windows 2003 & sp1 python: 2.4.3 standalone mode, tracd -s -d -a...

Browse it in local host will be very quick as my old trac 0.9.5. But it will very very slow from another PC in 100M LAN. It costs >60s!

  Changed 22 months ago by anonymous

In version 0.10, the following patch does the trick to disable dns reverse lookups (against trac/web/wsgi.py):

--- orig/wsgi.py 2006-11-06 10:36:11.991122600 -0700 +++ wsgi.py 2006-11-06 10:35:16.820306900 -0700 @@ -121,6 +121,9 @@

class WSGIRequestHandler(BaseHTTPRequestHandler):

+ def address_string(self): + host, port = self.client_address[:2] + return host

def setup_environ(self):

self.raw_requestline = self.rfile.readline()

  Changed 22 months ago by caoyanlong@…

  • status changed from reopened to closed
  • resolution set to fixed

thanks a lot. It is ok!

  Changed 22 months ago by eblot

  • status changed from closed to reopened
  • resolution fixed deleted

follow-up: ↓ 7   Changed 22 months ago by eblot

  • status changed from reopened to closed
  • resolution set to worksforme

(no change committed to the Trac base code)

in reply to: ↑ 6   Changed 22 months ago by cmlenz

  • status changed from closed to reopened
  • resolution worksforme deleted
  • milestone set to 0.10.1

Replying to eblot:

(no change committed to the Trac base code)

… meaning this issue is still open!

  Changed 22 months ago by cmlenz

Oops, I missed Christians response to this :-P

In any case, I think we should disable reverse lookups in tracd to get rid of this problem. I don't see any value in reverse lookups and pretty much every web server I know has them disabled by default. Plus, tracd is meant for being run either for development, or behind a HTTP proxy.

  Changed 22 months ago by cboos

  • owner changed from all to cboos
  • status changed from reopened to new

Well, I'm all for disabling reverse lookups there, choose your patch ;)

  Changed 22 months ago by cmlenz

  • status changed from new to closed
  • resolution set to fixed

Fixed in [4161].

Add/Change #3481 (Tracd HTTP response is very slow in windows between PCs.)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.