Some tests with Node.js/Express/Async/Mongoose and Java/Play/Spring/Morphia
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
conf
java
js
results
.gitignore
README

README

* For js/ part you need NPM 1.0+, Mongoose 1.0+, Node.js 0.6+
* For java/ part you need Java 1.6+, Sbt, Spring 3.1+ and Play 2.0+ 

---
Preparing Mongo DB instance for the test:

Registered Database on https://mongolab.com/home

URI: mongodb://testildouser:testildopwd@ds031637.mongolab.com:31637/testildodb
Database: testildodb
User: testildouser
Password: testildopwd

During the tests I find this very helpful:

$ mongo ds031637.mongolab.com:31637/testildodb -u testildouser -p testildopwd
MongoDB shell version: 2.0.2
connecting to: ds031637.mongolab.com:31637/testildodb
> db.testjavarecords.remove({});
> db.testjsrecords.remove({});

And to verify that there are no survivors:

> db.testjsrecords.count({});
0
> db.testjavarecords.count({});
0

---
** Running new EC2 instance:

Make sure you have installed http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip and:

$ export EC2_HOME=/opt/local/ec2-api-tools-1.5.2.5
$ export PATH=$PATH:$EC2_HOME/bin

$ export EC2_PRIVATE_KEY=`ls ~/.ec2/pk-*.pem`
$ export EC2_CERT=`ls ~/.ec2/cert-*.pem`

check with:

$ echo $EC2_CERT
$ echo $EC2_PRIVATE_KEY

$ ssh-keygen -I testildo-ec2 -f ~/Dropbox/_keys/alexeypro/testildo-ec2
$ ec2-import-keypair testildo-ec2 -f /Users/alexey/Dropbox/_keys/alexeypro/testildo-ec2.pub
$ ec2-describe-keypairs
$ chmod 700 ~/Dropbox/_keys/alexeypro/testildo-ec2.pub
$ ec2-describe-images -o amazon | grep ami-31814f58
$ ec2-run-instances ami-31814f58 -k testildo-ec2

write down the i-XXXXXX so we can tag it:

$ ec2-create-tags i-10230b74 --tag Name=testildo

Enabling ssh port, and ports for our servers
$ ec2-authorize default -p 22
$ ec2-authorize default -p 9000
$ ec2-authorize default -p 9191
$ ec2-authorize default -p 8000
$ ec2-authorize default -p 8181

$ ec2-describe-instances

write down the IP address (first one) and let's go:

$ ssh -v -i ~/Dropbox/_keys/alexeypro/testildo-ec2 ec2-user@ec2-107-20-53-115.compute-1.amazonaws.com

---
** Installing Git

$ sudo yum install git 

---
** Node.js, NPM, Express and Mongoose on EC2:

Pretty straightforward, just using this instruction: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

$ sudo yum localinstall --nogpgcheck http://nodejs.tchol.org/repocfg/amzn1/nodejs-stable-release.noarch.rpm
$ sudo yum install nodejs-compat-symlinks npm
$ node --version
v0.6.13

$ cd /tmp && sudo bash

$ curl http://npmjs.org/install.sh | sh
$ npm install mongoose
$ npm install express
$ npm install async

---
** Java, Sbt, Play on EC2:

$ sudo bash

$ mkdir -p /opt/local
$ cd /opt/local

$ wget http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-i586.rpm
$ rpm -i jdk-7u1-linux-i586.rpm

Default Java is OpenJDK 1.6:

$ java -version
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.6) (amazon-52.1.10.6.41.amzn1-i386)
OpenJDK Client VM (build 20.0-b11, mixed mode)

Change it to the new one:

$ /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_01/bin/java 20000
$ /usr/sbin/alternatives --config java

Just double checking we are good to go:L

$ java -version
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode, sharing)

Installing Play Framework now:

$ wget -c http://download.playframework.org/releases/play-2.0.zip
$ unzip play-2.0.zip
$ export PATH=$PATH:/opt/local/play-2.0

---
** Checking out source code from GitHub:

$ pwd
/home/ec2-user

$ git clone https://github.com/alexeypro/testildo.git

---
** Installing LT software on other instance:

Let's stop current so we don't waste money:

$ ec2-describe-instances
$ ec2-stop-instances i-10230b74
$ ec2-describe-instance-status i-10230b74

Need to create new box for the client and install "httperf" http://www.hpl.hp.com/research/linux/httperf and "autobench" https://github.com/menavaur/Autobench
Autobench's config you can get from https://github.com/menavaur/Autobench/blob/master/autobench.conf
I got AMI from http://alestic.com/, which is Ubuntu 11.10 Oneiric EBS boot 64 bit (us-east-1)

$ ec2-run-instances ami-baba68d3 -k testildo-ec2
$ ec2-create-tags i-b1c029d6 --tag Name=testildo_client
$ ec2-describe-instances
$ ssh -v -i ~/Dropbox/_keys/alexeypro/testildo-ec2 ubuntu@ec2-174-129-91-54.compute-1.amazonaws.com
$ sudo apt-get -y install git-core
$ sudo apt-get install apache2-utils
$ sudo apt-get install httperf
$ sudo apt-get install make
$ git clone https://github.com/menavaur/Autobench.git

Need out conf file :-)
$ sudo cp autobench.conf /home/ubuntu/.autobench.conf

$ ec2-stop-instances i-b1c029d6

Just in case -- on Mac OS X it's just as simple as:
$ brew install autobench
$ brew install httperf
$ brew install gnuplot

Copy config and run uncommenting specific URI:

$ cp conf/autobench.conf ~/.autobench.conf

We want to clone this server instance so we run JS and Java side by side:

$ ec2-create-tags i-10230b74 --tag Name=testildo_js
$ ec2-create-image i-10230b74 -n testildo_server_ami

Then wait... wait.. wait.. (Take a while, huh?) Basically I think we a looking at 30-45 minutes before it'll be done.

$ ec2-run-instances ami-39b96050 -k testildo-ec2
$ ec2-create-tags i-35ef0452 --tag Name=testildo_java

Now we should be good to go. Start both (js, and java) and client:

$ ec2-start-instances i-10230b74
$ ec2-start-instances i-35ef0452
$ ec2-start-instances i-b1c029d6

$ alias ssh_testjs="ssh -v -i ~/Dropbox/_keys/alexeypro/testildo-ec2 ec2-user@ec2-23-20-136-73.compute-1.amazonaws.com"
$ alias ssh_testjava="ssh -v -i ~/Dropbox/_keys/alexeypro/testildo-ec2 ec2-user@ec2-174-129-116-151.compute-1.amazonaws.com"
$ alias ssh_testclient="ssh -v -i ~/Dropbox/_keys/alexeypro/testildo-ec2 ubuntu@ec2-50-17-113-225.compute-1.amazonaws.com"

Log in, launch Java and Node stuff with run.sh's.
Ready to go back to the client and run autobench :-)

./autobench --host1 ec2-23-20-136-73.compute-1.amazonaws.com --host2 ec2-174-129-116-151.compute-1.amazonaws.com --file ~/.sample1.tsv

Getting results back:

$ scp -v -i ~/Dropbox/_keys/alexeypro/testildo-ec2 ubuntu@ec2-50-17-113-225.compute-1.amazonaws.com:/home/ubuntu/TEST* ./results/

Converting to CSV from TSV:

$ tr '\t' ',' < ~/code/alexeypro/testildo/results/TEST-find.tsv > TEST-find.csv 
$ tr '\t' ',' < ~/code/alexeypro/testildo/results/TEST-helloworld.tsv > TEST-helloworld.csv 
$ tr '\t' ',' < ~/code/alexeypro/testildo/results/TEST-save.tsv > TEST-save.csv 
$ tr '\t' ',' < ~/code/alexeypro/testildo/results/TEST-saveasync.tsv > TEST-saveasync.csv 

Use anything like http://home.gna.org/veusz/downloads/ to build graphs