connection-pooling

Analyzing Connection Closed Exception in Spring/JPA/Mysql/Tomcat app

风格不统一 提交于 2019-11-28 23:32:31
PROBLEM I have recently been put in charge of a Java web application with code already written and in place. The app receives moderately high traffic and has peak hours of traffic between 11am to 3pm everyday. The application uses Spring, JPA(Hibernate), MYSQL DB. Spring has been configured to use tomcat jdbc connection pool to make connections to the DB. (Details of configuration at the end of the post) For the past few days, during the application's peak load hours, the application has been going down due to tomcat going unresponsive to requests. It has required tomcat to be restarted

Apache PoolingHttpClientConnectionManager throwing illegal state exception

对着背影说爱祢 提交于 2019-11-28 23:22:30
Here is how I use it - private static final PoolingHttpClientConnectionManager connPool; static { connPool = new PoolingHttpClientConnectionManager(); // Increase max total connection to 200 connPool.setMaxTotal(200);//configurable through app.properties // Increase default max connection per route to 50 connPool.setDefaultMaxPerRoute(20);//configurable through app.properties } CloseableHttpClient httpClient = HttpClients.custom() .setConnectionManager(connPool) .build(); ALso I have put a finally block around http GET - finally { try { httpClient.close(); } catch (IOException e) { LOGGER

Initialcontext in a standalone Java program

为君一笑 提交于 2019-11-28 23:14:23
I'm using a JNDI for creating tomcat connection pool. It works great in a web application. I believe the InitialContext is provided by the tomcat server. Context initContext = new InitialContext(); Context envContext = (Context)initContext.lookup("java:/comp/env"); dataSource = (DataSource)envContext.lookup("jdbc/testdb"); But when I try to call the same utility from a standalone Java program, the initContext object is null. How can I explicitly provide all the necessary properties that Context object is expecting. Error : javax.naming.NoInitialContextException: Need to specify class name in

JDBC Connection Pooling: Connection Reuse?

余生长醉 提交于 2019-11-28 22:58:49
问题 As per my understanding, JDBC Connection Pooling (at a basic level) works this way: create connections during app initialization and put in a cache provide these cached connections on demand to the app a separate thread maintains the Connection Pool, performing activities like: discard connections that have been used (closed) create new connections and add to the cache to maintain a specific count of connections But, whenever I hear the term "connection reuse" in a JDBC Connection Pooling

Ideal settings for pgbouncer with Django's CONN_MAX_AGE

一世执手 提交于 2019-11-28 22:30:39
问题 I'm running a multi-tennant website, where I would like to reduce the overhead of creating a PostgreSQL connection per request. Django's CONN_MAX_AGE allows this, at the expense of creating a lot of open idle connections to PostgreSQL (8 workers * 20 threads = 160 connections). With 10MB per connection, this consumes a lot of memory. The main purpose is reducing connection-time overhead. Hence my questions: Which setup should I use for such solution? (PgBouncer?) Can I use 'transaction' pool

http request with timeout, maximum size and connection pooling

前提是你 提交于 2019-11-28 21:57:52
I'm looking for a way in Python (2.7) to do HTTP requests with 3 requirements: timeout (for reliability) content maximum size (for security) connection pooling (for performance) I've checked quite every python HTTP librairies, but none of them meet my requirements. For instance: urllib2: good, but no pooling import urllib2 import json r = urllib2.urlopen('https://github.com/timeline.json', timeout=5) content = r.read(100+1) if len(content) > 100: print 'too large' r.close() else: print json.loads(content) r = urllib2.urlopen('https://github.com/timeline.json', timeout=5) content = r.read

How would you test a Connection Pool

限于喜欢 提交于 2019-11-28 21:34:49
I have implemented a very simple ConnectionPool in Java. It has no fancy features, just get/release connection methods. How can I test it is working? I know there are plenty of connection Pools ready to use out there, which are much more reliable than what I'll do, but I am just trying to practice to understand how connections Pool work. Thank you! Here is the code in case it helps: public class ConnectionPoolImpl implements ConnectionPool { private Vector<PooledConnection> connections; // The connections container String url; String username; String password; /** * Instanciates a new

C3P0 apparent deadlock when the threads are all empty?

感情迁移 提交于 2019-11-28 20:16:15
I'm using C3P0 as a connection pool in Tomcat, and I'm seeing very worrying errors: 2010-09-16 13:25:00,160 [Timer-0] WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@43502400 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! 2010-09-16 13:25:01,407 [Timer-0] WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@43502400 -- APPARENT DEADLOCK!!! Complete Status: Managed Threads: 10 Active Threads: 0 Active Tasks: Pending

Java Database connection pool (BoneCP vs DBPool vs c3p0)

◇◆丶佛笑我妖孽 提交于 2019-11-28 20:12:29
问题 For a Java app outside of a J2EE container, which connection pool library is the best? I heard c3p0 is getting outdated. Jakarta's common pool library is no longer under development Therefore I'm left with BoneCP and DBPool. From what I can tell both have limited activity. The main difference I can see is performance, which BoneCP seems to win out with. However the documentation is pretty weak. Which database pool library have you used in the real world and why? What was the good and bad? 回答1

JDBC Connection pooling using C3P0

允我心安 提交于 2019-11-28 19:46:56
问题 Following is my helper class to get DB connection: I've used the C3P0 connection pooling as described here. public class DBConnection { private static DataSource dataSource; private static final String DRIVER_NAME; private static final String URL; private static final String UNAME; private static final String PWD; static { final ResourceBundle config = ResourceBundle .getBundle("props.database"); DRIVER_NAME = config.getString("driverName"); URL = config.getString("url"); UNAME = config