linux cgroup blkio子系統的用法.
.1. (completely fair queuing 完全公平隊列)cfq io排程政策,支援按權重配置設定io處理的時間片,進而達到io在各資源組直接的排程和限制的目的,權重取值範圍100-1000。
通過以下兩個檔案進行配置。
例子
cfq 排程器以及其他io排程器的介紹詳見核心文檔.
documentation/block/
.2. 限制iops使用上限
例子如下
這兩種資源限制手段各有特色,cfq的方法比較公平,互相不會幹擾,在確定最低使用io比例的情況下,如果io裝置空閑,還能超限使用。 (一句話就是保證最低的 iops)
限制iops上限的方法,所有組加起來的iops可以超出塊裝置的最大iops名額,實作錯峰使用的目的,但是壞處是如果超出最大名額太多,平時可能造成争搶導緻sla無法保證。 (一句話就是限制最高的 iops)
注意,目前blkio子系統不統計buffered write操作,僅僅統計direct i/o的操作。但是buffered read是統計在内的。
.1. 通過權重的方法限制io的使用比例。
blkio子系統中需要用到塊裝置的major, minor号,可以通過以下方法檢視
對于權重的方法,如果要對離散的i/o操作起到公平的排程,必須打開塊裝置的group_isolation設定。
additionally, you can enable group isolation which provides stronger isolation between groups at the expense of throughput.
when group isolation is disabled, fairness can be expected only for a sequential workload.
by default, group isolation is enabled and fairness can be expected for random i/o workloads as well.
to enable group isolation, use the following command:
<a href="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide/ch-subsystems_and_tunable_parameters.html">https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide/ch-subsystems_and_tunable_parameters.html</a>