2

クライアントとしてLinux(Ubuntu)マシンがあります。200 人のユーザーがサーバーから同時にファイルをダウンロードしようとしたときのデータ転送速度を測定したいと考えています。

このためのpythonまたはlinuxツールはありますか?または、アプローチをお勧めできますか?

私はこのスピードチェックコードを見ました。スレッドでラップできますが、コードが非常に「複雑」で、ブロックサイズが常に変化する理由がわかりません。

4

4 に答える 4

1

最近、 Mult-Mechanizeを使用していくつかのパフォーマンステストを実行しました。それはかなり簡単で、かなりうまくいきました。

于 2012-07-18T20:56:21.110 に答える
1

多分apacheからの'ab'?

ab -n 1000 -c 200 [http[s]://]hostname[:port]/path
-n Number of requests to perform
-c Number of multiple requests to make at a time

http://httpd.apache.org/docs/2.2/programs/ab.html またはmanabなど、多くのオプションがあります。

于 2013-03-03T23:05:51.800 に答える
1

実際の専用サーバーについて話しているかどうかはわかりません。トラフィック グラフなどには、Muninを使用することを好みます。これは、rrdtool を使用して素敵なグラフを作成する、非常に完全な監視アプリケーションです。例は munin サイトにリンクされています: full setupeth0 traffic graph

新しい munin 2はさらに派手ですが、私のリポジトリにはなく、perl アプリケーションをいじるのが好きではないため、まだ使用していません。

于 2012-07-20T08:41:21.233 に答える
0
import threading
import time
import urllib2

block_sz = 8192
num_threads = 1
url = "http://192.168.1.1/bigfile2"
secDownload = 30

class DownloadFileThread(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)

        self.u = urllib2.urlopen(url)
        self.file_size_dl = 0


    def run(self):
        while True:
            buffer = self.u.read(block_sz)
            if not buffer:
                raise 'There is nothing to read. You should have bigger file or smaller time'

            self.file_size_dl += len(buffer)


if __name__ == "__main__":
    print 'Download from url ' + url + ' use in ' + str(num_threads)  + ' to download. test time ' + str(secDownload)  
        threads = []
        for i in range(num_threads):
            downloadThread = DownloadFileThread()
            downloadThread.daemon = True
            threads.append(downloadThread)
        for i in range(num_threads):
            threads[i].start()
        time.sleep(secDownload)

        sumBytes=0
        for i in range(num_threads):
            sumBytes = sumBytes +  threads[i].file_size_dl
        print sumBytes
        print str(sumBytes/(secDownload *1000000)) + 'MBps'
于 2012-07-20T08:35:42.153 に答える