Categories: Linux筆記

Openvz和Xen的技術規格分析

一、Openvz和Xen的技術規格分析
1.Xen與Openvz的區別
Xen和Openvz同樣是虛擬化主機技術,區別在于Xen是半虛擬化技術,它幷不是一個真正的虛擬機,而是相當于自己運行了一個內核的實例,可以自由的加載內核模塊,虛擬的內存和IO,穩定而且可預測。Openvz則是操作系統級別的虛擬化技術,是底層操作系統上的一層應用,這意味著易于理解和低權重開銷,一般來說也意味著更優的性能。
這裏有一個問題,可以看到實際上openvz因爲免去了大量的公共開銷,理論上來說性能會比xen更好。爲什麽大家都會認爲openvz過分壓榨性能呢?我認爲是因爲openvz配置起來比較靈活,給黑心 openvz服務商改低限制的機會。
比如mediatemple,號稱512M內存的dv方案,kmemsize才12M,不瞭解的人看了512M覺得很哈皮啊,可是使用的時候一般這512M能分到你手裏一半就不錯了。此消彼長,所以才會有xen 能更好地利用機器性能的錯覺。
2.Openvz的內核模型
首先當OpenVZ的主機說“256MB的保證”,它實際上意味著約232MB的“privvmpages”,14M的“kmemsize”和其他雜項資源。當應用程序調用 malloc()分配的內存將被添加到“privvmpages”。
當“privvmpages”超過限制,malloc()將失敗幷返回一個NULL。當主機服務器內存用光了,然後虛擬環境下的進程超過 “oomguarpages”的將被終止。
OpenVZ的內存管理方法既有問題也有優勢。最大的問題之一是內存容量的應用程序使用的內存和應用程序實際上分配到的內存是不同的,不同的應用程序他們的差別可能會很大。以Java爲例,它通常分配一大塊的內存,但是,它可能只使用一小部分分配的內存。如果privvmpages受限,java會立即停止運行。調整參數可以解决一部分問題,但它處理得絕對沒有Xen來得乾淨利落。事實上,幾乎所有使用內存分配的應用程序都會受OpenVZ這個問題的影響。
/proc/meminfo 本身也有問題。雖然OpenVZ的已經爲內存進行了虛擬,但是用”free”命令依然會返回主機的內存。這樣就會使小內存的openvz的vps無法運行諸如java或者gcc編譯這樣的程序。
OpenVZ的內存模型的優點是, 它容易理解: 你幾乎就只有privvmpages受限。與專用的服務器或Xen的服務器不一樣的是,你的磁盤高速緩存和頁面緩存幷不計入您的總內存使用情况。因此,在一個沒有過度銷售的openvz主機上,由于擁有較大冗余的公共資源,它實際上可能會比同類規格的Xen的VPS表現更佳。
3.Xen的內存模型
Xen的系統模型更容易解釋。256MB的Xen的VPS是就像一個256MB的專用服務器-該內存段是預留作VPS專用,沒有其他VPS能够使用這部分內存,這就像一個真正的專用服務器。
此外,當內存不足時,VPS會使用Swap。一般每個VPS帶有兩倍大小的交換分區,當您的應用需要更多的內存,不常使用的頁面從內存中被換出到交換分區,從而騰出使更多的房間。因此,256MB的Xen的VPS系統實際上共有768MB內存(256MB內存+ 512MB的交換空間),請相信我,交換空間是非常有用的,特別是處理突發的需求高峰時。
這麽說來,Xen是永遠遠優于OpenVZ?不然,你的256MB的VPS理論可以使用高達768MB內存,而實際上內核,高速緩存,緩衝,他們都占用內存。這部分系統開銷也是可觀的。另外,Swap會嚴重降低性能。
4.穩定性和可預測性
當內存耗盡時,xen和openvz表現大相徑庭。xen會把不常用的內存頁面換入Swap,這將大大降低性能,當Swap也用盡,那麽xen的系統會響應得越來越慢,就像一台真實的服務器一樣。
而openvz一旦內存用盡,則會突然死亡:開不出新的程序,只能等待系統資源可用。更有甚者,本來運行的好好的程序也可能因爲不斷增長而超過限制,然後突然死亡。這就像開車開到70碼,然後突然撞墻上了,一般會死得很慘。
毫無疑問這點上我傾向于xen技術,可預測,穩定。
5.結論
如果xen和openvz一樣貴,我肯定選xen,因爲可預測性,即使openvz打8折,我還是追求穩定。
上面的話總結一下,得出幾個結論:
1、XEN比openvz主機對買家更有利,比如分配給你512M內存後,這一部分內存就從服務器上專門劃給你了,別人將無法使用,而openvz則是共用內存,比如分配給你512M內存是指最大你能使用512M內存,比如你占用了200M內存,那麽就只從物體內存中分配200M給你,所以賣家非常容易在服務器上面超賣!
2、openvz更高效,xen是硬件底層虛擬,更接近真實服務器,而openvz是操作系統虛擬,虛擬服務自身占用內存少,同樣的程序執行效率更高!
3、如果購買openvz應看賣家是否會超賣,應選擇良好聲譽明確申明不會超賣的
4、如果購買xen主機,應同時關注swap大小
5、測試VPS主機性能使用Unixbench(很多人不知道),國外非常流行這個東西!
這是它的一些參數說明
• dhry2reg 內存的register性能
• whetstone-double 雙精度浮點性能
• execl execl call性能
• fstime 文件系統性能
• fsbuffer 文件系統性能
• fsdisk 文件系統性能
• pipe 管道(pipe)的性能
• context1 管道上下文切換的性能
• spawn 創建進程的性能
• shell shell幷發性能
• syscall 系統調用性能
6、VPS用途:服務器、軟交換、代理和反向代理、離綫BT下載等等
7.通常一般的使用條件下,兩者性能應該相差不大。

===============================

Openvz and Xen technical specifications analysis
The difference 1.Xen with Openvz
Xen and Openvz same mainframe virtualization technology , the difference is that Xen paravirtualization technology that Bing is not a true virtual machine , but the equivalent of running its own instance of a kernel , kernel modules can be loaded free virtual memory and IO, stable and predictable . Openvz is operating system -level virtualization technology, is a layer of applications on the underlying operating system , which means easy to understand and a low weight overhead , generally means better performance .
There is a problem , because you can see that in fact openvz eliminates a lot of public spending , in theory, the performance will be better than xen. Why do we all think too much press openvz performance? I think it is because it is more flexible openvz configuration , change to black heart openvz service providers the opportunity to lower limits .
For example mediatemple, known as 512M of memory dv program , kmemsize only 12M, 512M think people do not understand looked very Happy ah , but it is generally used in this 512M half could be assigned to your hand pretty good . Shift, so will have to make better use xen machine performance illusion.
2.Openvz core model
First, when the OpenVZ host says “256MB of guarantee” , it actually means about 232MB of “privvmpages”, 14M of “kmemsize” and other miscellaneous resources. When an application calls malloc () allocated memory will be added to the “privvmpages”.
When “privvmpages” over the limit , malloc () will fail Bing returns a NULL. When the host server memory runs out , then the process of virtual environments over “oomguarpages” will be terminated.
OpenVZ memory management methods have the advantage of both problems . One of the biggest problems is the memory and application memory capacity actually used by the application is assigned to a different memory , different applications can be significant differences between them . In Java , for example, it usually allocates a chunk of memory, however, it may use only a fraction of the allocated memory. If privvmpages limited , java will immediately stop running. Adjustment parameters can solve part of the problem , but it is absolutely no Xen handled more cleanly . In fact, almost all applications use memory allocation will affect this problem by OpenVZ .
/ proc / meminfo itself a problem. While OpenVZ has been carried out for the virtual memory , but with a “free” command will still be returned to the host memory. This will make the vps openvz small memory can not run as java or gcc compiler such procedures .
Advantages OpenVZ memory model is that it is easy to understand : you can almost only privvmpages limited. With a dedicated server or Xen server is not the same as your disk cache and page cache Bing does not count toward your total memory usage. Therefore, on a no overselling the openvz host , as has a large redundant public resources , it may actually perform better than the Xen VPS similar specifications .
3.Xen memory model
Xen system model is more easily explained. The Xen VPS 256MB 256MB is like a dedicated server – the memory segment is reserved for dedicated VPS , no other VPS to use this part of the memory , it’s like a real dedicated server.
In addition, when there is insufficient memory , VPS will use the Swap. Generally speaking, each VPS has twice the size of the swap partition , if your application requires more memory , infrequently used pages from memory to be swapped out to the swap partition, thus freeing make more room. Therefore , 256MB of Xen VPS system is actually a total of 768MB of RAM (256MB RAM + 512MB swap space ) , believe me , swap space is very useful , especially when you deal with sudden spikes in demand .
So to say , Xen is always much better than OpenVZ? Otherwise , you can use the VPS theory 256MB up to 768MB of memory , but in fact the core , the cache buffer memory for all of them . This part of the overhead is also considerable. Further , Swap seriously degrade performance .
4 . Stability and predictability
When memory is exhausted , xen and openvz performance to differ materially . xen will not commonly used memory pages swapped Swap, which will greatly reduce performance when Swap are exhausted , then the system will respond xen increasingly slowly, like a real server.
And openvz memory exhaustion once , then sudden death : not to open a new program , can only wait for the system resources are available . What is more , had to run the program may also be because of the continuing good growth over the limit , then sudden death. It’s like drove 70 yards, then suddenly hit the wall on the general will die miserable .
There is no doubt on this point I tend xen technology , predictable and stable.
5 Conclusion
If xen and openvz as expensive , I’m sure choose xen, because predictability, even openvz hit 8-fold , I still pursue stable.
To summarize the above , then , leads to several conclusions :
1, XEN host to buyers than openvz more favorable , such as 512M of memory allocated to you after this part of the memory on the server from scratch specifically to you , others will not be able to use , and openvz is shared memory , such as allocated to you 512M RAM is the maximum you can use 512M memory, for example, you take up a 200M memory , then only allocate 200M to you from the object memory, so the seller is very easy on the server above oversold !
2, openvz more efficient , xen underlying virtual hardware , closer to the real server, and virtual openvz operating system , virtual service itself occupies less memory and higher efficiency the same procedure !
3 , if the purchase openvz should see if the seller will oversold , you should choose a good reputation does not expressly stated oversold
4 , if the purchase xen host , should also concern swap size
5, the test VPS host performance using Unixbench ( many people do not know ) , this thing is very popular abroad !
This is a description of some of its parameters
• dhry2reg register memory performance
• whetstone-double double- precision floating-point performance
• execl execl call performance
• fstime file system performance
• fsbuffer file system performance
• fsdisk file system performance
• pipe conduit (pipe) performance
Performance • context1 pipeline context switching
• spawn the process to create performance
• shell shell Bing hair Performance
• syscall system call performance
6, VPS uses: server , softswitch , agents and reverse proxy , offline BT download , etc.
7 usually under normal conditions of use, performance should be little difference between the two .

yan

Share
Published by
yan