Why I use zones on my server instead of using whole server?
I have a small vps server with 2 vcores and 2gb ram. And I created a lot of zones inside this server! Am I mad? No! I like zones.
A smartos zone, same as solaris container, is a lightweight container like docker, but not same, more powerful. Also smartos provides images for zones. An image is template for os. You create zones/kvms from these templates. You can create your own images to. Also serve your images. You can allocate resources to zones. One’s strength of zone is you can configure any resource you want such as swap, cpu core (may be decimal such as 0.5).
I have a small server, however I want to serve a lot of thing. Also I do not want some service may block others’ resources. Hence I need to divide resources with containers. Unix can provide several type of containers. For lightweight virtualization, linux we have lxc/docker, for smartos/solaris we have zones.
For about one year, I read, research containers. Docker seems good, however I am not satisfied with it, it is a matter of personal choice. The main reason of it comes from the biggest os limit: I cannot use zfs with docker, especially snapshots. I tried btrfs, but after some kernel panics, I return to use zfs on linux. Zfs snapshot is very important, because of release update. If something fails you can revert easily and zfs snapshots do not use disk space like lvm snapshots. Lvm snapshots are good for backup (incremential), but that’s all.
When I use omnios, I used and accustomed to zonecfg. However smartos uses vmadm for managing zones, one tool for rule them all (zones, kvm, lxc,…). A big pitfall of vmadm is using uuid for identifying zones, etc. And it needs two command, get uuid and run actual command.
Let’s return our main topic why I divide my server into small chunks (zones). Zones do not waste memory, small then 30mb. So creating several zones cannot be a big pitfall. I create two zones for db and minimal two zones for web applications. So I used my <120mb of memory for memory print of zones. Not very much for me. And the main reason of two kind of zones is isolation of database and application. But I continue to create more than two zones. Why?
Let’s investigate a scenario: Linode2048 plan is consist of two vcores and 2gb memory. One visitor caused your application consumes 1.5 vcores or 1.5gb memory. And remaining resources for other your 999 visitors. A very nice situation. Smartos consumes 256mb ram for itself, not much, probably same as a empty linux server. If i create two database zone and, two web application zone, such as 256mb ram and 0.5 ncores for each server. Our famous visitor visits one of app server and db server. And visitor can consume max 0.5 vcore or 512mb ram (total of db and application, mostly max 256mb, however we like worst and weird cases, don’t we?). And it has effect on 500 visitors (load balancing). Other 500 visitors do not meet our famous visitor. So bad!
The isolation with zones is minimizing effect of high loads. You should calculate and estimate cpu and memory usage. And divide your server into zones which provides a good balance of resource allocation while weird situations like bugs, memory leaks, attack by a visitor, etc.
I like zones.
Short Url:http://srkykzm.com/s/Elqv8PJ