Skip to content

Instantly share code, notes, and snippets.

View aludwiko's full-sized avatar

Andrzej Ludwikowski aludwiko

View GitHub Profile
It doesn’t matter if you are from JVM, .Net, PHP or else-world. If you need to test the performance - it will be a challenging task, especially nowadays with microservices architectures, clusters and very complex systems. I would like to address the most common pitfalls in this area. Share my experience gained through demanding experiments and quite often frustrating failures. Although most of the examples come from the JVM world, the aim of this presentation is to show some universal problems, laws and best practices that rule this very specific kind of testing.
@aludwiko
aludwiko / PersistenceQuery.scala
Last active March 9, 2018 14:26
Persistence Query
val eventJournal = PersistenceQuery(system).readJournalFor[CassandraReadJournal](CassandraReadJournal.Identifier)
eventJournal
.eventsByPersistenceId(persistenceId, startingSequenceNr, Long.MaxValue)
.map {
case EventEnvelope(_, _, sequenceNr, event: DomainEvent) => {
(sequenceNr, event)
}
}
.via(sendEventToKafka)
Value Percentile TotalCount 1/(1-Percentile)
0 0.000000000000 970 1.00
63 0.500000000000 64196 2.00
127 0.750000000000 100000 4.00
127 0.875000000000 100000 8.00
127 0.937500000000 100000 16.00
127 0.968750000000 100000 32.00
127 0.984375000000 100000 64.00
127 0.992187500000 100000 128.00
127 0.996093750000 100000 256.00
def printHdrHistogram(times: Seq[Int]) = {
val histogram = new Histogram(1000000, 0)
times.map(time => histogram.recordValue(time))
histogram.outputPercentileDistribution(System.out, 1, 1.0)
}
@aludwiko
aludwiko / results.txt
Created January 22, 2018 09:52
Dropwizzard Metrics results
-----------1
75: 75.000000
95: 95.000000
99: 98.000000
99.9: 1000.000000
max: 1000
-----------2
75: 75.000000
95: 94.000000
99: 98.000000
@aludwiko
aludwiko / DropWizardTest.scala
Last active January 30, 2018 15:16
Dropwizard Metrics
object DropWizardTest extends App {
val random = Random
val times =
//normal behavior
(1 to 100000).map(_ => random.nextInt(100)) ++
//standard peacks
(1 to 100).map(_ => 1000) ++
//very high peacks
(1 to 10).map(_ => 10000)
Source(1 to 10)
.map(_ / 0)
.runWith(Sink.ignore)
Source(1 to 10)
 .flatMapConcat { i =>
  Source.single(i)
  .map(toKafkaRecord)
  .via(Producer.flow(producerSettings))
 }
 .runForeach(i => println(s"${i.message.passThrough} sent to kafka"))
Source(1 to 10)
 .map(toKafkaRecord)
 .via(Producer.flow(producerSettings))
 .runForeach(i => println(s"${i.message.passThrough} sent to kafka"))
Source(1 to 10)
 .via(nonLinearFlow)
 .collect {
  case (Success(a), Success(b)) => (a, b)
 }
 .runForeach(println)