Browse Source

Merge pull request #801 from bclozel/boot-upgrade

Upgrade Spring dependencies and fix setup
Mike Smith 11 năm trước cách đây
mục cha
commit
1a254b42d9

+ 4 - 4
spring/README.md

@@ -61,8 +61,8 @@ Check out [SampleApplication, the main Application file](src/main/java/com/teche
 ## Infrastructure Software Versions
 The tests were run with:
 
-* [Spring 4.0.0.RC1](http://projects.spring.io/spring-framework/)
-* [Spring Boot 0.5.0M6](http://projects.spring.io/spring-boot/)
-* [Spring Data JPA 1.4.2.RELEASE](http://projects.spring.io/spring-data-jpa/)
+* [Spring 4.0.2.RELEASE](http://projects.spring.io/spring-framework/)
+* [Spring Boot 1.0.0.RC4](http://projects.spring.io/spring-boot/)
+* [Spring Data JPA 1.5.0.RELEASE](http://projects.spring.io/spring-data-jpa/)
 * [Java OpenJDK 1.7.0_09](http://openjdk.java.net/)
-* [Tomcat 8.0.0-RC5](https://tomcat.apache.org/)
+* [Tomcat 8.0.3](https://tomcat.apache.org/)

+ 8 - 3
spring/pom.xml

@@ -8,7 +8,7 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>0.5.0.M7</version>
+        <version>1.0.0.RC4</version>
     </parent>
 
     <groupId>com.techempower</groupId>
@@ -19,7 +19,7 @@
 
     <properties>
         <java.version>1.7</java.version>
-        <tomcat.version>8.0.0-RC10</tomcat.version>
+        <tomcat.version>8.0.3</tomcat.version>
     </properties>
 
     <dependencies>
@@ -47,7 +47,7 @@
         </dependency>
         <dependency>
             <groupId>org.thymeleaf</groupId>
-            <artifactId>thymeleaf-spring3</artifactId>
+            <artifactId>thymeleaf-spring4</artifactId>
         </dependency>
         <dependency>
             <groupId>org.yaml</groupId>
@@ -70,6 +70,11 @@
             <id>spring-milestones</id>
             <url>http://repo.spring.io/milestone</url>
         </repository>
+        <repository>
+            <id>bintray</id>
+            <name>bintray</name>
+            <url>http://jcenter.bintray.com</url>
+        </repository>
     </repositories>
 
     <pluginRepositories>

+ 1 - 1
spring/setup.py

@@ -6,7 +6,7 @@ import os
 def start(args, logfile, errfile):
   try:
     subprocess.check_call("mvn clean package", shell=True, cwd="spring", stderr=errfile, stdout=logfile)
-    subprocess.Popen(("java -Xmx2048m -Xms2048m -XX:MaxPermSize=256m -Ddatabase.host=" + args.database_host + " -jar spring.war").rsplit(" "), cwd="spring/target", stderr=errfile, stdout=logfile)
+    subprocess.Popen(("java -Ddatabase.host=" + args.database_host + " -jar spring.war").rsplit(" "), cwd="spring/target", stderr=errfile, stdout=logfile)
     return 0
   except subprocess.CalledProcessError:
     return 1

+ 1 - 1
spring/src/main/java/com/techempower/spring/SampleApplication.java

@@ -3,7 +3,7 @@ package com.techempower.spring;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
 import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.boot.web.SpringBootServletInitializer;
+import org.springframework.boot.context.web.SpringBootServletInitializer;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 

+ 6 - 6
spring/src/main/java/com/techempower/spring/TomcatCustomizer.java

@@ -4,7 +4,7 @@ import org.apache.catalina.connector.Connector;
 import org.apache.coyote.AbstractProtocol;
 import org.apache.coyote.ProtocolHandler;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainerFactory;
+import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
 import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
 import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer;
 import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
@@ -22,14 +22,14 @@ public class TomcatCustomizer implements EmbeddedServletContainerCustomizer {
 	@Value("${tomcat.connector.maxConnections}")
 	private int maxConnections;
 
+    @Value("${tomcat.connector.acceptCount}")
+    private int acceptCount;
+
 	@Value("${tomcat.connector.maxKeepAliveRequests}")
 	private int maxKeepAliveRequests;
 
-	@Value("${tomcat.connector.minSpareThreads}")
-	private int minSpareThreads;
-
 	@Override
-	public void customize(ConfigurableEmbeddedServletContainerFactory factory) {
+	public void customize(ConfigurableEmbeddedServletContainer factory) {
 
 		customizeTomcatConnector((TomcatEmbeddedServletContainerFactory) factory);
 	}
@@ -45,10 +45,10 @@ public class TomcatCustomizer implements EmbeddedServletContainerCustomizer {
 						if (handler instanceof AbstractProtocol) {
 							AbstractProtocol protocol = (AbstractProtocol) handler;
 							protocol.setMaxThreads(maxThreads);
-							protocol.setMinSpareThreads(minSpareThreads);
 							protocol.setConnectionTimeout(connectionTimeout);
 							protocol.setMaxConnections(maxConnections);
 						}
+						connector.setProperty("acceptCount", acceptCount+"");
 						connector.setProperty("maxKeepAliveRequests", maxKeepAliveRequests+"");
 					}
 				}

+ 13 - 5
spring/src/main/resources/application.yml

@@ -13,15 +13,23 @@ spring:
     hibernate:
       naming-strategy: org.hibernate.cfg.EJB3NamingStrategy
       ddl-auto: validate
-    open_in_view: true
+    open_in_view: false
 
 tomcat:
   connector:
-    maxThreads: 200
-    minSpareThreads: 100
+    # reduce context switching; Intel Xeons have 12 threads
+    maxThreads: 12
     connectionTimeout: 20000
-    maxConnections: 200
-    maxKeepAliveRequests: 2000
+    # maximum: 16K connections test
+    maxConnections: 20000
+    # handle initial connection spike
+    acceptCount: 20000
+    # avoid running out of ports due to connections stuck in TIME_WAIT state
+    maxKeepAliveRequests: -1
+
+server:
+  tomcat:
+    access_log_enabled: false
 
 ---
 spring: