5. What’s Fluency?
• Yet another fluent-logger-java
(https://github.com/komamitsu/fluency)
• 3x 4x faster than fluent-logger using
PackedForward format
• Easy to extend
• Many features
(Async flush, HB, Failover, Ack response)
• Used in LINE, Treasure Data, kafka-fluentd-consumer
7. Async flushing
Application Fluency Buffer FluentdFlusher
emit(event:A) append(event:A)
emit(event:B) append(event:B)
store events as
MessagePack
flush
send(event:[A, B])
emit(event:C) append(event:C)
flush
invoked
repeatedly
PackedForward
format
close close
force flush
emit(event:D) append(event:D)
send(event:[C,D])
event:C isn’t
ready for flush
event:A,B are
ready for flush
terminate
thread
8. Async flushing
Application Fluency Buffer FluentdFlusher
emit(event:A) append(event:A)
emit(event:B) append(event:B)
store events as
MessagePack
flush
send(event:[A, B])
emit(event:C) append(event:C)
flush
invoked
repeatedly
PackedForward
format
close close
force flush
emit(event:D) append(event:D)
send(event:[C,D])
event:C isn’t
ready for flush
event:A,B are
ready for flush
terminate
thread
9. Async flushing
Application Fluency Buffer FluentdFlusher
emit(event:A) append(event:A)
emit(event:B) append(event:B)
store events as
MessagePack
flush
send(event:[A, B])
emit(event:C) append(event:C)
flush
invoked
repeatedly
PackedForward
format
close close
force flush
emit(event:D) append(event:D)
send(event:[C,D])
event:C isn’t
ready for flush
event:A,B are
ready for flush
terminate
thread
10. Async flushing
Application Fluency Buffer FluentdFlusher
emit(event:A) append(event:A)
emit(event:B) append(event:B)
store events as
MessagePack
flush
send(event:[A, B])
emit(event:C) append(event:C)
flush
invoked
repeatedly
PackedForward
format
close close
force flush
emit(event:D) append(event:D)
send(event:[C,D])
event:C isn’t
ready for flush
event:A,B are
ready for flush
terminate
thread
11. Async flushing
Application Fluency Buffer FluentdFlusher
emit(event:A) append(event:A)
emit(event:B) append(event:B)
store events as
MessagePack
flush
send(event:[A, B])
emit(event:C) append(event:C)
flush
invoked
repeatedly
PackedForward
format
close close
force flush
emit(event:D) append(event:D)
send(event:[C,D])
event:C isn’t
ready for flush
event:A,B are
ready for flush
terminate
thread
12. Async flushing
Application Fluency Buffer FluentdFlusher
emit(event:A) append(event:A)
emit(event:B) append(event:B)
store events as
MessagePack
flush
send(event:[A, B])
emit(event:C) append(event:C)
flush
invoked
repeatedly
PackedForward
format
close close
force flush
emit(event:D) append(event:D)
send(event:[C,D])
event:C isn’t
ready for flush
event:A,B are
ready for flush
terminate
thread
13. Async flushing
Application Fluency Buffer FluentdFlusher
emit(event:A) append(event:A)
emit(event:B) append(event:B)
store events as
MessagePack
flush
send(event:[A, B])
emit(event:C) append(event:C)
flush
invoked
repeatedly
PackedForward
format
close close
force flush
emit(event:D) append(event:D)
send(event:[C,D])
event:C isn’t
ready for flush
event:A,B are
ready for flush
terminate
thread
14. Async flushing
Application Fluency Buffer FluentdFlusher
emit(event:A) append(event:A)
emit(event:B) append(event:B)
store events as
MessagePack
flush
send(event:[A, B])
emit(event:C) append(event:C)
flush
invoked
repeatedly
PackedForward
format
close close
force flush
emit(event:D) append(event:D)
send(event:[C,D])
event:C isn’t
ready for flush
event:A,B are
ready for flush
terminate
thread
25. 4x faster than
fluent-logger-java
fluency / fluent-logger-java: m3.large
fluentd: m3.large
See details: https://gist.github.com/komamitsu/c1e4045fe2ddb108cfbf12d5f014b683
But the actual
bottleneck
of this benchmark
might be Fluentd…
26. Java profiling (1/2)
fluency fluent-logger-java
fluency uses off heap
for buffer pool
Due to synchronization
28. Finding a bottleneck
fluency
emit (MessagePack
serialization & appending to
buffer) accounts for most of
the duration
String.getBytes in
MessagePack serialization
takes total 18%
ObjectMapper.writeValue
itself takes 40%