SlideShare a Scribd company logo
Spray(Akka)でJVMをCPUスケー
ルさせるために行った事
渡辺 雄作(35) / @waysaku
ソフトウェアエンジニア
株式会社サイバーエージェント	

アドテク本部	

(Webシステム)
Spray(Akka)でJVMをCPUスケー
ルさせるために行った事
spray is an open-source toolkit for building REST/HTTP-
based integration layers on top of Scala and Akka. Being
asynchronous, actor-based, fast, lightweight, modular and
testable it's a great way to connect your Scala applications
to the world.
Scalaコードを読めない人(技術的、もしくはポリ
シー的に)がAkkaアプリケーション運用を任されて
しまった
JVM上で動くノンブロッキング、非同期なアーキ
テクチャを採用しているアプリケーション
対象システム
対象者
リリース数日前の負荷試験、、、
何が起きたか
スループットが全然出ない!
• Akkaの仕組みを理解する
解決までの道のり
• Linuxの基本的な情報を取得
• Thread Dump取得
Actor
Dispacher
Actor
Actor
Actor
Thread ThreadThread Thread
Actor
Actor
ひもづける
• Akkaの仕組みを理解する
Dispacher
ThreadThread
Akkaの基本的な考え方
Thread
Actor
Actor Actor
Actor
Actor
Thread
Actor
!!
Cpu0 : 2.3%us, 0.7%sy, 0.0%ni, 97.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st	

Cpu1 : 0.3%us, 0.3%sy, 0.0%ni, 99.3%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st	

Cpu2 : 92.0%us, 6.0%sy, 0.0%ni, 2.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st	

Cpu3 : 5.4%us, 1.7%sy, 0.0%ni, 93.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
スループットが全然出ないと思ったら、
CPU一個しか使ってない!
そのくせロードアベレージが無駄に高い
• Linuxの基本的な情報を取得
Thread Dumpを取得する
"Attach Listener" daemon prio=5 tid=0x00007f8de5852000 nid=0x3b07 waiting on condition [0x0000000000000000]	

"DestroyJavaVM" prio=5 tid=0x00007f8de280b800 nid=0x1903 waiting on condition [0x0000000000000000]	

"default-akka.actor.default-dispatcher-4" prio=5 tid=0x00007f8de28d8000 nid=0x5f03 waiting on condition [0x000000011fb12000]	

"default-akka.actor.default-dispatcher-3" prio=5 tid=0x00007f8de28e2800 nid=0x5d03 waiting on condition [0x000000011fa0f000]	

"default-akka.actor.default-dispatcher-2" prio=5 tid=0x00007f8de3158000 nid=0x5b03 waiting on condition [0x000000011f90c000]	

"default-scheduler-1" prio=5 tid=0x00007f8de3854800 nid=0x5903 waiting on condition [0x000000011f809000]	

"Service Thread" daemon prio=5 tid=0x00007f8de5001000 nid=0x5303 runnable [0x0000000000000000]	

"C2 CompilerThread1" daemon prio=5 tid=0x00007f8de4805000 nid=0x5103 waiting on condition [0x0000000000000000]	

"C2 CompilerThread0" daemon prio=5 tid=0x00007f8de303c800 nid=0x4f03 waiting on condition [0x0000000000000000]	

"Signal Dispatcher" daemon prio=5 tid=0x00007f8de303b800 nid=0x4d03 runnable [0x0000000000000000]	

"Finalizer" daemon prio=5 tid=0x00007f8de3803800 nid=0x3903 in Object.wait() [0x000000011e8a2000]	

"Reference Handler" daemon prio=5 tid=0x00007f8de3034800 nid=0x3703 in Object.wait() [0x000000011e79f000]	

"VM Thread" prio=5 tid=0x00007f8de3033800 nid=0x3503 runnable	

"GC task thread#0 (ParallelGC)" prio=5 tid=0x00007f8de281a800 nid=0x2503 runnable	

"GC task thread#1 (ParallelGC)" prio=5 tid=0x00007f8de4800000 nid=0x2703 runnable	

"GC task thread#2 (ParallelGC)" prio=5 tid=0x00007f8de281b800 nid=0x2903 runnable	

"GC task thread#3 (ParallelGC)" prio=5 tid=0x00007f8de281c000 nid=0x2b03 runnable	

"GC task thread#4 (ParallelGC)" prio=5 tid=0x00007f8de281c800 nid=0x2d03 runnable	

"GC task thread#5 (ParallelGC)" prio=5 tid=0x00007f8de5000000 nid=0x2f03 runnable	

"GC task thread#6 (ParallelGC)" prio=5 tid=0x00007f8de4801000 nid=0x3103 runnable	

"GC task thread#7 (ParallelGC)" prio=5 tid=0x00007f8de5800000 nid=0x3303 runnable	

"VM Periodic Task Thread" prio=5 tid=0x00007f8de480d800 nid=0x5503 waiting on condition
Dynamic Attach機能に利用される(jmap, jstackなどのJVM内部の情報取得や
挙動の操作など)
VMをアンロードするためのリスナー(JVMアプリケーション以外
からJVMを利用している場合にVMをDestroyできるように)
JIT(HotSpot)で使うネイティブコンパイルスレッド()
GCを走らせるなどのVMのオペレーションを行うスレッド
マイナーGC用のスレッド
finalizeメソッドが定義されているオブジェクトの実行スレッド	

OSからのシグナルを受け付ける
"Attach Listener" daemon prio=5 tid=0x00007f8de5852000 nid=0x3b07 waiting on condition [0x0000000000000000]	

"DestroyJavaVM" prio=5 tid=0x00007f8de280b800 nid=0x1903 waiting on condition [0x0000000000000000]	

"default-akka.actor.default-dispatcher-4" prio=5 tid=0x00007f8de28d8000 nid=0x5f03 waiting on condition [0x000000011fb12000]	

"default-akka.actor.default-dispatcher-3" prio=5 tid=0x00007f8de28e2800 nid=0x5d03 waiting on condition [0x000000011fa0f000]	

"default-akka.actor.default-dispatcher-2" prio=5 tid=0x00007f8de3158000 nid=0x5b03 waiting on condition [0x000000011f90c000]	

"default-scheduler-1" prio=5 tid=0x00007f8de3854800 nid=0x5903 waiting on condition [0x000000011f809000]	

"Service Thread" daemon prio=5 tid=0x00007f8de5001000 nid=0x5303 runnable [0x0000000000000000]	

"C2 CompilerThread1" daemon prio=5 tid=0x00007f8de4805000 nid=0x5103 waiting on condition [0x0000000000000000]	

"C2 CompilerThread0" daemon prio=5 tid=0x00007f8de303c800 nid=0x4f03 waiting on condition [0x0000000000000000]	

"Signal Dispatcher" daemon prio=5 tid=0x00007f8de303b800 nid=0x4d03 runnable [0x0000000000000000]	

"Finalizer" daemon prio=5 tid=0x00007f8de3803800 nid=0x3903 in Object.wait() [0x000000011e8a2000]	

"Reference Handler" daemon prio=5 tid=0x00007f8de3034800 nid=0x3703 in Object.wait() [0x000000011e79f000]	

"VM Thread" prio=5 tid=0x00007f8de3033800 nid=0x3503 runnable	

"GC task thread#0 (ParallelGC)" prio=5 tid=0x00007f8de281a800 nid=0x2503 runnable	

"GC task thread#1 (ParallelGC)" prio=5 tid=0x00007f8de4800000 nid=0x2703 runnable	

"GC task thread#2 (ParallelGC)" prio=5 tid=0x00007f8de281b800 nid=0x2903 runnable	

"GC task thread#3 (ParallelGC)" prio=5 tid=0x00007f8de281c000 nid=0x2b03 runnable	

"GC task thread#4 (ParallelGC)" prio=5 tid=0x00007f8de281c800 nid=0x2d03 runnable	

"GC task thread#5 (ParallelGC)" prio=5 tid=0x00007f8de5000000 nid=0x2f03 runnable	

"GC task thread#6 (ParallelGC)" prio=5 tid=0x00007f8de4801000 nid=0x3103 runnable	

"GC task thread#7 (ParallelGC)" prio=5 tid=0x00007f8de5800000 nid=0x3303 runnable	

"VM Periodic Task Thread" prio=5 tid=0x00007f8de480d800 nid=0x5503 waiting on condition
Akkaのスレッド
"default-akka.actor.default-dispatcher-24" prio=5 tid=0x00007fef1e054800 nid=0x9003 waiting for monitor entry
[0x0000000114423000]	

java.lang.Thread.State: BLOCKED (on object monitor)	

at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:211)	

- waiting to lock <0x0000000701d22d00> (a ch.qos.logback.core.spi.LogbackLock)	

at ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:175)	

at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:103)	

at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:88)	

at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48)	

at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:272)	

at ch.qos.logback.classic.Logger.callAppenders(Logger.java:259)	

at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:441)	

at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:395)
Blockしてる
"default-akka.actor.default-dispatcher-24" prio=5 tid=0x00007fef1e054800 nid=0x9003 waiting for monitor entry
[0x0000000114423000]	

java.lang.Thread.State: BLOCKED (on object monitor)	

at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:211)	

- waiting to lock <0x0000000701d22d00> (a ch.qos.logback.core.spi.LogbackLock)	

at ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:175)	

at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:103)	

at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:88)	

at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48)	

at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:272)	

at ch.qos.logback.classic.Logger.callAppenders(Logger.java:259)	

at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:441)	

at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:395)
Lockを取得しよう
として待ってる
"default-akka.actor.default-dispatcher-18" prio=5 tid=0x00007fef1a99f800 nid=0x7f03 waiting for monitor entry
[0x0000000113e11000]	

java.lang.Thread.State: BLOCKED (on object monitor)	

at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:211)	

- locked <0x0000000701d22d00> (a ch.qos.logback.core.spi.LogbackLock)	

at ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:175)
Lockしてる
ch.qos.logback.core.OutputStreamAppender#subAppend(E event)
synchronized (lock) {	

writeOut(event);	

}
Block !
Jvm operation casual talks
• Do the blocking call within an actor (or a set of actors managed by a
router [Java, Scala]), making sure to configure a thread pool which is
either dedicated for this purpose or sufficiently sized.	

!
• Do the blocking call within a Future, ensuring an upper bound on the
number of such calls at any point in time (submitting an unbounded
number of tasks of this nature will exhaust your memory or thread
limits).	

!
• Do the blocking call within a Future, providing a thread pool with an
upper limit on the number of threads which is appropriate for the
hardware on which the application runs.	

!
• Dedicate a single thread to manage a set of blocking resources (e.g. a
NIO selector driving multiple channels) and dispatch events as they
occur as actor messages.
The non-exhaustive list of adequate solutions to the
“blocking problem”
ノンブロッキングアーキテクチャは	

I/Oを伴う処理は非常にセンシティブ
まとめ
Akkaにはログを非同期で出力できるユーティリティが用意されているのでそれを使おう
おかしいなと思ったらまずは	

Thread dump
おわり

More Related Content

ODP
Java GC, Off-heap workshop
PDF
淺談 Java GC 原理、調教和 新發展
PDF
Fight with Metaspace OOM
PPTX
Java memory problem cases solutions
PDF
Tools for Metaspace
PPTX
Sun jdk 1.6 gc english version
PDF
JVM Internals (2015)
PPTX
Java Memory Management Tricks
Java GC, Off-heap workshop
淺談 Java GC 原理、調教和 新發展
Fight with Metaspace OOM
Java memory problem cases solutions
Tools for Metaspace
Sun jdk 1.6 gc english version
JVM Internals (2015)
Java Memory Management Tricks

What's hot (20)

PDF
JVM and Garbage Collection Tuning
PDF
jcmd #javacasual
PPTX
Tuning Java GC to resolve performance issues
PPT
Jvm Performance Tunning
PPTX
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
PDF
Introduction of Java GC Tuning and Java Java Mission Control
PDF
Java and Containers - Make it Awesome !
PPTX
JVM @ Taobao - QCon Hangzhou 2011
PDF
Basics of JVM Tuning
PDF
How to cook lettuce @Java casual
PDF
Jvm internals
PDF
2014 OSDC Talk: Introduction to Percona XtraDB Cluster and HAProxy
PDF
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
PPTX
ClassLoader Leaks
PPTX
HotSpot JVM Tuning
PDF
Pimp my gc - Supersonic Scala
PDF
GC Tuning in the HotSpot Java VM - a FISL 10 Presentation
PPTX
NYC Java Meetup - Profiling and Performance
PDF
The JVM is your friend
PPTX
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
JVM and Garbage Collection Tuning
jcmd #javacasual
Tuning Java GC to resolve performance issues
Jvm Performance Tunning
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Introduction of Java GC Tuning and Java Java Mission Control
Java and Containers - Make it Awesome !
JVM @ Taobao - QCon Hangzhou 2011
Basics of JVM Tuning
How to cook lettuce @Java casual
Jvm internals
2014 OSDC Talk: Introduction to Percona XtraDB Cluster and HAProxy
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
ClassLoader Leaks
HotSpot JVM Tuning
Pimp my gc - Supersonic Scala
GC Tuning in the HotSpot Java VM - a FISL 10 Presentation
NYC Java Meetup - Profiling and Performance
The JVM is your friend
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
Ad

Similar to Jvm operation casual talks (20)

PPTX
16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLE
PDF
[CB20] Vulnerabilities of Machine Learning Infrastructure by Sergey Gordeychik
PDF
手把手教你如何串接 Log 到各種網路服務
PDF
Native Java with GraalVM
PPTX
Real World Lessons on the Pain Points of Node.JS Application
PPTX
OpenShiftMeetup #4 20190522 - KEDA-
PDF
Maxim Salnikov - Service Worker: taking the best from the past experience for...
PPTX
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
PPT
Find bottleneck and tuning in Java Application
PPT
Analysis bottleneck in J2EE application
PPTX
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
PDF
Advanced akka features
PDF
Hack.LU 2018 ARM IoT Firmware Emulation Workshop
PDF
Analyzing the Performance of Mobile Web
PPTX
OWASP ZAP Workshop for QA Testers
PDF
ARM IoT Firmware Emulation Workshop
PDF
Gimme Caching - The JCache Way
PDF
Varnish presentation for the Symfony Zaragoza user group
ODP
Java gpu computing
PDF
Kraken Front-Trends
16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLE
[CB20] Vulnerabilities of Machine Learning Infrastructure by Sergey Gordeychik
手把手教你如何串接 Log 到各種網路服務
Native Java with GraalVM
Real World Lessons on the Pain Points of Node.JS Application
OpenShiftMeetup #4 20190522 - KEDA-
Maxim Salnikov - Service Worker: taking the best from the past experience for...
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
Find bottleneck and tuning in Java Application
Analysis bottleneck in J2EE application
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
Advanced akka features
Hack.LU 2018 ARM IoT Firmware Emulation Workshop
Analyzing the Performance of Mobile Web
OWASP ZAP Workshop for QA Testers
ARM IoT Firmware Emulation Workshop
Gimme Caching - The JCache Way
Varnish presentation for the Symfony Zaragoza user group
Java gpu computing
Kraken Front-Trends
Ad

More from Yusaku Watanabe (11)

PDF
組織をシステム化するReactiveManagement
PDF
エンジニアがプロダクトマネージャーに進化すると何が起きるのか
PDF
QCon SF-feedback
PDF
Regional Scrum Gathering® Tokyo 2014
PDF
WEB開発を加速させる。アジャイル開発に最適なデータ構造とORマッパの形
PDF
PageRankアルゴリズムを使った人事評価についての実験
PDF
スケーラブルなアプリケーション開発を考える
PDF
Pythonによる並列プログラミング -GPGPUも-
KEY
実録 WEBエンジニアが Titanium Mobileアプリを開発するまで
PDF
Ameba Piggの裏側
DOC
GPGPUによるパーソナルスーパーコンピュータの可能性
組織をシステム化するReactiveManagement
エンジニアがプロダクトマネージャーに進化すると何が起きるのか
QCon SF-feedback
Regional Scrum Gathering® Tokyo 2014
WEB開発を加速させる。アジャイル開発に最適なデータ構造とORマッパの形
PageRankアルゴリズムを使った人事評価についての実験
スケーラブルなアプリケーション開発を考える
Pythonによる並列プログラミング -GPGPUも-
実録 WEBエンジニアが Titanium Mobileアプリを開発するまで
Ameba Piggの裏側
GPGPUによるパーソナルスーパーコンピュータの可能性

Recently uploaded (20)

PPTX
Geodesy 1.pptx...............................................
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
Sustainable Sites - Green Building Construction
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPTX
Construction Project Organization Group 2.pptx
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PPT
Total quality management ppt for engineering students
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Fundamentals of Mechanical Engineering.pptx
PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
Geodesy 1.pptx...............................................
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Sustainable Sites - Green Building Construction
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Categorization of Factors Affecting Classification Algorithms Selection
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Construction Project Organization Group 2.pptx
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
Total quality management ppt for engineering students
Internet of Things (IOT) - A guide to understanding
Fundamentals of Mechanical Engineering.pptx
Safety Seminar civil to be ensured for safe working.
Foundation to blockchain - A guide to Blockchain Tech
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Fundamentals of safety and accident prevention -final (1).pptx

Jvm operation casual talks

  • 2. 渡辺 雄作(35) / @waysaku ソフトウェアエンジニア 株式会社サイバーエージェント アドテク本部 (Webシステム)
  • 4. spray is an open-source toolkit for building REST/HTTP- based integration layers on top of Scala and Akka. Being asynchronous, actor-based, fast, lightweight, modular and testable it's a great way to connect your Scala applications to the world.
  • 10. Cpu0 : 2.3%us, 0.7%sy, 0.0%ni, 97.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Cpu1 : 0.3%us, 0.3%sy, 0.0%ni, 99.3%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Cpu2 : 92.0%us, 6.0%sy, 0.0%ni, 2.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Cpu3 : 5.4%us, 1.7%sy, 0.0%ni, 93.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st スループットが全然出ないと思ったら、 CPU一個しか使ってない! そのくせロードアベレージが無駄に高い • Linuxの基本的な情報を取得
  • 11. Thread Dumpを取得する "Attach Listener" daemon prio=5 tid=0x00007f8de5852000 nid=0x3b07 waiting on condition [0x0000000000000000] "DestroyJavaVM" prio=5 tid=0x00007f8de280b800 nid=0x1903 waiting on condition [0x0000000000000000] "default-akka.actor.default-dispatcher-4" prio=5 tid=0x00007f8de28d8000 nid=0x5f03 waiting on condition [0x000000011fb12000] "default-akka.actor.default-dispatcher-3" prio=5 tid=0x00007f8de28e2800 nid=0x5d03 waiting on condition [0x000000011fa0f000] "default-akka.actor.default-dispatcher-2" prio=5 tid=0x00007f8de3158000 nid=0x5b03 waiting on condition [0x000000011f90c000] "default-scheduler-1" prio=5 tid=0x00007f8de3854800 nid=0x5903 waiting on condition [0x000000011f809000] "Service Thread" daemon prio=5 tid=0x00007f8de5001000 nid=0x5303 runnable [0x0000000000000000] "C2 CompilerThread1" daemon prio=5 tid=0x00007f8de4805000 nid=0x5103 waiting on condition [0x0000000000000000] "C2 CompilerThread0" daemon prio=5 tid=0x00007f8de303c800 nid=0x4f03 waiting on condition [0x0000000000000000] "Signal Dispatcher" daemon prio=5 tid=0x00007f8de303b800 nid=0x4d03 runnable [0x0000000000000000] "Finalizer" daemon prio=5 tid=0x00007f8de3803800 nid=0x3903 in Object.wait() [0x000000011e8a2000] "Reference Handler" daemon prio=5 tid=0x00007f8de3034800 nid=0x3703 in Object.wait() [0x000000011e79f000] "VM Thread" prio=5 tid=0x00007f8de3033800 nid=0x3503 runnable "GC task thread#0 (ParallelGC)" prio=5 tid=0x00007f8de281a800 nid=0x2503 runnable "GC task thread#1 (ParallelGC)" prio=5 tid=0x00007f8de4800000 nid=0x2703 runnable "GC task thread#2 (ParallelGC)" prio=5 tid=0x00007f8de281b800 nid=0x2903 runnable "GC task thread#3 (ParallelGC)" prio=5 tid=0x00007f8de281c000 nid=0x2b03 runnable "GC task thread#4 (ParallelGC)" prio=5 tid=0x00007f8de281c800 nid=0x2d03 runnable "GC task thread#5 (ParallelGC)" prio=5 tid=0x00007f8de5000000 nid=0x2f03 runnable "GC task thread#6 (ParallelGC)" prio=5 tid=0x00007f8de4801000 nid=0x3103 runnable "GC task thread#7 (ParallelGC)" prio=5 tid=0x00007f8de5800000 nid=0x3303 runnable "VM Periodic Task Thread" prio=5 tid=0x00007f8de480d800 nid=0x5503 waiting on condition Dynamic Attach機能に利用される(jmap, jstackなどのJVM内部の情報取得や 挙動の操作など) VMをアンロードするためのリスナー(JVMアプリケーション以外 からJVMを利用している場合にVMをDestroyできるように) JIT(HotSpot)で使うネイティブコンパイルスレッド() GCを走らせるなどのVMのオペレーションを行うスレッド マイナーGC用のスレッド finalizeメソッドが定義されているオブジェクトの実行スレッド OSからのシグナルを受け付ける
  • 12. "Attach Listener" daemon prio=5 tid=0x00007f8de5852000 nid=0x3b07 waiting on condition [0x0000000000000000] "DestroyJavaVM" prio=5 tid=0x00007f8de280b800 nid=0x1903 waiting on condition [0x0000000000000000] "default-akka.actor.default-dispatcher-4" prio=5 tid=0x00007f8de28d8000 nid=0x5f03 waiting on condition [0x000000011fb12000] "default-akka.actor.default-dispatcher-3" prio=5 tid=0x00007f8de28e2800 nid=0x5d03 waiting on condition [0x000000011fa0f000] "default-akka.actor.default-dispatcher-2" prio=5 tid=0x00007f8de3158000 nid=0x5b03 waiting on condition [0x000000011f90c000] "default-scheduler-1" prio=5 tid=0x00007f8de3854800 nid=0x5903 waiting on condition [0x000000011f809000] "Service Thread" daemon prio=5 tid=0x00007f8de5001000 nid=0x5303 runnable [0x0000000000000000] "C2 CompilerThread1" daemon prio=5 tid=0x00007f8de4805000 nid=0x5103 waiting on condition [0x0000000000000000] "C2 CompilerThread0" daemon prio=5 tid=0x00007f8de303c800 nid=0x4f03 waiting on condition [0x0000000000000000] "Signal Dispatcher" daemon prio=5 tid=0x00007f8de303b800 nid=0x4d03 runnable [0x0000000000000000] "Finalizer" daemon prio=5 tid=0x00007f8de3803800 nid=0x3903 in Object.wait() [0x000000011e8a2000] "Reference Handler" daemon prio=5 tid=0x00007f8de3034800 nid=0x3703 in Object.wait() [0x000000011e79f000] "VM Thread" prio=5 tid=0x00007f8de3033800 nid=0x3503 runnable "GC task thread#0 (ParallelGC)" prio=5 tid=0x00007f8de281a800 nid=0x2503 runnable "GC task thread#1 (ParallelGC)" prio=5 tid=0x00007f8de4800000 nid=0x2703 runnable "GC task thread#2 (ParallelGC)" prio=5 tid=0x00007f8de281b800 nid=0x2903 runnable "GC task thread#3 (ParallelGC)" prio=5 tid=0x00007f8de281c000 nid=0x2b03 runnable "GC task thread#4 (ParallelGC)" prio=5 tid=0x00007f8de281c800 nid=0x2d03 runnable "GC task thread#5 (ParallelGC)" prio=5 tid=0x00007f8de5000000 nid=0x2f03 runnable "GC task thread#6 (ParallelGC)" prio=5 tid=0x00007f8de4801000 nid=0x3103 runnable "GC task thread#7 (ParallelGC)" prio=5 tid=0x00007f8de5800000 nid=0x3303 runnable "VM Periodic Task Thread" prio=5 tid=0x00007f8de480d800 nid=0x5503 waiting on condition Akkaのスレッド
  • 13. "default-akka.actor.default-dispatcher-24" prio=5 tid=0x00007fef1e054800 nid=0x9003 waiting for monitor entry [0x0000000114423000] java.lang.Thread.State: BLOCKED (on object monitor) at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:211) - waiting to lock <0x0000000701d22d00> (a ch.qos.logback.core.spi.LogbackLock) at ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:175) at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:103) at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:88) at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48) at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:272) at ch.qos.logback.classic.Logger.callAppenders(Logger.java:259) at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:441) at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:395) Blockしてる
  • 14. "default-akka.actor.default-dispatcher-24" prio=5 tid=0x00007fef1e054800 nid=0x9003 waiting for monitor entry [0x0000000114423000] java.lang.Thread.State: BLOCKED (on object monitor) at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:211) - waiting to lock <0x0000000701d22d00> (a ch.qos.logback.core.spi.LogbackLock) at ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:175) at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:103) at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:88) at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48) at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:272) at ch.qos.logback.classic.Logger.callAppenders(Logger.java:259) at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:441) at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:395) Lockを取得しよう として待ってる "default-akka.actor.default-dispatcher-18" prio=5 tid=0x00007fef1a99f800 nid=0x7f03 waiting for monitor entry [0x0000000113e11000] java.lang.Thread.State: BLOCKED (on object monitor) at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:211) - locked <0x0000000701d22d00> (a ch.qos.logback.core.spi.LogbackLock) at ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:175) Lockしてる
  • 17. • Do the blocking call within an actor (or a set of actors managed by a router [Java, Scala]), making sure to configure a thread pool which is either dedicated for this purpose or sufficiently sized. ! • Do the blocking call within a Future, ensuring an upper bound on the number of such calls at any point in time (submitting an unbounded number of tasks of this nature will exhaust your memory or thread limits). ! • Do the blocking call within a Future, providing a thread pool with an upper limit on the number of threads which is appropriate for the hardware on which the application runs. ! • Dedicate a single thread to manage a set of blocking resources (e.g. a NIO selector driving multiple channels) and dispatch events as they occur as actor messages. The non-exhaustive list of adequate solutions to the “blocking problem”