Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.
For the best experience please use the latest Chrome or Safari browser. Firefox 10 (to be released soon) will also handle it.
vagrant-lxc を触ってみた
Kohei Hasegawa / @banyan / paperboy&co.
Chef Casual Talks Vol.1 / 20130415
Vagrant + LXC
- fgrehm/vagrant-lxc
- Vagrant の plugin として利用可能、API が Vagrant のままなので使いやすい
- chrisroberts/vagabond
- vagabond は yet another vagrant for lxc みたいなもの。試したがうまく動かなかった...
- 普通に lxc + chef で構築すればいいじゃん、という話ですけど Vagrant みたいなインターフェースで統一されると便利そうだし、単純にどんなものか触ってみたかった
vagabond の README の中に
- Issue: VMs are slow.
- Discovery: Linux has LXC, which is pretty cool.
- Helpful: LXCs can run different distributions.
- Implementation: Vagabond
最近の Rails アプリケーションの開発環境の傾向
- 普段 Rails のアプリケーションを書いていて、テストにとても時間がかかる (少しでも速くしたい)
- 最近の Rails のオープンソースのアプリケーションだと、Vagrantfile が用意されているものも多い。これからは開発環境とかも chef + vagrant とかになっていきそうな気がします
vagrant-lxc で Vagrant/VB と速さを比較してみたい
- VirtualBox は windows/mac をカバーしていて LXC に比べれば便利だけど、もし LXC のほうが Vagrant/VB on Mac よりパフォーマンスがよいのであればそっちを使いたいというのが動機です
- 今回は rails-dev-box を使って試してみます
setup vagrant-lxc
$ sudo apt-get -y install lxc redir
$ wget "http://files.vagrantup.com/packages/64e360814c3ad960d810456add977fd4c7d47ce6/vagrant_`uname -m`.deb" -O /tmp/vagrant.deb
$ sudo dpkg -i /tmp/vagrant.deb
$ vagrant plugin install vagrant-lxc
$ vagrant box add lxc-quantal64 http://dl.dropbox.com/u/13510779/lxc-quantal64-2013-04-10.box
$ vagrant up --provider=lxc
Spec for Mac
- Processor 2.53 GHz Intel Core 2 Duo
- Memory 8 GB 1067 MHz DDR3
- Software Mac OS X Lion 10.7.5 (11G63)
- SSD
Spec for Ubuntu
- AMI: ubuntu/images/ebs/ubuntu-precise-12.04-amd64-server-20130124 (ami-9763e696)
- Zone: ap-northeast-1a
- Type: m1.small
Vagrant/VB on Mac (memory は 2GB にした)
real 134m21.753s
user 24m7.230s
sys 66m6.972s
vagrant-lxc on Ubuntu (m1.small)
real 68m20.202s
user 50m21.161s
sys 11m42.844s
Vagrant/VB on Mac with NFS
real 68m55.946s
user 25m44.357s
sys 23m32.856s
結論
- lxc のパフォーマンスがよいことを期待したけど、NFS を有効にした VirtualBox とそんなに差がでなかったことが分かりました。
所感
- vagrant-lxc の cgroups の settings を有効にすると vagrant up で止まってしまった。
- つまり今回は cgroups でメモリなどを制限できていない状態だった。(コンテナから見るとホストOSとリソースを共有してる状態)
- vagrant-lxc は活発に開発してるけどまだバギーな挙動も多かった (一度 halt で止めると起動がうまくいかなかったりとか)
ありがとうございました :)