Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
1
  • Loading branch information
winesoft committed May 7, 2015
1 parent d9927ce commit eef6ec9
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 4 deletions.
40 changes: 40 additions & 0 deletions admin/adv_topics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,46 @@ Keep-Alive시간을 길게 줄수록 소켓의 재사용성은 좋아지지만



.. _adv_topics_tso:

TCP Segmentation Offload
====================================

.. important::

10G NIC를 사용한다면 TSO(TCP Segmentation Offload)를 OFF로 설정하길 권장한다.

TCP는 전송시 패킷을 분할(Segmentation)하는데, 이 작업을 CPU가 아닌 NIC가 수행하도록 설정하는 것이 TSO이다.
(기본 값은 ON이다.)
하지만 10G NIC 서비스 환경에서 우리는 이와 관련된 많은 장애를 겪었다.

- TCP 패킷 유실 및 지연
- TCP 연결 종료
- Load Average의 비정상적인 증가

결론적으로 TSO는 모두의 기대만큼 높은 성능을 내지 못하는 것으로 추정된다.
(NIC만 1G로 바꿔도 이런 문제는 발생하지 않았다.)
결론적으로 TSO를 OFF로 설정함으로써 서비스는 정상화되었다.
이에 따른 CPU 사용량은 우려할 수준이 아니며 서비스 규모와 비례하는 정직한 지표를 보여 준다.

TSO 설정은 다음과 같이 설정/확인할 수 있다. (K의 대/소문자에 유의한다.) ::

# ethtool -K ethX tso off // TSO OFF 설정
# ethtool -k ethX // 설정 열람
...
tcp segmentation offload: on
...

.. tip::

더 자세한 정보는 다음 링크를 참조한다.

- `http://sandilands.info/sgordon/segmentation-offloading-with-wireshark-and-ethtool <http://sandilands.info/sgordon/segmentation-offloading-with-wireshark-and-ethtool>`_
- `http://www.linuxfoundation.org/collaborate/workgroups/networking/tso <http://www.linuxfoundation.org/collaborate/workgroups/networking/tso>`_
- `http://www.packetinside.com/2013/02/mtu-1500.html <http://www.packetinside.com/2013/02/mtu-1500.html>`_




클라이언트 접속 제한
====================================
Expand Down
Binary file added admin/img/hls_alternates_off.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/img/hls_alternates_on.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 35 additions & 3 deletions admin/media.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ MP4파일 헤더의 위치에 상관없이 다운로드와 동시에 실시간
# vhosts.xml - <Vhosts><Vhost><Media>

<MP4HLS Status="Inactive" Keyword="mp4hls">
<Index Ver="3">index.m3u8</Index>
<Index Ver="3" Alternates="off">index.m3u8</Index>
<Sequence>0</Sequence>
<Duration>10</Duration>
<AlternatesName>playlist.m3u8</AlternatesName>
</MP4HLS>

- ``<MP4HLS>``
Expand All @@ -202,13 +203,29 @@ MP4파일 헤더의 위치에 상관없이 다운로드와 동시에 실시간
- ``Ver (기본 3)`` 인덱스 파일 버전.
3인 경우 ``#EXT-X-VERSION:3`` 헤더가 명시되며 ``#EXTINF`` 의 시간 값이 소수점 3째 자리까지 표시된다.
1인 경우 ``#EXT-X-VERSION`` 헤더가 없으며, ``#EXTINF`` 의 시간 값이 정수(반올림)로 표시된다.

- ``Alternates (기본: OFF)`` Stream Alternates 사용여부.

.. figure:: img/hls_alternates_off.png
:align: center

OFF. ``<Index>`` 에서 TS목록을 서비스한다.

.. figure:: img/hls_alternates_on.png
:align: center

ON. ``<AlternatesName>`` 에서 TS목록을 서비스한다.

- ``<Sequence> (기본: 0)`` .ts 파일의 시작 번호. 이 수를 기준으로 순차적으로 증가한다.

- ``<Duration> (기본: 10초)`` MP4를 HLS로 분할하는 기준 시간(초).
분할의 기준은 Video/Audio의 KeyFrame이다.
KeyFrame은 들쭉날쭉할 수 있으므로 정확히 분할되지 않는다.
만약 10초로 분할하려는데 KeyFrame이 9초와 12초에 있다면 가까운 값(9초)을 선택한다.

- ``<AlternatesName> (기본: playlist.m3u8)`` Stream Alternates 파일명. ::

http://www.example.com/video.mp4/mp4hls/playlist.m3u8


서비스 주소가 다음과 같다면 해당 주소로 Pseudo-Streaming을 진행할 수 있다. ::
Expand All @@ -219,8 +236,23 @@ MP4파일 헤더의 위치에 상관없이 다운로드와 동시에 실시간
다음 URL이 호출되면 /video.mp4로부터 index.m3u8파일을 생성한다. ::

http://www.example.com/video.mp4/mp4hls/index.m3u8
생성된 index.m3u8(버전 3)은 다음과 같다. ::

``Alternates`` 속성이 ON이라면 ``<Index>`` 파일은 ``<AlternatesName>`` 파일을 서비스한다. ::

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=200000,RESOLUTION=720x480
/video.mp4/mp4hls/playlist.m3u8

``#EXT-X-STREAM-INF`` 의 Bandwidth와 Resolution은 영상을 분석하여 동적으로 제공한다.

.. note::

Stream Alternates를 제공하긴 하지만 현재 버전에서 index.m3u8는 항상 하나의 서브 인덱스 파일(playlist.m3u8)만을 제공한다.
캐시 입장에서는 video_1080.mp4와 video_720.mp4가 (인코딩 옵션만 다른) 같은 영상인지 알 수 없기 때문이다.


최종적으로 생성된 .ts 목록(버전 3)은 다음과 같다. ::

#EXTM3U
#EXT-X-TARGETDURATION: 10
Expand Down
2 changes: 1 addition & 1 deletion index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ STON Edge Server 완벽 가이드

:저자: STON 개발팀

:최신버전: 2.1.0, 2015년 4월 15일
:최신버전: 2.1.1, 2015년 5월 7일


1부. STON 기본: 설정 배우기
Expand Down

0 comments on commit eef6ec9

Please sign in to comment.