Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot + SSL : Consuming Too much CPU

I tested the performance of Java Spring framework with features like Spring Boot + SSL to develop REST API.

I found out that if I add SSL feature to Spring framework, it would consume too much CPU. However, I remove SSL feature, this problem won`t happen.

I did the stress test either by sending current 20 HTTP requests/sec or 100 requests/sec to test REST application, the application would always consume nearly 200% of CPU.

I have changed the application services from Spring to Tomcat. The result was the same.

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

The following is the test program on receiver server.

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

The following are Loading Test Generator commands in siege on sender server.

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

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

The following info is my test result on receiver server.

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%

It seems that the maximum performance of Spring is 3 requests/sec while the usage of CPU is below 100%. Although the spring app can process all the requests, it consumes too much CPU.

Please download a very simple code as below and give it a try. https://github.com/dpomaresp/Spring-boot-with-ssl

Could you help me to clarify this issue ? Why has this strange issue occurred ? Is it an issue of Spring framework ?

Your kindly assistance in this matter would be greatly appreciated.

Eric

like image 560
Eric Wei Avatar asked Sep 08 '16 10:09

Eric Wei


1 Answers

I had the same problem. Downgrading tomcat worked for me. See http://tomcat.10.x6.nabble.com/High-CPU-Consumption-with-Tomcat-8-5-4-NIO-and-SSL-td5054445.html

like image 86
dagerber Avatar answered Nov 02 '22 22:11

dagerber