Akka , java , getting java.util.concurrent.timeoutexception futures timed out


(Nikhil 20) #1

Hello ,

when i run a load test on my api which uses akka sync actor (uses ask pattern with 20 sec a time out) code snippet below , api invokes an micro service with interacts with oracle DB for get operation … but during load test i see lot of time out exceptions , some times more failures occur , i dont see any error in external microservice or in oracle … but in my api where i do patter.ask , it throws time out exception , when i use fork join executor i see failures are quite minimal , but when i use thread pool executor i see more failures … please help me to figure out the issue … thanks …

code snippet :

Timeout timeout = new Timeout(Duration.create(interaction.getActorTimeOut(), TimeUnit.SECONDS));
Future<Object> future = Patterns.ask(ipsActorSystem.synchronousActor, interactionRequest, timeout);
Object result =  Await.result(future, timeout.duration());

**akka config: Fork join executor ,**

        "default-dispatcher": {
          "attempt-teamwork": "on",
          "default-executor": {
          "fallback": "fork-join-executor"
        },
        "executor": "fork-join-executor",
        "fork-join-executor": {
          "parallelism-factor": 50,
          "parallelism-max": 100,
          "parallelism-min": 10,
          "task-peeking-mode": "FIFO"
        },
        "mailbox-requirement": "",
        "shutdown-timeout": "1s",
        "throughput": 100,
        "throughput-deadline-time": "0ms",
        "type": "Dispatcher"
      },

Thread pool executor:

     "default-dispatcher": {
          "attempt-teamwork": "on",
          "default-executor": {
          "fallback": "thread-pool-executor"
        },
        "executor": "thread-pool-executor",
        "thread-pool-executor": {
			"fixed-pool-size" : 10
		},
        "mailbox-requirement": "",
        "shutdown-timeout": "1s",
        "throughput": 10,
        "throughput-deadline-time": "0ms",
        "type": "Dispatcher"
      },

(Patrik Nordwall) #2

Do you use Await or any other blocking of the threads. Don’t.
If you have to use blocking, e.g. interaction with legacy systems that don’t have async API (e.g. jdbc) then you must manage that blocking carefully as described in this section of the documentation: https://doc.akka.io/docs/akka/current/dispatchers.html#blocking-needs-careful-management