KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How does the actor model (in Akka) work when you need to perform I/O (ie. a database operation)? It is my understanding that a blocking operation will throw an exception (and essentially ruin all concurrency due to the evented nature of Netty, which Akka uses). Hence I would have to use a Future or something similar - however I don't understand the concurrency model. Can 1 actor be processing multiple message simultaneously? If an actor makes a blocking call in a future (ie. future.get() ) does that block only the current actor's execution; or will it prevent execution on all actors until the blocking call has completed? If it blocks all execution, how does using a future assist concurrency (ie. wouldn't invoking blocking calls in a future still amount to creating an actor and executing the blocking call)? What is the best way to deal with a multi-staged process (ie. read from the database; call a blocking webservice; read from the database; write to the database) where each step is dependent on the last? The basic context is this: I'm using a Websocket server which will maintain thousands of sessions. Each session has some state (ie. authentication details, etc); The Javascript client will send a JSON-RPC message to the server, which will pass it to the appropriate session actor, which will execute it and return a result. Execution of the RPC call will involve some I/O and blocking calls. There will be a large number of concurrent requests (each user will be making a significant amount of requests over the WebSocket connection and there will be a lot of users). Is there a better way to achieve this?
Tags (comma-separated)
Save Edits
Cancel