1

Should I implement a pool of service actors, every one of which holds single DB connection? I'm very new to Akka and not sure how to implement DB-related work.

My context: I'm creating a distributed game server using akka-cluster.

sp-niemand
  • 225
  • 4
  • 10
  • DB connection pool (I would recommend HikariCP) should be configured on Slick level - http://slick.typesafe.com/doc/3.1.0/database.html#connection-pools – Sergiy Prydatchenko Dec 03 '15 at 20:41
  • @SergiyPrydatchenko, yes, Slick Database object has its own connection pool. But I wonder, what is the best practice for using it with Akka actors? Should I use an instance of Database on every node of my cluster and share it between all actors of this node if they need to access DB? If I understand correctly, actors are used to share no data between them. – sp-niemand Dec 04 '15 at 01:06
  • @spniemand Yes, you can create an instance of Database on every node of my cluster and share it between all actors of this node. You should not share data, but Database is not data. :) But you should beware of doing [blocking calls inside Actors]( http://stackoverflow.com/questions/19944034/blocking-calls-in-akka-actors). – Sergiy Prydatchenko Dec 04 '15 at 19:26
  • @SergiyPrydatchenko, and what about simultaneous operations on shared `Database` instance? Is `Database` class thread-safe? – sp-niemand Dec 06 '15 at 23:29

0 Answers0