這是一個運行在Linux(CentOS我認爲)使用Python 2.6.6和Django 1.2.3的服務器。Django服務器100%cpu沒有明顯的原因
會發生什麼事是運行django的python進程突然開始使用100%cpu,直到它重新啓動。這只是最近才發生過兩次,而且在不到一個月前纔開始這樣做。我在大約7個月內沒有對代碼做過任何大的修改。
查看控制檯的輸出,它沒有任何極端的用法。在10分鐘內只有大約10個查詢導致我相信它開始使用100%cpu。打印出來的唯一錯誤是一個破損的管道錯誤,我想可能是某人在緩慢關閉連接後使用它。
我重新運行了所有查詢,這些查詢都是在它放緩的時候出現的,並且它們都工作得很好,沒有任何問題。
服務器本身在某種意義上仍然有效,但速度非常慢。我有一系列的測試,我每天運行他們通常需要7分鐘左右,但是當它的速度變慢時,可能需要2-3小時。
如果有人有任何想法,我將非常感激。
另外,正如你可能會注意到,如果有人可以推薦一個關於如何監控這些活動的良好實踐,那麼當談到這些問題時,我是一個相當新手。
謝謝你的時間!
下面是我所提到的輸出,它開始100%的CPU時間是下午4點〜
[23/Jul/2012 15:49:55] "GET /CFXsearch/?n=&v=all&e=2012Week30&c=all&r=all&p=all&run=all&pl=all&m=all&o=all&d1=&d2=&submitOption=comparing&compareBy=plat&sort=sortName&Soft=CFX HTTP/1.1" 200 67228
[23/Jul/2012 15:50:00] "GET /CFXsearch/?n=&v=all&e=2012Week30&c=all&r=all&p=all&run=all&pl=RH5&m=all&o=all&d1=&d2=&submitOption=comparing&compareBy=plat&sort=sortName&Soft=CFX HTTP/1.1" 200 33346
[23/Jul/2012 15:50:05] "GET /CFXsearch/?n=&v=all&e=2012Week30&c=all&r=all&p=all&run=all&pl=SLES10&m=all&o=all&d1=&d2=&submitOption=comparing&compareBy=plat&sort=sortName&Soft=CFX HTTP/1.1" 200 33394
[23/Jul/2012 15:54:48] "GET /CFXsearch/?n=&v=all&e=2012Week30&c=all&r=all&p=all&run=all&pl=SLES11&m=all&o=all&d1=&d2=&submitOption=comparing&compareBy=plat&sort=sortName&Soft=CFX HTTP/1.1" 200 33394
[23/Jul/2012 15:54:53] "GET /results/?n=&e=2012Week30&c=TGTest&pl=SLES11&p=single&p=defined&p=double&run=default&run=hpmpi&run=mpich&run=mpich2&run=Platform&run=pvm%20parallel&run=serial&sort=sortResult&d=&y=&submitOption=latestsearch&Soft=CFX HTTP/1.1" 200 19350
[23/Jul/2012 15:54:57] "GET /results/?n=&e=2012Week30&c=turboexamples&pl=SLES11&p=single&p=defined&p=double&run=default&run=hpmpi&run=mpich&run=mpich2&run=Platform&run=pvm%20parallel&run=serial&sort=sortResult&d=&y=&submitOption=latestsearch&Soft=CFX HTTP/1.1" 200 36729
[23/Jul/2012 15:59:40] "GET/HTTP/1.1" 200 11111
[23/Jul/2012 15:59:40] "GET /site_media/style.css HTTP/1.1" 304 0
[23/Jul/2012 15:59:45] "GET /CFXsearch/ HTTP/1.1" 200 25637
[23/Jul/2012 15:59:45] "GET /site_media/jquery-1.2.6.min.js HTTP/1.1" 304 0
[23/Jul/2012 15:59:45] "GET /site_media/sorttable.js HTTP/1.1" 304 0
[23/Jul/2012 16:00:04] "GET /CFXsearch/?n=&v=14.5&e=all&c=solver54&r=all&p=all&run=all&pl=all&m=all&o=all&d1=&d2=&submitOption=comparing&compareBy=plat&sort=sortName&Soft=CFX HTTP/1.1" 200 402737
[23/Jul/2012 16:00:19] "GET /results/?n=&e=2012Week29&c=solver54&pl=SLES11&p=single&p=defined&p=double&run=default&run=hpmpi&run=mpich&run=mpich2&run=Platform&run=pvm%20parallel&run=serial&sort=sortResult&d=&y=&submitOption=latestsearch&Soft=CFX HTTP/1.1" 200 1557488
[23/Jul/2012 16:02:48] "GET /CFXsearch/?n=&v=14.5&e=all&c=solver54&r=all&p=all&run=all&pl=all&m=all&o=all&d1=&d2=&submitOption=comparing&compareBy=ex&sort=sortName&Soft=CFX HTTP/1.1" 200 408388
[23/Jul/2012 16:03:01] "GET /CFXsearch/?n=&v=14.5&e=all&c=solver54&r=all&p=all&run=all&pl=all&m=all&o=all&d1=&d2=&submitOption=comparing&compareBy=plat&sort=sortName&Soft=CFX HTTP/1.1" 200 402737
Traceback (most recent call last):
File "/home/install2/testingDatabase/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 281, in run
self.finish_response()
File "/home/install2/testingDatabase/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 321, in finish_response
self.write(data)
File "/home/install2/testingDatabase/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 400, in write
self.send_headers()
File "/home/install2/testingDatabase/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 465, in send_headers
self._write(str(self.headers))
File "/home/install2/testingDatabase/Python-2.6.6/Lib/socket.py", line 318, in write
self.flush()
File "/home/install2/testingDatabase/Python-2.6.6/Lib/socket.py", line 297, in flush
self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 32] Broken pipe
Traceback (most recent call last):
File "/home/install2/testingDatabase/Python-2.6.6/Lib/SocketServer.py", line 560, in process_request_thread
self.finish_request(request, client_address)
File "/home/install2/testingDatabase/Python-2.6.6/Lib/SocketServer.py", line 322, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/home/install2/testingDatabase/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 562, in __init__
BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
File "/home/install2/testingDatabase/Python-2.6.6/Lib/SocketServer.py", line 618, in __init__
self.finish()
File "/home/install2/testingDatabase/Python-2.6.6/Lib/SocketServer.py", line 661, in finish
self.wfile.flush()
File "/home/install2/testingDatabase/Python-2.6.6/Lib/socket.py", line 297, in flush
self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 32] Broken pipe
[23/Jul/2012 16:09:59] "GET /PolyflowSummary/ HTTP/1.1" 200 7561
[23/Jul/2012 16:17:42] "GET /?soft=CFX HTTP/1.1" 200 11112
[23/Jul/2012 16:17:44] "GET /?soft=CFX HTTP/1.1" 200 11112
[23/Jul/2012 16:18:06] "GET /site_media/style.css HTTP/1.1" 200 432
[23/Jul/2012 16:18:23] "GET /site_media/style.css HTTP/1.1" 200 432
[23/Jul/2012 16:18:23] "GET /site_media/favicon.ico HTTP/1.1" 200 1718
在調試python程序時,使用gdb而不是使用pdb有什麼優勢? – 2012-07-25 14:46:24
你可以使用pdb連接到一個進程嗎? – 2012-07-25 14:47:59