Recommanded Free YOUTUBE Lecture: <% selectedImage[1] %>

OpenVSwitch에서의 QoS Policing

멀티테넌트를 지원하는 컨테이너 기반의 SaaS 환경을 만들고 있다. 하나의 컨테이너 인스턴스에 여러 개의 SaaS 컨테이너가 네트워크 자원을 공유두고 경쟁을 한다. 따라서 SaaS 별로 트래픽을 제어 할 필요가 있다. OpenVSwitch의 QoS Policing를 이용해서 트래픽 대역폭을 제어하는 방법을 살펴보려 한다.

환경

VirtualBox로 VM을 하나 만들어서 여기에 docker를 설치했다. docker의 기본 네트워크는 리눅스 브릿지인데, 이걸 OpenVSwitch로 바꿨다. 테스트 환경은 아래와 같 구성했다.

 ovs 테스트 환경

OVS 브릿지를 만들고, 두 개의 가상 네트워크 디바이스(veth)를 만들어서 브릿지와 컨테이너를 연결 한다. 컨테이너와 가상머신에는 iperf를 설치해서 네트워크 대역폭을 측정한다. 두 개의 물리적인 호스트를 사이에 두고 테스트하면 좋겠으나, 기능에 대한 테스트는 이것으로 충분하다.

OVS 브릿지 네트워크 구성

OVS 브릿지를 이용한 네트워크 환경은 Docker 레퍼런스 네트워크 구성문서를 참고해서 구성하자. 구성했다고 가정하고 진행한다.
  • OVS 브릿지 이름 : ovs-docker0
  • OVS 브릿지 네트워크 : 172.17.0.0/16
  • 가상 네트워크 디바이스 : veth-a, veth-b. 전자는 OVS 브릿지에 후자는 컨테이너에 붙였다.
현재 브릿지 상태는 다음과 같다.
# ovs-vsctl show
56850bfb-9a48-4221-8333-99aa683ea23d
    Bridge "ovs-docker0"
        Port veth-a
            Interface veth-a
        Port "ovs-docker0"
            Interface "ovs-docker0"
                type: internal
    ovs_version: "2.4.0"

컨테이너의 네트워크 정보는 다음과 같다.
root@54022377aa4c:/# ifconfig
eth0      Link encap:Ethernet  HWaddr 12:34:56:78:90:01  
          inet addr:172.17.10.2  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::1034:56ff:fe78:9001/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:830 (830.0 B)  TX bytes:830 (830.0 B)

QoS Policing 설정

ingress_policing_rate와 ingress_policing_burst를 이용해서 traffic rate를 설정 할 수 있다.
  • ingress_policing_rate : 컨테이너가 전송 할 수 있는 최대 rate. 단위는 Kbps다.
  • ingress_policing_burst : ingress_policing_rate를 초과해서 전송 할 수 있는 최대 데이터 크기로 단위는 Kb다.
예를 들어 컨테이너에 10Mbps의 대역폭을 허용하고 싶다면 아래와 같이 설정하면 된다.
# ovs-vsctl set interface veth-a ingress_policing_rate=1000
# ovs-vsctl set interface veth-a ingress_policing_burst=100

테스트

iperf 설치

가상 머신과 컨테이너에 iperf를 설치한다. 가상머신에서는 서버모드로 실행하고 컨테이너에서는 클라이언트 모드로 실행한다.
// 서버모드로 실행
# iperf --server
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------

// 클라이언트 모드로 실행
// 10초동안 서버로 트래픽을 전송하고, 결과를 레포팅 한다.
# iperf --client 192.168.56.10

QoS Policing 설정이 없는 상태

설정을 하지 않을 경우, 대역폭 사용에 제한이 없다. veth-a의 설정정보를 보자.
# ovs-vsctl list interface veth-a
_uuid               : 0f319845-f767-4e12-bf30-a2a04d48022d
admin_state         : up
bfd                 : {}
bfd_status          : {}
cfm_fault           : []
cfm_fault_status    : []
// 생략 ....
ingress_policing_burst: 0
ingress_policing_rate: 0
lacp_current        : []
link_resets         : 1
link_speed          : 10000000000
// 생략 ....

QoS Policing 적용

1Mbps 로 설정했다.
# ovs-vsctl set interface veth1453-1 ingress_policing_rate=1000
# ovs-vsctl set interface veth1453-1 ingress_policing_burst=100 
가상 인터페이스의 정보를 확인했다.
# ovs-vsctl list interface veth1453-1
_uuid               : 0b230446-875c-4a7d-8742-ab82c730b7d1
admin_state         : up
......
cfm_remote_opstate  : []
duplex              : full
error               : []
external_ids        : {}
ifindex             : 10
ingress_policing_burst: 100
ingress_policing_rate: 1000
......

테스트 결과
# iperf --server
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 192.168.56.5 port 5001 connected with 172.17.0.5 port 50342
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-13.3 sec  1.62 MBytes  1.02 Mbits/sec

10Mbps로 설정했다.
# ovs-vsctl set interface veth1453-1 ingress_policing_rate=10000
# ovs-vsctl set interface veth1453-1 ingress_policing_burst=1000

테스트 결과
# iperf --server
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 192.168.56.5 port 5001 connected with 172.17.0.5 port 50344
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-10.3 sec  12.9 MBytes  10.5 Mbits/sec

참고

  1. qos-rate-limiting
  2. Docker 레퍼런스 네트워크 구성