java - Websphere caconfiguration/IBM JVM : pure java works much more slower that in tomcat

标签 java jvm websphere ibm-jvm

大家好。我遇到了下一个问题: 处理需要使用 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 出了问题,因为最简单的请求会慢得多(慢 8 倍):

  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);

它在 x8 的 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 属性)。

最佳答案

发现问题。 启用的调试端口使 WAS java 性能降低 8 倍! 至少在 docker 中的 WAS 8.0.0.10 上。

关于java - Websphere caconfiguration/IBM JVM : pure java works much more slower that in tomcat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49501257/

相关文章:

java - 线程安全和共享资源

java - 在 Java 中创建一个 Nohup 进程

java - 为什么 JAXB 找不到 XML 行数?

java - 从 WEB-INF 文件夹获取图像

java - Hibernate IN/ANY 与 Criteria 中的自定义转换器

java - 对目录和子目录中的每个文件做一些事情

android - android studio 创建JVM失败

Java G1GC - 卡片表(CT)与 memset (RS)

java - wsdl 级别 Web 服务中的字符限制

java - 移除或删除现有 Websphere Application Server 的配置文件