java - Spring 启动 + SSL : Consuming Too much CPU

标签 java ssl spring-boot

我测试了 Java Spring 框架的性能,具有 Spring Boot + SSL 等功能来开发 REST API。

我发现如果我在 Spring 框架中添加 SSL 功能,它会消耗太多 CPU。但是,我删除了 SSL 功能,这个问题就不会发生了。

我通过发送当前 20 个 HTTP 请求/秒或 100 个请求/秒来测试 REST 应用程序来进行压力测试,应用程序将始终消耗近 200% 的 CPU。

我已经将应用程序服务从 Spring 更改为 Tomcat。结果是一样的。

Test Environment
 - Sender  : Loading Test Generator Ubuntu, Dual Core, EC2 on AWS.
 - Receiver: Spring-Boot + SSL, Ubuntu, Dual Core, EC2 on AWS.

以下是接收服务器上的测试程序。

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Hello world!
 *
 */
@SpringBootApplication
//@EnableAutoConfiguration
public class App 
{
    public static void main( String[] args )
    {
        SpringApplication.run(App.class, args);
    }
}

以下是发送方服务器围攻中的Loading Test Generator命令。

 //Current 1 request 
 siege -b -c6 -t60S https://receiver Server IP:8443/ 

 //Current 100 request 
  siege -b -c100 -t60S https://receiver Server IP:8443/

以下信息是我在接收服务器上的测试结果。

Current Requests/sec     Usage of CPU1  Usage of CPU2    Succ
   1                         40%           40%           100%
   2                         80%           80%           100%
   3                         95%           95%           100%
   6                         100%          100%          100%
  100                        100%          100%          100%
  600                        100%          100%          100%

似乎Spring的最大性能是3个请求/秒,而CPU的使用率低于100%。尽管 spring 应用程序可以处理所有请求,但它非常消耗 CPU。

请下载如下非常简单的代码并试一试。 https://github.com/dpomaresp/Spring-boot-with-ssl

你能帮我澄清一下这个问题吗?为什么会出现这个奇怪的问题?是Spring框架的问题吗?

非常感谢您在此问题上提供的帮助。

埃里克

最佳答案

我遇到了同样的问题。降级 tomcat 对我有用。 参见 http://tomcat.10.x6.nabble.com/High-CPU-Consumption-with-Tomcat-8-5-4-NIO-and-SSL-td5054445.html

关于java - Spring 启动 + SSL : Consuming Too much CPU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39388847/

相关文章:

php - 学习基本网络安全的最佳方法

java - 我如何让 TestNG 在特定组中运行测试(从命令行)?

java - 在 Vista 32 位和 Win 7 64 位中访问 %ProgramFiles(x86)% 的统一方式

java - 从IDE内部运行时Hadoop路径异常

c# - 为什么读取进程启动的 server.js 中的证书会导致进程终止?

c++ - BB10 QNX Momentics IDE 中的 SSL 握手失败

java - 如何为远程IP建立套接字连接? (我知道如何为本地IP做到这一点)

Spring Boot Webflux - 安全 CORS 不起作用

java - Spring Boot - 返回日期(不是时间戳)

java - Spring Boot 执行器 - MAX 属性