spring boot tomcat 線程數 修改初始線程數 統計性能 每百次請求耗時


 

 

[root@f java]# tail -30 nohup.out
searchES-TimeMillisSpent:448
P->1602@fT->http-nio-8080-exec-3t->池州小型柴油機移動泵哪家好kw->柴油機移動泵kws->柴油機移動泵,柴油機水泵機組,自吸柴油機泵
searchES-TimeMillisSpent:387
P->1602@fT->http-nio-8080-exec-10t->東莞知名6061鋁合金價格kw->6061鋁合金kws->6061鋁合金,鋁材制造,燈飾鋁材
searchES-TimeMillisSpent:661
P->1602@fT->http-nio-8080-exec-6t->中山知名私人聚會外賣服務為先kw->私人聚會kws->私人聚會,冷餐會服務,烹飪隊
searchES-TimeMillisSpent:778
P->1602@fT->http-nio-8080-exec-5t->青島智能干式過濾器系統kw->干式過濾器kws->干式過濾器,廢氣處理工程,直接燃燒爐
searchES-TimeMillisSpent:469
P->1602@fT->http-nio-8080-exec-7t->金川開發區知名3-6歲潛能培訓哪家好kw->3-6歲潛能培訓kws->3-6歲潛能培訓,學前教育,寶寶潛能開發
searchES-TimeMillisSpent:667
P->1602@fT->http-nio-8080-exec-9t->四川靠譜的寶寶早教機構老師水平怎么kw->寶寶早教kws->寶寶早教,兒童早教,家庭早教加盟
searchES-TimeMillisSpent:420
P->1602@fT->http-nio-8080-exec-2t->韶關正規掃碼共享充電批發kw->掃碼共享充電kws->掃碼共享充電,賓館小型售貨機,掃碼充電線
searchES-TimeMillisSpent:30
P->1602@fT->http-nio-8080-exec-10t->盛芯泰銷售優質的ISL31492EIBZ原裝貨賣kw->ISL31492EIBZkws->ISL31492EIBZ,ISL3159EFBZ,ISL32478EIBZ
searchES-TimeMillisSpent:456
P->1602@fT->http-nio-8080-exec-5t->河源生產環保烘干機廠家kw->環保烘干機kws->環保烘干機,節能烘干機,面條烘干機
searchES-TimeMillisSpent:423
P->1602@fT->http-nio-8080-exec-7t->雲南正規冷板選哪家kw->冷板kws->冷板,角鐵,鋼結構
searchES-TimeMillisSpent:598
P->1602@fT->http-nio-8080-exec-3t->橫崗街道散打深圳學武術價格價格kw->深圳學武術價格kws->深圳學武術價格,深圳少兒武術,龍崗武術培訓班
searchES-TimeMillisSpent:726
P->1602@fT->http-nio-8080-exec-1t->甘肅放心家用空氣能熱水器哪家好kw->家用空氣能熱水器kws->家用空氣能熱水器,OEM熱水器,商用空氣能熱水器
searchES-TimeMillisSpent:355
P->1602@fT->http-nio-8080-exec-9t->安康知名職員辦公桌廠家kw->職員辦公桌kws->職員辦公桌,傳統辦公家具,玻璃茶幾
searchES-TimeMillisSpent:536
P->1602@fT->http-nio-8080-exec-6t->雲南昆明高端快題集訓機構哪個好kw->快題集訓kws->快題集訓,短期手繪培訓,考研快題輔導
searchES-TimeMillisSpent:355
P->1602@fT->http-nio-8080-exec-5t->襄樊地中海風格火燒石餐桌多少錢kw->火燒石餐桌kws->火燒石餐桌,中式沙發,火燒石餐桌
[root@f java]#

 

 

awk  去重

 

 

修改初始線程數

 

server.tomcat.max-threads=100
server.tomcat.minSpareThreads=50


D:\worksp\springtest\src\main\resources\application.properties

 

rentT->http-nio-8080-exec-39:t->甘南定做公司互聯網推廣找哪家:kw->公司互聯網推廣:kws->公司互聯網推廣,網站建設,網站設計公司
searchES-TimeMillisSpent:683
16213@f:currentT->http-nio-8080-exec-15:t->惠州生產車牌識別收費系統批發價格:kw->車牌識別收費系統:kws->車牌識別收費系統,門禁停車場系統,移動伸縮門
searchES-TimeMillisSpent:348
16213@f:currentT->http-nio-8080-exec-3:t->雁塔區個體外貿公司注冊資料:kw->外貿公司注冊:kws->外貿公司注冊,工商年審,淘丁
searchES-TimeMillisSpent:260
16213@f:currentT->http-nio-8080-exec-41:t->浙江省供應水晶蜜蠟有哪些:kw->水晶蜜蠟:kws->水晶蜜蠟,綠松石桶珠,南紅
searchES-TimeMillisSpent:856
16213@f:currentT->http-nio-8080-exec-5:t->濱州知名環保設備工程就業怎么選:kw->環保設備工程就業:kws->環保設備工程就業,環保設備工程專業介紹,光氧催化廢氣原理圖
searchES-TimeMillisSpent:294
16213@f:currentT->http-nio-8080-exec-17:t->東莞有創意的年會場地布置報價:kw->年會場地布置:kws->年會場地布置,年會小品,年會場地選擇
searchES-TimeMillisSpent:592
16213@f:currentT->http-nio-8080-exec-16:t->內蒙古自治區資深景觀投影燈定制:kw->景觀投影燈:kws->景觀投影燈,logo燈,定制logo燈
searchES-TimeMillisSpent:693
16213@f:currentT->http-nio-8080-exec-31:t->大同設計廣告用板報價:kw->廣告用板:kws->廣告用板,鋪車底塑料板,煤倉襯板
searchES-TimeMillisSpent:595
16213@f:currentT->http-nio-8080-exec-9:t->肇慶投資光伏農業有哪些:kw->光伏農業:kws->光伏農業,光伏板,光伏行業
searchES-TimeMillisSpent:282
16213@f:currentT->http-nio-8080-exec-14:t->內蒙古正規自卸車淋水器配件哪家好:kw->自卸車淋水器配件:kws->自卸車淋水器配件,貨車淋水器,自卸車淋水器封頭

 

 

Apache Tomcat 7 Configuration Reference (7.0.92) - The HTTP Connector https://tomcat.apache.org/tomcat-7.0-doc/config/http.html#Standard_Implementation
minSpareThreads

The minimum number of threads always kept running. This includes both active and idle threads. If not specified, the default of 10 is used. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool. Note that if an executor is configured any value set for this attribute will be recorded correctly but it will be reported (e.g. via JMX) as -1 to make clear that it is not used.




@RequestMapping(value = "/getESversion553ByPost", method = RequestMethod.POST)
public ResponseEntity getES653(@RequestBody TitleKeyword titleKeyword) throws IOException {
long startMethod = System.currentTimeMillis();
long searchESTimeMillisSpent = 0;
String title = titleKeyword.getTitle();
String keyword = titleKeyword.getKeyword();
String keywords = titleKeyword.getKeywords();
String searchESstr;
String resJsonStr;
JSONObject jsonObject;
HttpStatus httpStatus = HttpStatus.OK;
String kwsSeparatorStr = ",";

// TODO searchESstr公共部分摘除
// 假設優先級 主關鍵詞>關鍵詞列表>標題,有關鍵詞存在情況下,不考慮標題
if (keyword != null && keyword.replace(" ", "").length() > 0) {
if (keywords != null && keywords.replace(" ", "").length() > 0) {
if (keywords.contains(kwsSeparatorStr)) {
String[] requestKeywordList = keywords.split(kwsSeparatorStr);
// TODO 此處需要結合es數據結構請求的數據結構進行算法優化,使得es搜索結果精准
keywords = keyword + "," + requestKeywordList[0] + "," + requestKeywordList[requestKeywordList.length - 1];
} else {
keywords = keyword + "," + keywords;
}
} else {
keywords = keyword;
}
searchESstr = "{\"from\":0,\"size\":200,\"query\":{\"bool\":{\"should\":[{\"match\":{\"keyword\":{\"query\":\"" + keyword + "\",\"boost\":2}}},{\"match\":{\"text\":{\"query\":\"" + keywords + "\",\"boost\":1}}}]}},\"track_scores\":\"true\",\"sort\":[{\"weight\":{\"order\":\"desc\"}},{\"_score\":{\"order\":\"desc\"}}]}";
} else if (title != null && title.replace(" ", "").length() > 0) {
searchESstr = "{\"from\":0,\"size\":200,\"query\":{\"bool\":{\"should\":{\"match\":{\"text\":{\"query\":\"" + title + "\"}}}}},\"track_scores\":\"true\",\"sort\":[{\"weight\":{\"order\":\"desc\"}},{\"_score\":{\"order\":\"desc\"}}]}";
} else {
// TODO 同上
searchESstr = "";
}

if (searchESstr == "") {
resJsonStr = "{\"msg\":\"請求參數非法!BAD_REQUEST!\"}";
} else {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
long timeMillisSpent = 0;
long startEsSearch = System.currentTimeMillis();
long endEsSearch;
// TODO 硬代碼
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials("elastic", "admi"));
RestClient restClient = RestClient.builder(new HttpHost("es-cn-m3ats.elasticsearch.aliyuncs.com", 9200))
.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
}).build();
try {
HttpEntity httpEntity = new StringEntity(searchESstr, ContentType.APPLICATION_JSON);
//search a document
String endpoint = "/search_text/_search?";
Response response = restClient.performRequest("GET", endpoint,
Collections.singletonMap("pretty", "false"), httpEntity);
endEsSearch = System.currentTimeMillis();
searchESTimeMillisSpent = endEsSearch - startEsSearch;
resJsonStr = EntityUtils.toString(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
resJsonStr = "{\"msg\":\"" + e.toString() + "\"}";
httpStatus = HttpStatus.REQUEST_TIMEOUT;
} finally {
credentialsProvider.clear();
restClient.close();
}
}
Thread t = Thread.currentThread();
String debug = ManagementFactory.getRuntimeMXBean().getName() + ":currentT->" + t.getName() + ":t->" + title + ":kw->" + keyword + ":kws->" + keywords;
jsonObject = JSONObject.parseObject(resJsonStr);
long beforeReturn = System.currentTimeMillis();
System.out.println("searchES:" + searchESTimeMillisSpent + "inMethod2BeforeReturn:" + (beforeReturn - startMethod) + "thread:" + debug);
return new ResponseEntity<JSONObject>(jsonObject, httpStatus);
}





 java -jar target/springMybatis-1.0-SNAPSHOT.jar -Xms2g -Xmx2g


對接口發起百次請求,統計區間斷點時間、最值時間、平均值時間







免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM