Weitere ähnliche Inhalte
Ähnlich wie GRUTER가 들려주는 Big Data Platform 구축 전략과 적용 사례: 인터넷 쇼핑몰의 실시간 분석 플랫폼 구축 사례 (20)
GRUTER가 들려주는 Big Data Platform 구축 전략과 적용 사례: 인터넷 쇼핑몰의 실시간 분석 플랫폼 구축 사례
- 1. © 2013 Gruter. All rights reserved.
실시간 분석 플랫폼
구축 사례
2013.08.28
김형준 수석 연구원
- 2. © 2013 Gruter. All rights reserved.
요구사항
• 실시간 데이터 수집
• 수집 단계에서 실시간 데이터 분석
• 실시간 분석 결과 실시간 데이터 제공
• 수집된 데이터 안정적 저장
• 저장소 데이터 배치 분석
• 저장소 데이터 검색
• 전체 클러스터 관리 및 모니터링
2
- 3. © 2013 Gruter. All rights reserved.
전체 아키텍처
3
웹 로그 수집 서버
WAS
log Agent
로그 Collector
Flume
Collector
분석 결과 저장소
검색 저장소
TCP
UDP
FTP
HDFS
Search
Real
Time
원본 파일 저장소
로그 Collector
Flume
Collector
TCP
UDP
FTP
HDFS
Search
Real
Time
실시간 분석
Application Server
사용자 행동
분석 로직
실시간 분석 클러스터
실시간 분석
Application Server
실시간 분석 로직
HBase
(NoSQL)
Table Table Table
ElasticSearch
Latest
Index
Backup
Index
Hadoop File System
Hive
Table A
Hive
Table B
배치분석
Hadoop MapReduce
Map
Reduce
클러스터 관리
ZooKeeper
Cloumon
Hive
질의
MySQL
- 5. © 2013 Gruter. All rights reserved.
실시간 분석 예 #2
• 페이스북 Social-Plugin
5
수집
실시간분석
실시간
Feedback
배치분석
process over 20 billion events per
day (200,000 events per second)
with a lag of less than 30 seconds.
Analytic
Transactional
- 7. © 2013 Gruter. All rights reserved.
현실은?
• 가장 기본적인 로그 조차도 일 단위 분석
– HTTP LOG 등
• 비즈니스에 중요한 데이터는 로그도 없음
• 일부 로그는 외부 업체로 전달
7
- 8. © 2013 Gruter. All rights reserved.
실시간 분석의 어려움 #1
• 중복, 유실, 성능 모두를 만족시키기 어려움
– 이중화된 큐와 체크 포인팅 기능이 핵심
– 체크 포인팅을 많이 사용하면 성능 저하 적게 사용하면 유실율
이 높아짐
• 성능
– 대량의 데이터
– 분석의 복잡성(다양한 메타 데이터와 연계 등)
• 운영 관리
– 무정지로 운영 되어야 함
– 비즈니스 로직 변경에 따른 배포
• 분석 결과 저장
– 체크 포인트
– 최종 결과
– 시각화
8
- 9. © 2013 Gruter. All rights reserved.
실시간 분석의 어려움 #2
• 시간 관리
– 분산된 환경의 시간 동기화
– Time window 동기화
– Data time vs. System time
• 분석 로직 구현
– SQL 기반
– 프로그램 기반
• 플랫폼들의 조합
– Flume, Storm, Kafka 등
– 각 솔루션은 HA 등에 대한 기능 제공
– But, 조합 시 불협화음
– 서버 사이징
• Agent/Collelctor 댓수 비율, CPU/Network 등
9
- 10. © 2013 Gruter. All rights reserved.
참조 아키텍처 #1
• Facebook Social Plugin
10
/category1/collect_1.dat
/category1/collect_2.dat
/category1/collect_3.dat
데이터 수집기
(scribe)
데이터 수집기
(scribe)
데이터 수집기
(scribe)
Hadoop
Write, sync
Key1: value
Key2: value
Key3: value
HBase
ptail
Driver
Aggregation
Store
Checkpoint
Handler
Storage
Thrift
Server
클라이언트
- 11. © 2013 Gruter. All rights reserved.
참조 아키텍처 #2
11
http://highlyscalable.wordpress.com/2013/08/20/in-stream-big-data-processing/
- 12. © 2013 Gruter. All rights reserved.
개발 시스템 아키텍처
12
ZooKeeper
분석 결과 저장소
(HBase)
Realtime Server
Partition
Proxy
Partitioner
Processor
Engine
User
Processor
ReplicatorQueue
Time Window
Manager
(Master Role)
Flume Collector
Realtime
Client
Partition #2
Partition #1
Partition #3
Flume Collector
Realtime
Client
Dimension
Data
memory
- 13. © 2013 Gruter. All rights reserved.
구성 요소
• Realtime Server
– 외부로부터 데이터를 수신하여 사용자가 개발한 분석 프로그램을 실행해주는 데몬 프로세스
– 여러 대의 물리적인 서버에 분산 배치
– 서버 자체는 분석 기능을 가지고 있지 않음
– 서버 장애를 대비하여 서버 별로 Slave 서버를 구성할 수 있음
• Cluster Master
– 클러스터 중 한대가 마스터 역할 수행, 자동으로 Master가 선정
– 서버 장애 시 Partition Master/Slave failover 수행
– 작업 그룹의 Flush 주기에 따라 Flush Scheduler 수행
– 서버 사이의 타임 동기화 작업
– 파티션 추가 및 제거 등 클러스터 관리 작업
• Realtime Client
– 실시간 분석 클러스터로 분석 대상 데이터를 전송하는 프로그램에서 사용하는 모듈
• ZooKeeper(시스템 외부)
– 클러스터의 전체 서버 상태 정보, Workgroup 정보 등 클러스터를 운영하는데 필요한 메타 정보 관
리
– Flush 이벤트 등 이벤트 전송
• 분석 결과 저장소(시스템 외부)
– 분석 결과를 저장하는 저장소
– 동시 저장 데이터가 많고 분석 서버가 많은 경우 HBase와 같은 분산 데이터 저장소 사용
– 결과 데이터가 작고 결과를 다양한 질의로 통해 조회하는 경우 MySQL과 같은 RDBMS 사용
13
- 14. © 2013 Gruter. All rights reserved.
특징
• 고정된 크기의 클러스터 파티션
– 각 서버는 시작 시 지정된 파티션 ID를 가짐
– 데이터 파티션 처리 쉬운 장점
– 서버 추가/제거는 Shell 명령을 가능
• 파티션 이중화
– 하나의 파티션은 두 개의 서버가 담당(Master/Slave)
• 분산 실시간 분석에 필요한 다양한 모듈 기본 제공
– 분산된 서버들 사이에 동기화된 Flush 기능
– Time 동기화 기능
– SQL-Like 질의 기반 분석 도구인 Esper와 연계 모듈
• WorkGroup
– 하나의 분석을 수행하기 위해서는 여러 개의 분석 모듈이 연결 되어야 함.
– 하나의 클러스터로 여러 개의 분석 업무를 동시에 수행
• 자체 개발
– 공개된 실시간 분석 솔루션은 다음 기능 제공
• 데몬 서버, 데이터 송수신 RPC, 프로그램 모델, 데이터 파티셔닝, Queue와 연동
– 활용 가능한 조각 모음은 대부분 오픈 소스로 나와 있음
• RPC: Thrift, Avro, Protobuf, Netty
• Event, Cluster Membership, Synchronization : ZooKeeper
• Query Processing: Esper
• Queue: Kafka, RabbitMQ, ZeroMQ
14
- 15. © 2013 Gruter. All rights reserved.
데이터 처리 흐름
15
Log Parsing
Log Parsing
Log Parsing
log
data
URL, Count(1)
Group by URL
URL, Count(1)
Group by URL
Count
(Distinct User)
Count
(Distinct User)
HBase Table
TOP 100
Order by count
Desc
hash(url) time batch 60 sec.
hash(user_id)
time batch 20 sec.WorkGroup #2
(LogType=User)
WorkGroup #1
(LogType=URL)
IP-City
DataLoad in memory
- 16. © 2013 Gruter. All rights reserved.
분석 프로그램 예시
16
public class WordCountProcessor extends AnalysisProcessor {
private Map<String, Integer> wordCountMap = new HashMap<String, Integer>();
public String getWorkGroupName() {
return "wordcountGroup";
}
public String getEventType() {
return "wordcount";
}
public int getPartitionId(EventParsedRecord eventParsedRecord, int numPartition, int serverId) {
return getHashPartitionId(eventParsedRecord.getKey(), numPartition);
}
public EventParsedRecord parseEvent(String event) throws IOException {
EventParsedRecord eventParsedRecord = new EventParsedRecord();
eventParsedRecord.setKey(event);
return eventParsedRecord;
}
public void process(String type, EventParsedRecord eventParsedRecord, boolean serverPairMaster) {
Integer count = wordCountMap.get(eventParsedRecord.getKey());
if(count == null) wordCountMap.put(eventParsedRecord.getKey(), 1);
else wordCountMap.put(eventParsedRecord.getKey(), count + 1);
}
public void flush(long flushTime, boolean serverPartitionMaster) throws IOException {
if(serverPartitionMaster) {
for(Map.Entry<String, Integer> entry: wordCountMap.entrySet()) {
HBaseStore.store(“T_WORD_COUNT”, entry.getKey() + ”,“ + entry.getValue());
}
}
}
- 17. © 2013 Gruter. All rights reserved.
결론
• 실시간 분석은 대세이지만 많은 난관이 존재
– 고객의 요구(정합성, 안정성 모두 만족 등)
– 메타 정보(JOIN) 처리 성능
– 운영의 어려움(항상 데이터가 흘러 다님)
• 분석 대상 데이터의 속성, 분석 로직 등에 따라
적절한 플랫폼 선택
– 플랫폼은 기본만 제공
– 많은 것을 그 위에 만들어야 함
– 적절한 플랫폼이 없으면 만드는 것도 방법
17
- 18. GRUTER: YOUR PARTNER
IN THE BIG DATA REVOLUTION
Phone +82-70-8129-2950
Fax +82-70-8129-2952
E-mail contact@gruter.com
Web www.gruter.com
© 2013 Gruter. All rights reserved.
Gruter, Inc.
5F Sehwa Office Building 889-70 Daechi-dong, Gangnam-gu, Seoul, South Korea 135-839