2

在我的应用程序重新部署操作后,cpu 上升到 100%。所以我必须重新启动Tomcat来释放cpu。

消耗所有cpu的线程是:

    "reactor-http-epoll-1" #1569412 守护进程 prio=5 os_prio=0 tid=0x00007f53c010b000 nid=0x6155 可运行 [0x00007f539237d000]
       java.lang.Thread.State:可运行
            在 java.lang.Throwable.getStackTraceElement(本机方法)
            在 java.lang.Throwable.getOurStackTrace(Throwable.java:827)
            - 锁定(java.lang.NoClassDefFoundError)
            在 java.lang.Throwable.getStackTrace(Throwable.java:816)
            在 ch.qos.logback.classic.spi.ThrowableProxy.(ThrowableProxy.java:55)
            在 ch.qos.logback.classic.spi.LoggingEvent.(LoggingEvent.java:119)
            在 ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:419)
            在 ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383)
            在 ch.qos.logback.classic.Logger.log(Logger.java:765)
            在 io.netty.util.internal.logging.LocationAwareSlf4JLogger.log(LocationAwareSlf4JLogger.java:50)
            在 io.netty.util.internal.logging.LocationAwareSlf4JLogger.warn(LocationAwareSlf4JLogger.java:202)
            在 io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
            在 io.netty.util.concurrent.SingleThreadEventExecutor.runAllTask​​s(SingleThreadEventExecutor.java:472)
            在 io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:387)
            在 io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
            在 io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
            在 io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
            在 java.lang.Thread.run(Thread.java:748)

该问题仅发生在重新部署操作中。我用新版本替换 - 从外壳 - 战争。

  • 操作系统:RedHat 7.6 x86_64 (3.10.0-957.5.1.el7.x86_64)
  • 处理器:1 x Intel(R) Xeon(R) CPU E5-2687W v4 @ 3.00GHz
  • OpenJDK 运行时环境(内部版本 1.8.0_191-b12)
  • OpenJDK 64 位服务器 VM(内部版本 25.191-b12,混合模式)
  • 服务器版本:Apache Tomcat/9.0.7.redhat-12
  • 服务器建成时间:2018 年 9 月 7 日 13:37:03 UTC
  • 服务器号:9.0.7.0
  • 操作系统名称:Linux
  • 操作系统版本:3.10.0-957.5.1.el7.x86_64
  • 架构:amd64
  • JVM版本:1.8.0_191-b12
  • JVM 供应商:甲骨文公司
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>Hoxton.SR9</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-loadbalancer</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-commons</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-webflux</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
        <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-springsecurity5</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-openfeign</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-netflix-ribbon</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

使用 webflux (webclient) 的负载均衡器配置。


    @Configuration
    @EnableAutoConfiguration
    @LoadBalancerClients({ @LoadBalancerClient(value = "${loadbalancer.client.name}") })
    public class LoadBalancerConfig implements WebMvcConfigurer {
    
        @LoadBalanced
        @Bean
        RestTemplate restClient() {
            return new RestTemplate();
        }
    
        @Bean
        public ServiceInstanceListSupplier discoveryClientServiceInstanceListSupplier(DiscoveryClient discoveryClient, Environment env, ApplicationContext context, LoadBalancerProperties loadBalancerProperties) {
            DiscoveryClientServiceInstanceListSupplier firstDelegate = new DiscoveryClientServiceInstanceListSupplier(discoveryClient, env);
    
            HealthCheckServiceInstanceListSupplier delegate = new HealthCheckServiceInstanceListSupplier(firstDelegate, loadBalancerProperties.getHealthCheck(), WebClient.create());
    
            /*
             * ObjectProvider<LoadBalancerCacheManager> cacheManagerProvider = context
             * .getBeanProvider(LoadBalancerCacheManager.class);
             *
             * if (cacheManagerProvider.getIfAvailable() != null) { return new
             * CachingServiceInstanceListSupplier(delegate,
             * cacheManagerProvider.getIfAvailable()); }
             */
            return delegate;
        }
    
    }


依赖:树

    [信息]
    [信息] ---------------------------------------------
    [信息] 构建 webapp 1.0.1                                              
    [信息] --------------------------------[ 战争 ]------------ ---------------------
    [信息]
    [信息] --- maven-dependency-plugin:3.1.2:tree (default-cli) @ webapp ---
    [信息] it.xxx:webapp:war:1.0.1
    [信息] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.3.0.RELEASE:compile
    [信息] | +- org.springframework.boot:spring-boot-starter:jar:2.3.0.RELEASE:compile
    [信息] | | +- org.springframework.boot:spring-boot:jar:2.3.0.RELEASE:compile
    [信息] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.3.0.RELEASE:compile
    [信息] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.3.0.RELEASE:compile
    [信息] | | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
    [信息] | | | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
    [信息] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.13.2:compile
    [信息] | | | | \- org.apache.logging.log4j:log4j-api:jar:2.13.2:compile
    [信息] | | | \- org.slf4j:jul-to-slf4j:jar:1.7.30:compile
    [信息] | | \- org.yaml:snakeyaml:jar:1.26:compile
    [信息] | +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.3.0.RELEASE:compile
    [信息] | | +- org.springframework.boot:spring-boot-actuator:jar:2.3.0.RELEASE:compile
    [信息] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.11.0:compile
    [信息] | | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.0:compile
    [信息] | | | \- com.fasterxml.jackson.core:jackson-core:jar:2.11.0:compile
    [信息] | | \- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.0:compile
    [信息] | \- io.micrometer:micrometer-core:jar:1.5.1:compile
    [信息] | +- org.hdrhistogram:HdrHistogram:jar:2.1.12:compile
    [信息] | \- org.latencyutils:LatencyUtils:jar:2.0.3:runtime
    [信息] +- org.springframework.boot:spring-boot-starter-web:jar:2.3.0.RELEASE:compile
    [信息] | +- org.springframework.boot:spring-boot-starter-json:jar:2.3.0.RELEASE:compile
    [信息] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.11.0:compile
    [信息] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.0:compile
    [信息] | +- org.springframework:spring-web:jar:5.2.6.RELEASE:compile
    [信息] | | \- org.springframework:spring-beans:jar:5.2.6.RELEASE:compile
    [信息] | \- org.springframework:spring-webmvc:jar:5.2.6.RELEASE:compile
    [信息] | \- org.springframework:spring-expression:jar:5.2.6.RELEASE:compile
    [信息] +- org.springframework.boot:spring-boot-starter-security:jar:2.3.0.RELEASE:compile
    [信息] | +- org.springframework:spring-aop:jar:5.2.6.RELEASE:compile
    [信息] | +- org.springframework.security:spring-security-config:jar:5.3.2.RELEASE:compile
    [信息] | | \- org.springframework.security:spring-security-core:jar:5.3.2.RELEASE:compile
    [信息] | \- org.springframework.security:spring-security-web:jar:5.3.2.RELEASE:compile
    [信息] +- org.thymeleaf.extras:thymeleaf-extras-springsecurity5:jar:3.0.4.RELEASE:compile
    [信息] | \- org.slf4j:slf4j-api:jar:1.7.30:compile
    [信息] +- org.springframework.boot:spring-boot-starter-thymeleaf:jar:2.3.0.RELEASE:compile
    [信息] | +- org.thymeleaf:thymeleaf-spring5:jar:3.0.11.RELEASE:compile
    [信息] | | \- org.thymeleaf:thymeleaf:jar:3.0.11.RELEASE:compile
    [信息] | | +- org.attoparser:attoparser:jar:2.0.5.RELEASE:compile
    [信息] | | \- org.unbescape:unbescape:jar:1.1.6.RELEASE:compile
    [信息] | \- org.thymeleaf.extras:thymeleaf-extras-java8time:jar:3.0.4.RELEASE:compile
    [信息] +- org.springframework.boot:spring-boot-starter-test:jar:2.3.0.RELEASE:test
    [信息] | +- org.springframework.boot:spring-boot-test:jar:2.3.0.RELEASE:test
    [信息] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.3.0.RELEASE:test
    [信息] | +- com.jayway.jsonpath:json-path:jar:2.4.0:test
    [信息] | | \- net.minidev:json-smart:jar:2.3:test
    [信息] | | \- net.minidev:accessors-smart:jar:1.2:test
    [信息] | | \- org.ow2.asm:asm:jar:5.0.4:test
    [信息] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:test
    [信息] | | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:test
    [信息] | +- org.assertj:assertj-core:jar:3.16.1:test
    [信息] | +- org.hamcrest:hamcrest:jar:2.2:test
    [信息] | +- org.junit.jupiter:junit-jupiter:jar:5.6.2:test
    [信息] | | +- org.junit.jupiter:junit-jupiter-api:jar:5.6.2:test
    [信息] | | | +- org.opentest4j:opentest4j:jar:1.2.0:test
    [信息] | | | \- org.junit.platform:junit-platform-commons:jar:1.6.2:test
    [信息] | | +- org.junit.jupiter:junit-jupiter-params:jar:5.6.2:test
    [信息] | | \- org.junit.jupiter:junit-jupiter-engine:jar:5.6.2:test
    [信息] | +- org.junit.vintage:junit-vintage-engine:jar:5.6.2:test
    [信息] | | +- org.apiguardian:apiguardian-api:jar:1.1.0:test
    [信息] | | +- org.junit.platform:junit-platform-engine:jar:1.6.2:test
    [信息] | | \- junit:junit:jar:4.13:test
    [信息] | +- org.mockito:mockito-core:jar:3.3.3:test
    [信息] | | +- net.bytebuddy:byte-buddy:jar:1.10.10:test
    [信息] | | +- net.bytebuddy:byte-buddy-agent:jar:1.10.10:test
    [信息] | | \- org.objenesis:objenesis:jar:2.6:test
    [信息] | +- org.mockito:mockito-junit-jupiter:jar:3.3.3:test
    [信息] | +- org.skyscreamer:jsonassert:jar:1.5.0:test
    [信息] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
    [信息] | +- org.springframework:spring-core:jar:5.2.6.RELEASE:compile
    [信息] | | \- org.springframework:spring-jcl:jar:5.2.6.RELEASE:compile
    [信息] | +- org.springframework:spring-test:jar:5.2.6.RELEASE:test
    [信息] | \- org.xmlunit:xmlunit-core:jar:2.7.0:test
    [信息] +- org.webjars:bootstrap:jar:4.2.1:compile
    [信息] | +- org.webjars:jquery:jar:3.0.0:compile
    [信息] | \- org.webjars:popper.js:jar:1.14.3:compile
    [信息] +- org.springframework.cloud:spring-cloud-starter-openfeign:jar:2.2.6.RELEASE:compile
    [信息] | +- org.springframework.cloud:spring-cloud-starter:jar:2.2.6.RELEASE:compile
    [信息] | | +- org.springframework.cloud:spring-cloud-context:jar:2.2.6.RELEASE:compile
    [信息] | | \- org.springframework.security:spring-security-rsa:jar:1.0.9.RELEASE:compile
    [信息] | | \- org.bouncycastle:bcpkix-jdk15on:jar:1.64:compile
    [信息] | | \- org.bouncycastle:bcprov-jdk15on:jar:1.64:compile
    [信息] | +- org.springframework.cloud:spring-cloud-openfeign-core:jar:2.2.6.RELEASE:compile
    [信息] | | +- org.springframework.boot:spring-boot-starter-aop:jar:2.3.0.RELEASE:compile
    [信息] | | | \- org.aspectj:aspectjweaver:jar:1.9.5:compile
    [信息] | | \- io.github.openfeign.form:feign-form-spring:jar:3.8.0:compile
    [信息] | | +- io.github.openfeign.form:feign-form:jar:3.8.0:compile
    [信息] | | \- commons-fileupload:commons-fileupload:jar:1.4:compile
    [信息] | +- io.github.openfeign:feign-core:jar:10.10.1:compile
    [信息] | +- io.github.openfeign:feign-slf4j:jar:10.10.1:compile
    [信息] | \- io.github.openfeign:feign-hystrix:jar:10.10.1:compile
    [信息] | +- com.netflix.archaius:archaius-core:jar:0.7.6:compile
    [信息] | | +- com.google.code.findbugs:jsr305:jar:3.0.1:runtime
    [信息] | | +- commons-configuration:commons-configuration:jar:1.8:runtime
    [信息] | | | \- commons-lang:commons-lang:jar:2.6:runtime
    [信息] | | \- com.google.guava:guava:jar:29.0-jre:runtime
    [信息] | | +- com.google.guava:failureaccess:jar:1.0.1:runtime
    [信息] | | +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:runtime
    [信息] | | +- org.checkerframework:checker-qual:jar:2.11.1:runtime
    [信息] | | +- com.google.errorprone:error_prone_annotations:jar:2.3.4:runtime
    [信息] | | \- com.google.j2objc:j2objc-annotations:jar:1.3:runtime
    [信息] | \- com.netflix.hystrix:hystrix-core:jar:1.5.18:compile
    [信息] | \- io.reactivex:rxjava:jar:1.3.8:compile
    [信息] +- org.springframework.cloud:spring-cloud-starter-loadbalancer:jar:2.2.6.RELEASE:compile
    [信息] | +- org.springframework.cloud:spring-cloud-loadbalancer:jar:2.2.6.RELEASE:compile
    [信息] | | +- org.springframework.boot:spring-boot-starter-validation:jar:2.3.0.RELEASE:compile
    [信息] | | | \- org.hibernate.validator:hibernate-validator:jar:6.1.5.Final:compile
    [信息] | | | +- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
    [信息] | | | +- org.jboss.logging:jboss-logging:jar:3.4.1.Final:compile
    [信息] | | | \- com.fasterxml:classmate:jar:1.5.1:compile
    [信息] | | +- io.projectreactor:reactor-core:jar:3.3.5.RELEASE:compile
    [信息] | | | \- org.reactivestreams:reactive-streams:jar:1.0.3:compile
    [信息] | | \- io.projectreactor.addons:reactor-extra:jar:3.3.3.RELEASE:compile
    [信息] | +- org.springframework.boot:spring-boot-starter-cache:jar:2.3.0.RELEASE:compile
    [信息] | | \- org.springframework:spring-context-support:jar:5.2.6.RELEASE:compile
    [信息] | \- com.stoyanr:evictor:jar:1.0.0:compile
    [信息] +- org.springframework.cloud:spring-cloud-commons:jar:2.2.6.RELEASE:compile
    [信息] | \- org.springframework.security:spring-security-crypto:jar:5.3.2.RELEASE:compile
    [信息] +- org.springframework.boot:spring-boot-starter-webflux:jar:2.3.0.RELEASE:compile
    [信息] | +- org.springframework.boot:spring-boot-starter-reactor-netty:jar:2.3.0.RELEASE:compile
    [信息] | | \- io.projectreactor.netty:reactor-netty:jar:0.9.7.RELEASE:compile
    [信息] | | +- io.netty:netty-codec-http:jar:4.1.49.Final:compile
    [信息] | | | +- io.netty:netty-common:jar:4.1.49.Final:compile
    [信息] | | | +- io.netty:netty-buffer:jar:4.1.49.Final:compile
    [信息] | | | +- io.netty:netty-transport:jar:4.1.49.Final:compile
    [信息] | | | \- io.netty:netty-codec:jar:4.1.49.Final:compile
    [信息] | | +- io.netty:netty-codec-http2:jar:4.1.49.Final:compile
    [信息] | | +- io.netty:netty-handler:jar:4.1.49.Final:compile
    [信息] | | | \- io.netty:netty-resolver:jar:4.1.49.Final:compile
    [信息] | | +- io.netty:netty-handler-proxy:jar:4.1.49.Final:compile
    [信息] | | | \- io.netty:netty-codec-socks:jar:4.1.49.Final:compile
    [信息] | | \- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.49.Final:compile
    [信息] | | \- io.netty:netty-transport-native-unix-common:jar:4.1.49.Final:compile
    [信息] | +- org.springframework:spring-webflux:jar:5.2.6.RELEASE:compile
    [信息] | \- org.synchronoss.cloud:nio-multipart-parser:jar:1.1.0:compile
    [信息] | \- org.synchronoss.cloud:nio-stream-storage:jar:1.1.3:compile
    [INFO] +- it.xxx:type:jar:1.0-SNAPSHOT:compile
    [信息] | \- org.projectlombok:lombok:jar:1.18.12:compile
    [INFO] +- it.xxx:utility:jar:1.0-SNAPSHOT:compile
    [信息] | +- org.springframework:spring-context:jar:5.2.6.RELEASE:compile
    [信息] | +- javax.mail:mail:jar:1.4.7:compile
    [信息] | | \- javax.activation:activation:jar:1.1:compile
    [信息] | +- org.apache.commons:commons-lang3:jar:3.10:compile
    [信息] | +- org.modelmapper:modelmapper:jar:2.1.0:compile
    [信息] | +- commons-io:commons-io:jar:2.6:compile
    [信息] | \- io.jsonwebtoken:jjwt:jar:0.9.1:compile
    [信息] +- org.json:json:jar:20190722:compile
    [信息] +- commons-validator:commons-validator:jar:1.6:compile
    [信息] | +- commons-beanutils:commons-beanutils:jar:1.9.2:compile
    [信息] | +- commons-digester:commons-digester:jar:1.8.1:compile
    [信息] | +- commons-logging:commons-logging:jar:1.2:compile
    [信息] | \- commons-collections:commons-collections:jar:3.2.2:compile
    [信息] +- com.google.code.gson:gson:jar:2.8.5:compile
    [信息] \- org.springframework.boot:spring-boot-starter-tomcat:jar:2.3.0.RELEASE:provided
    [信息] +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
    [信息] +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.35:provided
    [信息] +- org.glassfish:jakarta.el:jar:3.0.3:compile
    [信息] \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.35:provided

谢谢!

4

0 回答 0