美好的一天,所有。我遇到了下一个问题: 处理需要使用WAS和tomcat在不同环境上部署的项目。 WAS docer img使用:common / base-ibm-websphere:8.0.0.10 - 8.0架构:x86_64
Name IBM WebSphere Application Server
Version 8.0.0.10
ID BASE
Build Level cf101502.03
Build Date 1/16/15
Package com.ibm.websphere.DEVELOPERSILAN.v80_8.0.10.20150116_1534
Architecture x86-64 (64 bit)
Installed Features IBM 64-bit SDK for Java, Version 6
EJBDeploy tool for pre-EJB 3.0 modules
Embeddable EJB container
Stand-alone thin clients and resource adapters
Tomcat docker img使用:common / base-tomcat:7
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) Server VM (build 24.80-b11, mixed mode)
从一开始就假设WAS出现问题,因为最简单的请求(x8较慢)会慢得多:
long startMethodTime = System.nanoTime();
long endMethodTime;
long operationStartTime;
long operationEndTime;
Long result = 0L;
Long resultSet = 0L;
operationStartTime = System.nanoTime();
List<ResultDTO> testDAOList = new ArrayList<ResultDTO>();
for (int i = 0; i < 200000; i++) {
ResultDTO testClass = new ResultDTO();
testClass.setBody(String.valueOf(new Random().nextDouble()));
testClass.setResult(String.valueOf(new Random().nextInt()));
testClass.setSubject(String.valueOf(new Date()));
testDAOList.add(testClass);
}
operationEndTime = System.nanoTime();
String operationTime = String.valueOf(((operationEndTime - operationStartTime) / 1000000));
LOGGER.error("Creation object in cycle=" + operationTime);
operationStartTime = System.nanoTime();
for (ResultDTO testDAO : testDAOList) {
result += testDAO.getResult().length();
}
operationEndTime = System.nanoTime();
operationTime = String.valueOf((operationEndTime - operationStartTime)/ 1000000);
LOGGER.error("Incrementation in the loop of objects=" + operationTime);
operationStartTime = System.nanoTime();
Set<ResultDTO> sortedResults = new TreeSet<ResultDTO>(
new Comparator<ResultDTO>() {
public int compare(ResultDTO r1, ResultDTO r2) {
int firstCompValue = (r1.getResult().length() + r1.getSubject().length()) % 2;
int secondCompValue = (r2.getResult().length() + r2.getSubject().length()) % 2;
return firstCompValue - secondCompValue;
}
}
);
sortedResults.addAll(testDAOList);
operationEndTime = System.nanoTime();
operationTime = String.valueOf((operationEndTime - operationStartTime) / 1000000);
LOGGER.error("Sort the Set of Objects=" + operationTime);
for (ResultDTO testDAO : sortedResults) {
resultSet += testDAO.getBody().length();
}
//Creation of 100 default objects
long hundredObjectsCreationTime = 0;
for (int i = 0; i < 100; i++) {
operationStartTime = System.nanoTime();
ResultDTO testClass = new ResultDTO();
testClass.setBody(String.valueOf(new Random().nextDouble()));
testClass.setResult(String.valueOf(new Random().nextInt()));
testClass.setSubject(String.valueOf(new Date()));
operationEndTime = System.nanoTime();
hundredObjectsCreationTime += (operationEndTime - operationStartTime);
}
LOGGER.error("100 objects creation time = " + hundredObjectsCreationTime);
endMethodTime = System.nanoTime();
operationTime = String.valueOf((endMethodTime - startMethodTime) / 1000000);
LOGGER.error("Test method duration = " + operationTime);
它在WAS上的执行速度比在Tomcat上慢。 验证的测试结果:
Tomcat:
2018-03-26 21:39:44,347 ERROR [c.v.e.r.r.AboutResource] Creation object in cycle=1006
2018-03-26 21:39:44,381 ERROR [c.v.e.r.r.AboutResource] Incrementation in the loop of objects=33
2018-03-26 21:39:44,411 ERROR [c.v.e.r.r.AboutResource] Sort the Set of Objects=29
2018-03-26 21:39:44,411 ERROR [c.v.e.r.r.AboutResource] 100 objects creation time = 405100 - microsec
2018-03-26 21:39:44,411 ERROR [c.v.e.r.r.AboutResource] Test method duration = 1070
WAS:
[26/03/18 22:26:39:944 UTC] 00000018 SystemOut O ERROR [c.v.e.r.r.AboutResource] Creation object in cycle=8408
[26/03/18 22:26:40:069 UTC] 00000018 SystemOut O ERROR [c.v.e.r.r.AboutResource] Incrementation in the loop of objects=124
[26/03/18 22:26:40:373 UTC] 00000018 SystemOut O ERROR [c.v.e.r.r.AboutResource] Sort the Set of Objects=303
[26/03/18 22:26:40:377 UTC] 00000018 SystemOut O ERROR [c.v.e.r.r.AboutResource] 100 objects creation time = 3384400
[26/03/18 22:26:40:377 UTC] 00000018 SystemOut O ERROR [c.v.e.r.r.AboutResource] Test method duration = 8841
在WAS端配置仅堆大小(超过enoph)和数据库连接(与此问题无关)。
首先,在调整IBM jVM / WAS配置时我应该注意什么? (现在我已经在调查IBM手册了,可能为了避免冒烟测试而节省了时间,以避免测试不同的JVM属性。)
答案 0 :(得分:1)
IBM Java和HotSpot之间的一些默认值是不同的,因此微基准测试(一些请求)是众所周知的不准确。最好进行长负载测试。话虽如此,它可能是很多东西。我建议您尝试的第一件事是将-Xquickstart
设置为generic JVM argument:
IBM®JIT编译器针对通常在服务器上使用的长时间运行的应用程序进行了调整。您可以使用-Xquickstart命令行选项来提高短期运行应用程序的性能,尤其是对于处理不集中在少数方法中的应用程序。 (https://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/com.ibm.java.lnx.80.doc/diag/tools/jitpd_short_run.html)
如果这没有帮助,那么下一件事就是enable verbosegc与-Xverbosegclog:${SERVER_LOG_ROOT}/verbosegc.%seq.log,20,50000
并检查proportion of time in garbage collection with the free IBM GCMV tool。
如果这显示不多,请提供有关您的操作系统的更多信息。
答案 1 :(得分:1)
发现问题。 启用的调试端口减慢了8次WAS java性能! 至少在Docker中使用WAS 8.0.0.10。