Alex Rivera | Logout

Play constantly writes to disc? Causing higher bill on Amazon ec2

Asked 2012-07-05T18:59:20.817
24

I've got myself an Amazon ec2 Micro Instance (A VPN Server) to play around with.
The problem is that Amazon charge you for every disc IO you do in a Micro Instance.
The instance is running Amazon Linux a flavor of CentOS.

I've started a Scala application in Play 2.0(.2) framework on the server and I'm the only one who connects to the application.

I have observed that every few second something on the server commits IO transactions, to narrow it down I installed a Linux program called iotop.

Here is an output after a couple of seconds.

TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    
23333 be/4 root        0.00 B/s   11.91 K/s  0.00 %  0.00 %  
COMMAND java -Dsbt.ivy.home=/usr/play-2.0.2/framework/../repository -Djava.runtime.name=OpenJDK ~/jars/slf4j-api.jar:/usr/play-2.0.2/repository/local/org.slf4j/jul-to-slf4j/1.6.4/jars/j

A cat from the log file

cat /home/ec2-user/socketTest/logs/application.log
2012-07-05 11:43:31,881 - [INFO] - from play in main
Listening for HTTP on port 9000...

So Play doesn't write anything to the log file.

First question have I understood the iotop correct and that Play indeed is the disc IO thief.
If so why do play use IO?

My application is a simple websocket example. In essence it echos the input to the output. The IO occurs even thou nothing is pushed thru websockets.

Edit
Report

1 Answer

30

I've finally found the answer.

By observing when Play made an IO transaction I instantly executed this command:

touch -d '-10 seconds' /tmp/newerthan
find / ! -fstype proc -newer /tmp/newerthan

This returned one interesting line:

/tmp/hsperfdata_root/23320

While googling on this i stumbled upon a Bug ID: 5012932 from sun JVM creates subdirectory "hsperfdata_xxx". Java does this to enable noninvasive observability of the JRE, they claim it's a feature and not a bug that's why it hasn't been resolved.
A solution presented to disable this "feature" was to make use of an undocumented option -XX:-UsePerfData. I tried this but unfortunately Play kept making the IO transactions.

But after some more digging I found another switch -XX:+PerfDisableSharedMem.

So I executed export _JAVA_OPTIONS="-XX:+PerfDisableSharedMem" before starting Play .

And... VoilĂ  Play stopped making the IO transactions!

answered 2012-07-06T02:11:45.147

Your Answer