before ask question, sure has been asked before had hard time filling in proper terms find this. result unable find information. apologize if has been asked before.
consider following scenario: game server backed sql database player storage , logging. every time player logs in data retrieved , written. every few seconds (20 seconds or something) logs written database including changed data players.
i wondering how handle these connections. keeping connection open forever bad idea because mysql server closes after "inactivity".
opening connection each time works wondering if best approach or there possibility?
that connection pools for. try hikaricp, extremly fast. can use on top of plain jdbc, jpa or o/r mappers. keep set of connections open (pooling) , manage reuse, if have lot of concurrent connections.
if have store logs in database, there several logging frameworks, have funtions so. example logback has dbappender works on top of connection pools:
"..., sending 500 logging requests aforementioned mysql database takes around 0.5 seconds, average of 1 millisecond per request, tenfold improvement in performance." (source)
Comments
Post a Comment