Parcourir la source

Fix benchmark config and customize tomcat config

URLs listed in the benchmark_config file were wrong, since
the "/spring" prefix is gone now.

Also customized the Embedded Tomcat configuration for benchmark
purposes.
Brian Clozel il y a 12 ans
Parent
commit
6c4c4c1224

+ 6 - 6
spring/benchmark_config

@@ -3,12 +3,12 @@
   "tests": [{
     "default": {
       "setup_file": "setup",
-      "json_url": "/spring/json",
-      "db_url": "/spring/db",
-      "query_url": "/spring/queries?queries=",
-      "fortune_url": "/spring/fortunes",
-      "plaintext_url": "/spring/plaintext",
-      "update_url": "/spring/updates?queries=",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "fortune_url": "/fortunes",
+      "plaintext_url": "/plaintext",
+      "update_url": "/updates?queries=",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Fullstack",

+ 48 - 0
spring/src/main/java/com/techempower/spring/TomcatCustomizer.java

@@ -0,0 +1,48 @@
+package com.techempower.spring;
+
+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.EmbeddedServletContainerCustomizer;
+import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer;
+import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class TomcatCustomizer implements EmbeddedServletContainerCustomizer {
+
+	@Value("${tomcat.connector.maxThreads}")
+	private int maxThreads;
+
+	@Value("${tomcat.connector.connectionTimeout}")
+	private int connectionTimeout;
+
+	@Value("${tomcat.connector.maxConnections}")
+	private int maxConnections;
+
+	@Override
+	public void customize(ConfigurableEmbeddedServletContainerFactory factory) {
+
+		customizeTomcatConnector((TomcatEmbeddedServletContainerFactory) factory);
+	}
+
+	private void customizeTomcatConnector(TomcatEmbeddedServletContainerFactory factory) {
+
+		factory.addConnectorCustomizers(
+				new TomcatConnectorCustomizer() {
+					@Override
+					public void customize(Connector connector) {
+						ProtocolHandler handler = connector.getProtocolHandler();
+						if (handler instanceof AbstractProtocol) {
+							AbstractProtocol protocol = (AbstractProtocol) handler;
+							protocol.setMaxThreads(maxThreads);
+							protocol.setConnectionTimeout(connectionTimeout);
+							protocol.setMaxConnections(maxConnections);
+						}
+					}
+				}
+		);
+	}
+}

+ 8 - 1
spring/src/main/resources/application.yml

@@ -9,9 +9,16 @@ spring:
   jpa:
     show_sql: false
 
+tomcat:
+  connector:
+    maxThreads: 10000
+    connectionTimeout: 20000
+    maxConnections: -1
+
 ---
 spring:
   profiles: local
   datasource:
+    initialize: true
     driverClassName: org.h2.Driver
-    url: jdbc:h2:mem:framework_benchmark
+    url: jdbc:h2:mem:framework_benchmark