The folks at IBM recently announced their Cloud Foundry based infrastructure, Codename: BlueMix. It is currently open for beta as they scale up the service and work out all the kinks.
Overall I have been pretty impressed with the platform. I have a soft spot in my heart for Heroku but a little added competition in the market isn't bad either. It is clearly still pretty early in the product's lifecycle but the interface is surprisingly slick (coming from IBM at least) and the implementation is pretty standard and thus easy to move to and from. Vendor lock-in sucks so I find this second point especially promising.
Right now, BlueMix supports three main development environments:
- Ruby (either on Rails, or Sinatra)
The system works very similarly to other cloud environments though where these can be extended using buildpacks. As an example, instead of using the ruby_buildpack option when deploying, you could use a third party buildpack, heroku-buildpack-go, to deploy an environment ready for Go applications.
As usual, I wanted to test out the offering in way that may be a bit beyond what the intentions are. Enter DEFCOIN.
I love DEF CON and I love crypto-currencies so mining me some DEFCOIN seems like a no brainer. I think it's also important to point out that these really have zero value at this point and thus, I wasn't doing this for profit.
So, on to the fun stuff. For this project, I just needed a small CPU miner application that I could deploy along with some scripts. I ended up using cpuminer which conveniently can be downloaded in binary format (I was feeling a tad lazy).
So, I setup my project directory and extracted it into there.
> tar zxf pooler-cpuminer-2.3.3-linux-x86_64.tar.gz > mkdir defcoin-miner && cd defcoin-miner > mkdir app > cp ../minerd app/ > touch Procfile > touch app/mine.sh
Then I wrote out the mine.sh file so it would start the miner once it was deployed.
#!/usr/bin/env bash echo "hello DEFCOIN" app/minerd -o stratum+tcp://pooladdy:3333 --userpass=u:p
Then I quickly wrote up my Procfile to execute my bash script during deployment.
This took a bit of trial and error as I realized that the deployment program seems to really want the web worker defined. Originally I had given it a custom label but this was not executed during deployment.
When I created the application from the BlueMix interface, I told it to be a Sinatra application. I actually didn't prefer it for any particular reason as I knew I didn't need any of the real development environments.
Of course, actually deploying the code was pretty simple during this testing:
> cf push defcoin -b https://github.com/ryandotsmith/null-buildpack.git
Note: A null-buildpack was used because I didn't actually want to do anything other than run minerd
So it turns out that this all worked! At least for a minute or two. The problem was that BlueMix is constantly checking the health of your application. This includes a HTTP check to the site to assure that everything is up and running. Since the health checks were coming back negative, the worker process was killed.
So, now I needed to actually make a Sinatra site in order to pacify the health check.
First a quick ruby file that will respond to the HTTP requests:
require 'sinatra' get '/' do "Hello World!" end
Then we needed to setup the Gemfile so that all our deployment requirements are met:
source 'https://rubygems.org' gem 'sinatra'
And, now we needed to make sure the ruby site gets run on deployment too - which means changing our mine.sh script.
#!/usr/bin/env bash echo "hello DEFCOIN" bundle exec ruby app/app.rb & app/minerd -o stratum+tcp://pooladdy:3333 --userpass=u:p
Finally, we build the bundle and deploy again. Since we are back to being a ruby app, we had to specify that buildpack too.
> bundle install > cf push defcoin -b ruby_buildpack Updating app defcoin in org abstrct / space dev as abstrct... OK Uploading defcoin... Uploading from: /Users/Abstract/Projects/DEFCOIN 1.5K, 6 files OK Starting app defcoin in org abstrct / space dev as abstrct... OK -----> Downloaded app package (212K) -----> Downloaded app buildpack cache (2.8M) -----> Using Ruby version: ruby-1.9.3 -----> Installing dependencies using Bundler version 1.3.2 Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment Using rack (1.5.2) Using rack-protection (1.5.3) Using tilt (1.4.1) Using sinatra (1.4.5) Using bundler (1.3.2) Your bundle is complete! It was installed into ./vendor/bundle Cleaning up the bundler cache. -----> WARNINGS: You have not declared a Ruby version in your Gemfile. To set your Ruby version add this line to your Gemfile:" ruby '1.9.3'" # See https://devcenter.heroku.com/articles/ruby-versions for more information." -----> Uploading droplet (23M) 7 of 60 instances running, 53 starting App started Showing health and status for app defcoin in org abstrct / space dev as abstrct... OK requested state: started instances: 42/60 usage: 128M x 60 instances urls: defcoin.ng.bluemix.net state since cpu memory disk #0 running 2014-04-24 10:28:32 AM 0.0% 70M of 128M 53M of 1G #1 running 2014-04-24 10:28:32 AM 0.0% 69.7M of 128M 53M of 1G #2 starting 2014-04-24 10:28:30 AM 0.0% 0 of 0 0 of 0
If we look at our logs, we see some mining :D
> cf logs defcoin --recent Connected, dumping recent logs for app defcoin in org Abstrct / space dev as Abstrct... 2014-04-24T10:29:42.65-0400 [App/47] ERR [2014-04-24 14:29:42] thread 0: 55260 hashes, 1.04 khash/s 2014-04-24T10:29:42.70-0400 [App/1] ERR 22.214.171.124 - - [24/Apr/2014 14:29:42] "GET / HTTP/1.1" 200 12 0.0004 2014-04-24T10:29:42.70-0400 [App/1] ERR 2.router.default.scas-yz-prod.microbosh - - [24/Apr/2014:14:29:42 UTC] "GET / HTTP/1.1" 200 12 2014-04-24T10:29:42.70-0400 [App/1] ERR - -> / 2014-04-24T10:29:42.84-0400 [App/30] ERR [2014-04-24 14:29:42] thread 3: 344760 hashes, 5.93 khash/s 2014-04-24T10:29:43.09-0400 [App/58] ERR [2014-04-24 14:29:43] thread 0: 343404 hashes, 5.91 khash/s 2014-04-24T10:29:43.11-0400 [App/42] ERR [2014-04-24 14:29:43] thread 3: 55728 hashes, 1.04 khash/s 2014-04-24T10:29:43.15-0400 [RTR] OUT defcoin.ng.bluemix.net - [24/04/2014:14:29:43 +0000] "GET / HTTP/1.1" 200 12 "-" "Wget/1.11.4" 126.96.36.199:54514 vcap_request_id:03a0a9ee2804a00f462a8a9b33a8ac57 response_time:0.083128870 app_id:02942815-fb98-43cf-b56c-9c8bd0fdad34 2014-04-24T10:29:43.23-0400 [App/42] ERR 188.8.131.52 - - [24/Apr/2014 14:29:43] "GET / HTTP/1.1" 200 12 0.0076 2014-04-24T10:29:43.23-0400 [App/42] ERR 2.router.default.scas-yz-prod.microbosh - - [24/Apr/2014:14:29:43 UTC] "GET / HTTP/1.1" 200 12 2014-04-24T10:29:43.23-0400 [App/42] ERR - -> / 2014-04-24T10:29:43.26-0400 [App/16] ERR [2014-04-24 14:29:43] thread 3: 405744 hashes, 6.19 khash/s 2014-04-24T10:29:43.64-0400 [App/45] ERR 184.108.40.206 - - [24/Apr/2014 14:29:43] "GET / HTTP/1.1" 200 12 0.0037 2014-04-24T10:29:43.64-0400 [App/45] ERR 3.router.default.scas-yz-prod.microbosh - - [24/Apr/2014:14:29:43 UTC] "GET / HTTP/1.1" 200 12 2014-04-24T10:29:42.86-0400 [App/26] ERR 220.127.116.11 - - [24/Apr/2014 14:29:42] "GET / HTTP/1.1" 200 12 0.0005 2014-04-24T10:29:42.86-0400 [App/26] ERR 3.router.default.scas-yz-prod.microbosh - - [24/Apr/2014:14:29:42 UTC] "GET / HTTP/1.1" 200 12 2014-04-24T10:29:42.86-0400 [App/26] ERR - -> / 2014-04-24T10:29:43.24-0400 [App/18] ERR [2014-04-24 14:29:43] thread 0: 235704 hashes, 3.67 khash/s 2014-04-24T10:29:43.34-0400 [App/36] ERR [2014-04-24 14:29:43] thread 0: 336984 hashes, 5.47 khash/s
What you may or may not notice between those hashing log lines is a number of HTTP requests. These are not actually all the health check, some are another script I wrote on another network that constantly tries to access the site. I found without users actually making calls to the fake site, my hash rate would get lower and lower as workers were put to sleep.
So how did we do? Well.. you are given 8GB of memory to work with as a beta user which can be split-up over as many workers as you want. So I eventually worked my way up to 60 workers with 128MB of ram each.
Almost 1500Kh/s :D
After a couple hours though, my glorious mining farm suddenly stopped - all my workers were shut down. After a couple choppy attempts to start it back up again, my account was crippled further.
> cf start defcoin Starting app defcoin in org Abstrct / space dev as Abstrct... FAILED Server error, status code: 403, error code: 10003, message: You are not authorized to perform the requested action
Anything I do now via the command line cf tool, or the web interface is met by that same error "You are not authorized to perform the requested action".
I'm sorry I made you mad IBM - I hope we can be friends again! I am overall very impressed with the offering and I look forward to playing around with it more once the shackles are removed from my account.
I will try to be a little less CPU intensive during my next round of testing :)