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 |
@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
对接口发起百次请求,统计区间断点时间、最值时间、平均值时间