Mysql CP performance enhancements
This commit is contained in:
parent
c6b35688eb
commit
9fa5f2beea
@ -12,6 +12,7 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
|
import fr.xephi.authme.util.RuntimeUtils;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
|
|
||||||
import java.sql.Blob;
|
import java.sql.Blob;
|
||||||
@ -100,6 +101,9 @@ public class MySQL implements DataSource {
|
|||||||
ds = new HikariDataSource();
|
ds = new HikariDataSource();
|
||||||
ds.setPoolName("AuthMeMYSQLPool");
|
ds.setPoolName("AuthMeMYSQLPool");
|
||||||
|
|
||||||
|
// Pool size
|
||||||
|
ds.setMaximumPoolSize(RuntimeUtils.getCoreCount());
|
||||||
|
|
||||||
// Database URL
|
// Database URL
|
||||||
ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
|
ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
|
||||||
|
|
||||||
@ -118,7 +122,7 @@ public class MySQL implements DataSource {
|
|||||||
|
|
||||||
// Caching
|
// Caching
|
||||||
ds.addDataSourceProperty("cachePrepStmts", "true");
|
ds.addDataSourceProperty("cachePrepStmts", "true");
|
||||||
ds.addDataSourceProperty("prepStmtCacheSize", "250");
|
ds.addDataSourceProperty("prepStmtCacheSize", "275");
|
||||||
ds.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
ds.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||||
|
|
||||||
ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!");
|
ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!");
|
||||||
|
|||||||
7
src/main/java/fr/xephi/authme/util/RuntimeUtils.java
Normal file
7
src/main/java/fr/xephi/authme/util/RuntimeUtils.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package fr.xephi.authme.util;
|
||||||
|
|
||||||
|
public class RuntimeUtils {
|
||||||
|
public static int getCoreCount() {
|
||||||
|
return Runtime.getRuntime().availableProcessors();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user