7. How bad is it?
Normal CPU instruction
Fetch from RAM
Disk seek
Ping from Iași to Bucharest
Ping from Iași to USA
0.5 nsec
120 nsec
10 msec
30 msec
130 msec
8. No, really
Normal CPU instruction
Fetch from RAM
Disk seek
Ping from Iași to Bucharest
Ping from Iași to USA
1 sec
4 min
7.5 Months
2 Years
6 Years
27. val bookingFlow =
Flow[NewBookingCommand].map { command =>
val bookings = TicketsRepository.
bookForEvent(command.eventId, command.count)
BookingSucceeded(
command.eventId, bookings)
}
28. val in = ThunkTap[NewBookingCommand] {
// Flood with requests
Some(NewBookingCommand(1, 2))
}
val out = ForeachDrain[BookingSucceeded] {
case BookingSucceeded(eventId, bookings) =>
println(s"Thank you!" + bookings.mkString("n"))
}
29. FlowGraph { implicit b =>
in ~> bookingFlow ~> out
}.run()
Altogether now
Tap Flow
Drain
30. Recap
• Do you really know what's slow in your code?
• Queues make bottlenecks obvious
• If you can't serve me, tell me so ("Agree to Start")
• Because people pleasers end up disappointing
everyone equally :-)