從事例說起
先從簡單實現類似LR多機聯合負載這樣一個壓測場景展開。被測目標是這樣的:一個web應用服務,用于收集分布式系統的跨機房流量信息,后端采用hbase作為存儲數據庫,接口為單一節點的http listen端口,需要模擬真實跨機房場景,利用較少的機器數量(約真實系統的50分之一)模擬線上系統的并發度。
測試工具代碼是發送http request部分,出于安全考慮,重要部分略過:
while(System.currentTimeMillis() - start <= runtime){ StringBuffer sb = new StringBuffer(); List<String> data = new ArrayList<String>(); HttpURLConnection httpurlconnection = null; try{ URL url = new URL(this.reportAd); httpurlconnection = (HttpURLConnection) url.openConnection(); httpurlconnection.setConnectTimeout(5000); httpurlconnection.setReadTimeout(5000); httpurlconnection.setDoOutput(true); httpurlconnection.setRequestMethod("POST"); httpurlconnection.setRequestProperty("Content-type", "text/plain");
for(long i=0; i<this 原文轉自:http://www.taobaotest.com/blogs/2515
|