私のconnection.pool_sizeには何が妥当な数字になるのだろうか?それはどのような側面に関連していますか?また、サイズが定義されたらアプリケーションをテストする方法も知っておく必要があります。データベース接続プールの妥当なサイズの確認方法と検証方法
私のアプリケーションは、100人以上のユーザーが同時に使用する予定で、データベースに20を超えるテーブルがあります。私のデータベースはMySQLであり、少なくとも12のシステムは私のアプリケーションを同時に使用しています。もっと知る必要がある場合はお知らせください。
また、接続プールのサイズを定義するのに役立ちますが、それでも妥当な数値がわからない場合は、次のものも見つかりました。
Hibernate's own connection pooling algorithm is, however, quite rudimentary.
It is intended to help you get started and is not intended for use in a production
system, or even for performance testing. You should use a third party pool for
best performance and stability. Just replace the hibernate.connection.pool_size
property with connection pool specific settings. This will turn off Hibernate's
internal pool. For example, you might like to use c3p0.
connection.pool_size indicates the maximum number of pooled connections. So it is
better to keep it at a logical count. It depends on your application and DB how
much it can handle. 10 is a reasonable count that will typically used as it is
sufficient for most cases.
私HibernateUtilのはあなたが使用するどのくらいの最小値と最大接続プール実際のフレームワークでそれをテストする必要があります
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
public class HibernateUtil {
private static ServiceRegistry serviceRegistry;
private static final ThreadLocal<Session> threadLocal = new ThreadLocal();
private static SessionFactory sessionFactory;
private static SessionFactory configureSessionFactory() {
try {
Configuration configuration = new Configuration();
configuration.configure();
serviceRegistry = new
ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
} catch (HibernateException e) {
System.out.append("** Exception in SessionFactory **");
e.printStackTrace();
}
return sessionFactory;
}
static {
try {
sessionFactory = configureSessionFactory();
} catch (Exception e) {
System.err.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
private HibernateUtil() {
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static Session getSession() throws HibernateException {
Session session = threadLocal.get();
if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
rebuildSessionFactory();
}
session = (sessionFactory != null) ? sessionFactory.openSession() : null;
threadLocal.set(session);
}
return session;
}
public static void rebuildSessionFactory() {
try {
sessionFactory = configureSessionFactory();
} catch (Exception e) {
System.err.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
public static void closeSession() throws HibernateException {
Session session = (Session) threadLocal.get();
threadLocal.set(null);
if (session != null) {
session.close();
}
}
}
一度に使用しているデータベースの種類とデータベースに接続するシステムの数はいくつですか? – Karthikeyan
@ Karthikeyanの質問が更新され、12のシステムが同時にそれを使用しており、データベースはmysql –