jan-gerling / FLOCKA

1 stars 1 forks source link

Testing #9

Open jan-gerling opened 5 years ago

jan-gerling commented 5 years ago

@ABieniek please add more details here, such as testing procedures and help.

jan-gerling commented 5 years ago

I did some testing to estimate the performance of our current system, by creating users. Based on this article: https://hackernoon.com/what-to-do-with-5-000-000-akka-actors-381a915a0f78

Findings

1. 100000 create users called from UserService ~ 60 seconds 400000 create users called from UserService ~ 250 seconds

430000 leads to dead letters [UserCreated from UserActor]

2. 100000 create users called from UserActorSupervisor piping to it self ~ 61 seconds

3. 100000 create users called from UserActorSupervisor without piping ~ 63 seconds

4. 100000 create users called from UserActorSupervisor piping to it self without applying post conditions~ 62 seconds

Used Code:

def time[R](block: => R): R = {
    val t0 = System.nanoTime()
    val result = block    // call-by-name
    val t1 = System.nanoTime()
    val elapsedSeconds: Double = ((t1 - t0) / 1000000000)
    println("Elapsed time: " + elapsedSeconds + " seconds" )
    result
  }

var list = time {
        val Attempts: Int = 100000
        val populateResult = Source(1 to Attempts)
          .mapAsyncUnordered(32)(_ =>
            commandHandler(
              CreateUser(),
              generateUserId(),
              self,
              _ match {
                case UserCommunication.UserCreated(resultId) => true
                case _ => false })
          )
          .runWith(Sink.ignore)
        Await.ready(populateResult, Duration.Inf)
}

Notes:

clear out journal between each run (FLOCKA/target/example/journal)

jan-gerling commented 5 years ago

I did some more testing

Findings

with postman

1. The usual response time to create a new user is about 4ms. 2. trying to make 100.000 iterations for a request with postman will make it crash on my PC 3. there increased response times, whenever a new supervision is created => ~50ms for a response 4. first request to the system takes very long > 400ms

in code

1. the normal time to create a new user from user service is about 45 - 65 microseconds 2. memory comsumption is significantly lower, already by using multiple supervisors, I have no idea why 3. cpu utilization was quite low, about ~18 at max, this might be due to limitations with intellij

Remarks

1. Parallelisation has to be tested more. Any ideas on how to do this? 2. I think the average response time is reasonable so we should now try the setup with a sharded, distributed system.

jan-gerling commented 5 years ago

Simple tests for postman, to verify a user creation.

tests["User created"] = responseBody.has("UserCreated")
tests["Response time below 300ms"] = responseTime < 300