score:3
This blog post has some really good points why not to use Actor per DB connection.
In particular, it means you need to manage the concurrency level instead of letting the native connection pool to handle it for you. It also may mislead you to think your code runs in parallel while in fact your code runs serially.
score:24
1 - Does the databaseActors keep the connection open the all time?
Akka actors are stateful i.e., you can safely store state (in this case DB connection) inside an actor. You can either write you own connection management logic or use the one that is provided by the your database driver.
2 - How does it work together with connection Pooling as offered by many database?
3 - Shall we combine both, and have the DatabaseActors request a new connection from the pool each time they are solicited. If not, isn't it keeping a connection open at all time a bad thing to do?
You can combine both. Have an actor for each connection in the pool. Why do you think having a connection alive is a bad thing? Isn't the whole point of having a connection pool is to reuse resources (connections) and not pay the price of creating/destroying them every time.
4 - Can someone explain to me the subtle thing that make it an approach that avoid thread starvation. For instance using Play or spray, the handling of a request is an asynchronous task, however if that task need a database access and we send an ask to the DatabaseActor, does the block on the database Actor (if it occur) do not induce, a block in the asynchronous task, leading to possible thread starvation ?
If your database driver is blocking then you eventually have to block also. The recommended practice is to execute this blocking piece of code in a separate execution context/thread pool. Or if you have the option choose a datastore that has a reactive database driver (e.g., ReactiveMongo for MongoDB) which is completely async and non-blocking.
5 - Is it 100% sure the DB ACID property ensures the safety of the multiple read and write and therefore happens before relationship.
I don't understand what you mean by this.
6 - I'm using the semantic database also called triple store and make heavy using of semantic reasoning capability during my request. I also perform a lot of write access, any advise, concerning tuning parameters of pooling and actor numbers or dedicated execution context?
You should definitely use a different execution context. The turning of parameters really depends on your hardware configuration and other specifics of your software (type of database, remote db vs embedded db, requests/second etc).
I don't think there is a one size fits all when it comes to Akka dispatchers. It's more of an art. My only recommendation is that make sure you are not blocking anywhere in your code.
Source: stackoverflow.com
Related Query
- AKKA Actor and DataBase Operation
- Akka Actor ask and Type Safety
- Slick Database Sessions, Efficiency, and Threading in Akka
- Play & Akka and blocking threads for database access
- Akka Actor "ask" and "Await" with TimeoutException
- Get or create child Akka actor and ensure liveness
- The actor pattern with Akka and long running processes
- Akka FSM Actor with stashing and unstashing
- Java, Akka Actor and Bounded Mail Box
- Akka and concurrent Actor execution
- Akka FSM actor and round-robin routing
- Akka actors + Play! 2.0 Scala Edition best practices for spawning and bundling actor instances
- How can I resolve conflicting actor systems while testing akka-http and akka actors at the same spec file?
- Akka actor pipeline and congested store actor
- Scala akka typed: how to get ActorRef to Actor from it's instance and send message itself?
- Akka Stream and HTTP Scala: How to send Messages to an Actor from a Route
- Akka long-running initialization and crashing actor from within Future callback
- Share database code between akka sbt-project and scala-play project
- Does akka copy MDC from source actor to other actors and futures?
- Akka and Actor behavior interface
- Akka HTTP client and Akka actor performance tuning
- Akka router, Futures and blocking operation
- Ask an actor and let him respond when he reaches a particular state in Akka 2
- Play + Akka - Join the cluster and ask actor on another ActorSystem
- How to represent that an Akka actor is in a long running operation using FSM-s
- akka and testkit. Can't get actor children
- Akka Actor Searching and Streaming Events
- Akka Actor message memory and Garbage Collection
- How to send in Akka from outside of an actor and still be able to use sender
- akka streaming file lines to actor router and writing with single actor. how to handle the backpressure
More Query from same tag
- taskdef java.lang.VerifyError: Bad type on operand stack when TEAM CITY executes build
- Change a if-else-construct in a more functional style?
- Map for generic HList
- spark-shell cannot find the class to be extended
- Running SVD in Spark Scala
- How can I iterate to a scala map in order to save the contents in a Seq?
- Getting Value of Either
- Redis on spark: variable pipeline in class BinaryJedis cannot be accessed
- How to remove the fractional part from a dataframe column?
- Colons in Apache Spark application path
- Theta Sketch (Yahoo) on SnappyData
- How can I add a member to list(immutable) in scala?
- Partition rdd from text file while preserving header
- What does a lazy val do?
- Why does enabling the "Any Exception" break point in IDEA cause a ClassNotFoundException when launching Scala swing apps?
- JDT weaving is currently disabled
- sbt Task classpath
- Match String with List Items
- Derive column value from another row's column value Slick
- How to split and remove empty spaces before get the result
- Checking null vs. matching in a Java/Scala project
- Scala, Adding 2d arrays to a 3d array
- How set an hour with Calendar in scala
- How do I render 3d objects with 2d GUI (nifty-gui) correctly?
- Split list into multiple lists with fixed number of elements
- Scala compiler co- and contra-variance rules
- Play for Scala: Catch HTTP JSON request error
- Skip/Take with Spark SQL
- Why are evicted dependencies not excluded in sbt publish task
- xtext: Generate Scala stubs from workflow