From 4401dfbfc1ccf8bfaaaee7e7aaa04d3fecf3fa0c Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Mon, 13 Nov 2017 02:51:11 +0100 Subject: [PATCH] Update all play2-java benchmark projects (#3061) --- .../Java/play2-java/benchmark_config.json | 12 +- .../play2-java-ebean-hikaricp/.gitignore | 1 - .../play2-java-ebean-hikaricp/README.md | 14 +-- .../app/controllers/Application.java | 87 ++++++-------- .../app/inject/AppModule.java | 37 ------ .../app/models/Fortune.java | 15 ++- .../app/models/World.java | 33 +++-- .../app/utils/DatabaseExecutionContext.java | 15 +++ .../app/utils/Headers.java | 21 ---- .../app/utils/Predicate.java | 8 -- .../app/utils/Predicated.java | 26 ---- .../app/utils/PredicatedAction.java | 28 ----- .../play2-java-ebean-hikaricp/build.sbt | 7 +- .../conf/application.conf | 103 ++++++++-------- .../conf/logback.xml | 10 +- .../play2-java-ebean-hikaricp/conf/routes | 9 +- .../project/build.properties | 2 +- .../project/plugins.sbt | 5 +- .../play2-java-ebean-hikaricp/source_code | 19 ++- .../play2-java-jpa-hikaricp/README.md | 15 +-- .../app/controllers/Application.java | 110 ++++++----------- .../app/models/Fortune.java | 15 +-- .../app/models/World.java | 26 ++-- .../app/utils/DatabaseExecutionContext.java | 15 +++ .../app/utils/Headers.java | 21 ---- .../app/utils/Predicate.java | 8 -- .../app/utils/Predicated.java | 26 ---- .../app/utils/PredicatedAction.java | 23 ---- .../play2-java-jpa-hikaricp/build.sbt | 12 +- .../conf/META-INF/persistence.xml | 1 + .../conf/application.conf | 113 +++++++++--------- .../play2-java-jpa-hikaricp/conf/logback.xml | 12 +- .../play2-java-jpa-hikaricp/conf/routes | 8 +- .../project/build.properties | 2 +- .../project/plugins.sbt | 2 +- .../play2-java-jpa-hikaricp/source_code | 19 ++- .../Java/play2-java/play2-java/README.md | 2 +- .../app/controllers/Application.java | 10 +- .../play2-java/app/utils/Headers.java | 21 ---- .../Java/play2-java/play2-java/build.sbt | 9 +- .../play2-java/conf/application.conf | 9 +- .../play2-java/play2-java/conf/logback.xml | 12 +- .../Java/play2-java/play2-java/conf/routes | 8 +- .../play2-java/project/build.properties | 2 +- .../play2-java/play2-java/project/plugins.sbt | 2 +- .../Java/play2-java/play2-java/source_code | 6 +- 46 files changed, 362 insertions(+), 599 deletions(-) delete mode 100644 frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/inject/AppModule.java create mode 100644 frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/DatabaseExecutionContext.java delete mode 100644 frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Headers.java delete mode 100644 frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Predicate.java delete mode 100644 frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Predicated.java delete mode 100644 frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/PredicatedAction.java create mode 100644 frameworks/Java/play2-java/play2-java-jpa-hikaricp/app/utils/DatabaseExecutionContext.java delete mode 100644 frameworks/Java/play2-java/play2-java-jpa-hikaricp/app/utils/Headers.java delete mode 100644 frameworks/Java/play2-java/play2-java-jpa-hikaricp/app/utils/Predicate.java delete mode 100644 frameworks/Java/play2-java/play2-java-jpa-hikaricp/app/utils/Predicated.java delete mode 100644 frameworks/Java/play2-java/play2-java-jpa-hikaricp/app/utils/PredicatedAction.java delete mode 100644 frameworks/Java/play2-java/play2-java/app/utils/Headers.java diff --git a/frameworks/Java/play2-java/benchmark_config.json b/frameworks/Java/play2-java/benchmark_config.json index e583c700335..cc7775d634c 100644 --- a/frameworks/Java/play2-java/benchmark_config.json +++ b/frameworks/Java/play2-java/benchmark_config.json @@ -13,11 +13,11 @@ "database": "None", "approach": "Realistic", "classification": "Fullstack", - "platform": "Netty", + "platform": "Akka", "webserver": "None", "database_os": "Linux", "notes": "", - "versus": "netty", + "versus": "akka-http", "port": "9000", "json_url": "/json", "plaintext_url": "/plaintext" @@ -33,11 +33,11 @@ "database": "MySQL", "approach": "Realistic", "classification": "Fullstack", - "platform": "Netty", + "platform": "Akka", "webserver": "None", "database_os": "Linux", "notes": "", - "versus": "netty", + "versus": "akka-http", "port": "9000", "db_url": "/db", "query_url": "/queries?queries=", @@ -55,11 +55,11 @@ "database": "MySQL", "approach": "Realistic", "classification": "Fullstack", - "platform": "Netty", + "platform": "Akka", "webserver": "None", "database_os": "Linux", "notes": "", - "versus": "netty", + "versus": "akka-http", "port": "9000", "db_url": "/db", "query_url": "/queries?queries=", diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/.gitignore b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/.gitignore index 4252a308ffe..b5fc8054690 100644 --- a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/.gitignore +++ b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/.gitignore @@ -27,4 +27,3 @@ test-result server.pid *.iml *.eml - diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/README.md b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/README.md index b164a77dc87..33003f237a1 100644 --- a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/README.md +++ b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/README.md @@ -2,31 +2,19 @@ This is the Play portion of a [benchmarking test suite](../) comparing a variety of web development platforms. -### JSON Encoding Test - -* [JSON test controller](app/controllers/Application.java) - ### Data-Store/Database Mapping Test * [Database test controller](app/controllers/Application.java) * [Database World test model](app/models/World.java) * [Database Fortune test model](app/models/Fortune.java) -### Plain Text Test - -* [Plain text test controller](app/controllers/Application.java) - ## Infrastructure Software Versions The tests were run with: * Java 8 -* [Play 2.5.14](https://www.playframework.com/) +* [Play 2.6.7](https://www.playframework.com/) ## Test URLs -### JSON Encoding Test - -* http://localhost/json - ### Data-Store/Database Mapping Test * http://localhost/db diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/controllers/Application.java b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/controllers/Application.java index 93cbf631b93..48012ca6852 100644 --- a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/controllers/Application.java +++ b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/controllers/Application.java @@ -1,60 +1,42 @@ package controllers; -import com.google.inject.name.Named; -import models.Fortune; -import models.World; -import play.Play; -import play.libs.F; -import play.libs.Json; -import play.mvc.Controller; -import play.mvc.Result; -import play.mvc.With; -import scala.concurrent.ExecutionContext; -import utils.Headers; -import utils.Predicate; -import utils.Predicated; - import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Random; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.ThreadPoolExecutor; + import javax.inject.Inject; -@With(Headers.class) -public class Application extends Controller { +import models.Fortune; +import models.World; +import play.libs.Json; +import play.mvc.Controller; +import play.mvc.Result; +import utils.DatabaseExecutionContext; - private static final int TEST_DATABASE_ROWS = 10000; +public class Application extends Controller { - @Inject @Named("dbEc") private ExecutionContext dbEc; + private final DatabaseExecutionContext dbEc; - // If the thread-pool used by the database grows too large then our server - // is probably struggling, and we should start dropping requests. Set - // the max size of our queue something above the number of concurrent - // connections that we need to handle. - public static class IsDbAvailable implements Predicate { - @Inject @Named("dbTpe") private ThreadPoolExecutor tpe; - @Override - public boolean condition() { - return tpe.getQueue().size() <= 1024; - } + @Inject + public Application(final DatabaseExecutionContext dbEc) { + this.dbEc = dbEc; } - @Predicated(predicate = IsDbAvailable.class, failed = SERVICE_UNAVAILABLE) - public F.Promise db() { - return getRandomWorlds(1).map(worlds -> ok(Json.toJson(worlds.get(0)))); + public CompletionStage db() { + return getRandomWorlds(1).thenApply(worlds -> ok(Json.toJson(worlds.get(0)))); } - @Predicated(predicate = IsDbAvailable.class, failed = SERVICE_UNAVAILABLE) - public F.Promise queries(final String queryCountString) { - return getRandomWorlds(queryCount(queryCountString)).map(worlds -> ok(Json.toJson(worlds))); + public CompletionStage queries(final String queries) { + return getRandomWorlds(queryCount(queries)).thenApply(worlds -> ok(Json.toJson(worlds))); } - @Predicated(predicate = IsDbAvailable.class, failed = SERVICE_UNAVAILABLE) - public F.Promise fortunes() { - return F.Promise.promise(() -> { - List fortunes = Fortune.findAll(); + public CompletionStage fortunes() { + return CompletableFuture.supplyAsync(() -> { + final List fortunes = Fortune.findAll(); fortunes.add(new Fortune("Additional fortune added at request time.")); Collections.sort(fortunes, (f1, f2) -> f1.message.compareTo(f2.message)); @@ -62,24 +44,23 @@ public F.Promise fortunes() { }, dbEc); } - @Predicated(predicate = IsDbAvailable.class, failed = SERVICE_UNAVAILABLE) - public F.Promise update(final String queryCountString) { - return getRandomWorlds(queryCount(queryCountString)).map(worlds -> { - Random random = ThreadLocalRandom.current(); - for (World world : worlds) { + public CompletionStage update(final String queries) { + return getRandomWorlds(queryCount(queries)).thenApplyAsync(worlds -> { + final Random random = ThreadLocalRandom.current(); + for (final World world : worlds) { world.randomNumber = (long) (random.nextInt(10000) + 1); } - List updatedWorlds = World.save(worlds); + final List updatedWorlds = World.save(worlds); return ok(Json.toJson(updatedWorlds)); }, dbEc); } - private int queryCount(String queryCountString) { + private int queryCount(final String queryCountString) { int queryCount; try { queryCount = Integer.parseInt(queryCountString, 10); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { queryCount = 1; } if (queryCount < 1) { @@ -91,13 +72,13 @@ private int queryCount(String queryCountString) { return queryCount; } - private F.Promise> getRandomWorlds(final int n) { - return F.Promise.promise(() -> { - Random random = ThreadLocalRandom.current(); - List worlds = new ArrayList<>(n); + private CompletionStage> getRandomWorlds(final int n) { + return CompletableFuture.supplyAsync(() -> { + final Random random = ThreadLocalRandom.current(); + final List worlds = new ArrayList<>(n); for (int i = 0; i < n; ++i) { - long randomId = random.nextInt(TEST_DATABASE_ROWS) + 1; - World world = World.find(randomId); + long randomId = random.nextInt(10000) + 1; + final World world = World.find(randomId); worlds.add(world); } return worlds; diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/inject/AppModule.java b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/inject/AppModule.java deleted file mode 100644 index e6b4a21bbf4..00000000000 --- a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/inject/AppModule.java +++ /dev/null @@ -1,37 +0,0 @@ -package inject; - -import akka.dispatch.ExecutionContexts; -import com.google.inject.AbstractModule; -import com.google.inject.Provides; -import com.google.inject.Singleton; -import com.google.inject.name.Named; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import play.Configuration; -import play.core.NamedThreadFactory; -import scala.concurrent.ExecutionContext; - -public class AppModule extends AbstractModule { - - protected void configure() { - } - - @Provides @Singleton @Named("dbTpe") - public ThreadPoolExecutor provideThreadPoolExecutor(Configuration configuration) { - int partitionCount = configuration.getInt("db.default.partitionCount"); - int maxConnections = partitionCount * configuration.getInt("db.default.maxConnectionsPerPartition"); - int minConnections = partitionCount * configuration.getInt("db.default.minConnectionsPerPartition"); - - return new ThreadPoolExecutor(minConnections, maxConnections, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue<>(), - new NamedThreadFactory("dbEc")); - } - - @Provides @Singleton @Named("dbEc") - public ExecutionContext provideExecutionContext(@Named("dbTpe") ThreadPoolExecutor tpe) { - return ExecutionContexts.fromExecutorService(tpe); - } - -} diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/models/Fortune.java b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/models/Fortune.java index 6789de63e3f..4c911634bcb 100644 --- a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/models/Fortune.java +++ b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/models/Fortune.java @@ -1,15 +1,18 @@ package models; -import com.avaje.ebean.Ebean; -import com.avaje.ebean.Model; +import java.util.List; import javax.persistence.Entity; import javax.persistence.Id; -import java.util.List; + +import io.ebean.Finder; +import io.ebean.Model; @Entity public class Fortune extends Model { + private static final Finder find = new Finder<>(Fortune.class); + @Id public Long id = 0L; @@ -18,11 +21,11 @@ public class Fortune extends Model { public Fortune() { } - public Fortune(String message) { + public Fortune(final String message) { this.message = message; } public static List findAll() { - return Ebean.find(Fortune.class).findList(); + return find.all(); } -} \ No newline at end of file +} diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/models/World.java b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/models/World.java index 1860f8e77a4..8557dc33f9e 100644 --- a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/models/World.java +++ b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/models/World.java @@ -1,30 +1,47 @@ package models; -import com.avaje.ebean.Ebean; -import com.avaje.ebean.Model; +import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; -import java.util.List; + +import io.ebean.Finder; +import io.ebean.Model; +import io.ebean.Transaction; @Entity public class World extends Model { + private static final Finder find = new Finder<>(World.class); + @Id public Long id; @Column(name = "randomNumber") public Long randomNumber; - public static World find(Long id) { - return Ebean.find(World.class, id); + public static World find(final Long id) { + return find.byId(id); } public static List save(final List worlds) { - worlds.forEach(Ebean::update); + final int batchSize = 25; + final int batches = ((worlds.size() / batchSize) + 1); + for ( int i = 0 ; i < batches ; ++i ) { + final Transaction transaction = World.db().beginTransaction(); + try { + transaction.setBatchMode(true); + transaction.setBatchSize(batchSize); + for(int j = i * batchSize ; j < Math.min((i + 1) * batchSize, worlds.size()); ++j) { + World.db().update(worlds.get(j), transaction); + } + transaction.commit(); + } finally { + transaction.end(); + } + } return worlds; } - -} \ No newline at end of file +} diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/DatabaseExecutionContext.java b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/DatabaseExecutionContext.java new file mode 100644 index 00000000000..4b095aa512c --- /dev/null +++ b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/DatabaseExecutionContext.java @@ -0,0 +1,15 @@ +package utils; + +import javax.inject.Inject; + +import akka.actor.ActorSystem; +import play.libs.concurrent.CustomExecutionContext; + +public class DatabaseExecutionContext extends CustomExecutionContext { + + @Inject + public DatabaseExecutionContext(final ActorSystem actorSystem) { + super(actorSystem, "database.dispatcher"); + } + +} diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Headers.java b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Headers.java deleted file mode 100644 index 54e23372b1c..00000000000 --- a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Headers.java +++ /dev/null @@ -1,21 +0,0 @@ -package utils; - -import java.util.concurrent.CompletionStage; -import org.joda.time.DateTime; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; -import play.mvc.Action; -import play.mvc.Http; -import play.mvc.Result; - -public class Headers extends Action.Simple { - - private static final DateTimeFormatter RFC_1123_DATE_TIME = DateTimeFormat.forPattern("EEE, dd MMM yyyy HH:mm:ss 'GMT'").withZoneUTC(); - - @Override - public CompletionStage call(Http.Context context) { - context.response().setHeader("Server", "Play2"); - context.response().setHeader("Date", RFC_1123_DATE_TIME.print(new DateTime())); - return delegate.call(context); - } -} diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Predicate.java b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Predicate.java deleted file mode 100644 index aa7d159676e..00000000000 --- a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Predicate.java +++ /dev/null @@ -1,8 +0,0 @@ -package utils; - -/** - * Predicates for PredicatedActions. - */ -public interface Predicate { - boolean condition(); -} diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Predicated.java b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Predicated.java deleted file mode 100644 index 99efc4555f5..00000000000 --- a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Predicated.java +++ /dev/null @@ -1,26 +0,0 @@ -package utils; - -import play.mvc.With; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Declares a composing action that will check for a condition before deciding on whether to proceed with the request. - */ -@With(PredicatedAction.class) -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface Predicated { - /** - * The condition. - */ - Class predicate(); - - /** - * The http status code to return if the condition fails. - */ - int failed(); -} diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/PredicatedAction.java b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/PredicatedAction.java deleted file mode 100644 index 45b4383f548..00000000000 --- a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/PredicatedAction.java +++ /dev/null @@ -1,28 +0,0 @@ -package utils; - -/** - * A predicated action is one where a condition must be satisfied in order to proceed with the request. If the - * condition is not satisfied then a supplied status result is yielded. - */ - -import com.google.inject.Injector; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import javax.inject.Inject; -import play.mvc.Action; -import play.mvc.Http; -import play.mvc.Result; - -public class PredicatedAction extends Action { - - @Inject private Injector injector; - - @Override - public CompletionStage call(final Http.Context ctx) { - final Predicate p = injector.getInstance(configuration.predicate()); - if (p.condition()) { - return delegate.call(ctx); - } - return CompletableFuture.supplyAsync(() -> status(configuration.failed())); - } -} diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/build.sbt b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/build.sbt index d4c830d98f8..95ab3b84276 100644 --- a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/build.sbt +++ b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/build.sbt @@ -4,11 +4,10 @@ version := "1.0-SNAPSHOT" lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean) -scalaVersion := "2.11.7" +scalaVersion := "2.12.4" libraryDependencies ++= Seq( + guice, javaJdbc, - "mysql" % "mysql-connector-java" % "5.1.38" + "mysql" % "mysql-connector-java" % "5.1.44" ) - -routesGenerator := InjectedRoutesGenerator diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/conf/application.conf b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/conf/application.conf index c5206db96b1..27a59fd0021 100644 --- a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/conf/application.conf +++ b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/conf/application.conf @@ -4,66 +4,73 @@ # Secret key # ~~~~~ # The secret key is used to secure cryptographics functions. -# If you deploy your application to several instances be sure to use the same key! -play.crypto.secret="RItx1I:80?W@]8GAtPDuF8Ydd3mXM85p/<7og]Q;uBOdijQAauRDgu73B6`wQP59" +play.http.secret.key = "RItx1I:80?W@]8GAtPDuF8Ydd3mXM85p/<7og]Q;uBOdijQAauRDgu73B6`wQP59" # The application languages # ~~~~~ -application.langs="en" +play.i18n.langs = [ "en" ] -# Global object class -# ~~~~~ -# Define the Global object class for this application. -# Default to Global in the root package. -# global=Global - -# The dependency injection modules -play.modules.enabled += "inject.AppModule" +# Disable default filters +play.filters.enabled = [ ] -# Database configuration -# ~~~~~ -# You can declare as many datasources as you want. -# By convention, the default datasource is named `default` -# -# db.default.driver=org.h2.Driver -# db.default.url="jdbc:h2:mem:play" -# db.default.user=sa -# db.default.password= -# -# You can expose this datasource via JNDI if needed (Useful for JPA) -# db.default.jndiName=DefaultDS +play.server.akka.server-header = "Play2" -db.default.driver= com.mysql.jdbc.Driver -db.default.url="jdbc:mysql://TFB-database:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true" -db.default.username=benchmarkdbuser -db.default.password=benchmarkdbpass -db.default.jndiName=DefaultDS -jpa.default=defaultPersistenceUnit +# Number of database connections +# https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing +# db connections = ((physical_core_count * 2) + effective_spindle_count) +# The TechEmpower benchmark environment uses 2 x 4-Core E5520 CPUs in the database server +# That is 8 physical cores +# https://www.techempower.com/benchmarks/#section=environment +fixedConnectionPool = 17 -db.default.partitionCount=4 +database.dispatcher { + executor = "thread-pool-executor" + throughput = 1 + thread-pool-executor { + fixed-pool-size = ${fixedConnectionPool} + } +} -# The number of connections to create per partition. Setting this to -# 5 with 3 partitions means you will have 15 unique connections to the -# database.. -# -# This value maps to the maximumPoolSize for HickariCP (db.default.partitionCount * db.default.maxConnectionsPerPartition) -db.default.maxConnectionsPerPartition=64 - -# The number of initial connections, per partition. -# -# This maps to the minimumIdle connections for HikariCP (db.default.partitionCount * db.default.minConnectionsPerPartition) -db.default.minConnectionsPerPartition=64 - -dbplugin=disabled - -# Evolutions +# Database configuration # ~~~~~ -# You can disable evolutions if needed -evolutionplugin=disabled +# You can declare as many datasources as you want. +# By convention, the default datasource is named `default` +db { + default { + # https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration + url = "jdbc:mysql://TFB-database:3306/hello_world" + username = "benchmarkdbuser" + password = "benchmarkdbpass" + hikaricp { + dataSource { + cachePrepStmts=true + prepStmtCacheSize=250 + prepStmtCacheSqlLimit=2048 + useServerPrepStmts=true + useLocalSessionState=true + useLocalTransactionState=true + rewriteBatchedStatements=true + cacheResultSetMetadata=true + cacheServerConfiguration=true + cacheCallableStmts=true + callableStmtCacheSize=250 + elideSetAutoCommits=true + maintainTimeStats=false + alwaysSendSetIsolation=false + zeroDateTimeBehavior="convertToNull" + traceProtocol=false + jdbcCompliantTruncation=false + useUnbufferedInput=false + #useReadAheadInput=false + } + maximumPoolSize = ${fixedConnectionPool} + } + } +} # Ebean configuration # ~~~~~ # You can declare as many Ebean servers as you want. # By convention, the default server is named `default` # -ebean.default="models.*" +ebean.default = [ "models.*" ] diff --git a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/conf/logback.xml b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/conf/logback.xml index 743d9d93da4..42824914eba 100644 --- a/frameworks/Java/play2-java/play2-java-ebean-hikaricp/conf/logback.xml +++ b/frameworks/Java/play2-java/play2-java-ebean-hikaricp/conf/logback.xml @@ -4,10 +4,16 @@ - %coloredLevel - %logger - %message%n%xException + %coloredLevel %logger{15} - %message%n%xException{10} + + 500 + 0 + + +