This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-27
Channels
- # adventofcode (3)
- # aws (1)
- # beginners (79)
- # boot-dev (1)
- # clara (50)
- # cljs-dev (7)
- # clojure (60)
- # clojure-austin (1)
- # clojure-germany (1)
- # clojure-greece (1)
- # clojure-russia (3)
- # clojure-spec (43)
- # clojure-uk (1)
- # clojurescript (76)
- # data-science (1)
- # datomic (26)
- # docs (2)
- # emacs (7)
- # fulcro (10)
- # hoplon (1)
- # instaparse (1)
- # lumo (3)
- # off-topic (16)
- # om (3)
- # onyx (2)
- # re-frame (3)
- # reagent (24)
- # ring-swagger (10)
- # shadow-cljs (15)
- # spacemacs (1)
- # sql (16)
- # uncomplicate (12)
- # unrepl (47)
can anyone recommends me a JDBC connection pool? im having strange issues using c3p0
like msgs `com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet successfully received from the server was 125,692 milliseconds ago. The last packet sent successfully to the server was 7 milliseconds ago.`
@plins We use c3p0 in production and have no problems -- but you have to configure it properly.
Which database are you using?
Here's the configuration we use in production -- the main thing to look at are your timeouts for idle and test connections
cpds (doto (ComboPooledDataSource.)
(.setDataSourceName dsn-name)
(.setDriverClass "com.mysql.jdbc.Driver")
(.setJdbcUrl jdbc-url)
(.setUser user)
(.setPassword password)
;; pool size (default is 3 and 15):
(.setMinPoolSize min-pool)
(.setMaxPoolSize max-pool)
(.setNumHelperThreads num-helpers)
;; initial pool size default is 3 but actual pool size
;; must be between minimum and maximum pool size
(.setInitialPoolSize min-pool)
;; expire excess connections after 10 mins of inactivity:
(.setMaxIdleTimeExcessConnections (* 10 60))
;; expire connections after 61 minutes of inactivity:
(.setMaxIdleTime (* 61 60))
;; idle connection testing
(.setAutomaticTestTable "c3p0connection")
(.setTestConnectionOnCheckin true)
(.setIdleConnectionTestPeriod (* 11 60))
;; unreturned (app leakage) get zapped after an hour:
(.setUnreturnedConnectionTimeout (* 59 60)))]
@plins also, generally, when hitting a problem like this I’ve had the most success with googling how to address the issue in java - the translation to clojure is always trivial and the problems are identical
MySQL also has an issue that if you don't explicitly time things out it messes up connections after eight hours I believe (we hit that initially before we added all those timeouts).
(I’ve also used c3p0 with no issue)
But we've had this configuration in production for years now with heavy traffic -- powering over 100 dating sites with millions of users 🙂
Mostly ethnic verticals... http://arablounge.com, http://soulsingles.com, http://lovingbbw.com, http://eligiblegreeks.com
It's an... interesting... business to be in. With some very specific data challenges at times 🙂