SlideShare une entreprise Scribd logo
1  sur  51
Télécharger pour lire hors ligne
Web Analytics at Scale with Elasticsearch @ naver.com
Part 2 - Lessons Learned
허정수 / 네이버
jason.heo.sde@gmail.com
Agenda
• Introduction
• 콘텐츠소비통계
• Part I - Architecture
• Initial Architecture -> Problems & Solutions -> Proven Architecture
• Data Pipelines
• Part II - Lessons Learned
• 성능 개선 Tip
• 운영 Tip
2017.06.22. 밋업 발표 내용
Part 1 발표 영상 https://youtu.be/Mc9gy-5d60w?t=10m40s
콘텐츠소비통계
회사 내부 직원용이 아닌,
네이버 사용자를 위한 서비스
네이버 블로그
(2016.06. 서비스 시작)
공통통계플랫폼
(2016.01. 개발 시작)
네이버 사용자
YYY 서비스
(2017.07. 서비스 시작)
다양한 네이버의 서비스들
OOO 서비스
(2016.09. 서비스 시작)
…
…
XXX 서비스
(2017.10. 서비스 계획)
…
<블로그 프론트엔드>
<블로그 통계 메뉴>
Goal
High
Throughput
Low
Latency
Ease
of Use
Architecture
Kafka 1
(Raw Log)
Kafka 2
(Refined Log)Transform
Realtime
ESLoader
Parquet
Loader
Scoreboard
Loader
Logstash
nginx
access log
Realtime
ES Cluster
Batch
ES Cluster
Parquet
Files
nBase-ARC
(Redis Cluster)
SparkSQL
Node.jsEnd Users
SparkSQL
Impala
업무
요청
&
내부
지표Zeppelin
Versions
1. Elasticsearch 2.3 & es-hadoop 2.3
2. Logstash 2.1
3. Spark 1.6
4. JDK 1.8 for ES, 1.7 for Spark
5. CDH 5.8
6. Storm 0.10
7. CentOS 7.2
8. Kafka 0.9
9. nBase-ARC 1.3
Agenda
• Introduction
• 콘텐츠소비통계
• Part I - Architecture
• Initial Architecture -> Problems & Solutions -> Proven Architecture
• Data Pipelines
• Part II - Lessons Learned
• 성능 개선 Tip
• 운영 Tip
8월 10일 밋업 내용
Execution Hint (1)
{
"query": {
"match": {...}
},
"aggr": {
"terms": {
"field": "u",
"execution_hint": "map"
}
}
Execution Hint (2)
SELECT u, COUNT(*)
FROM tab
WHERE <조건>
GROUP BY u
SQL 실행 순서
1. "조건에 맞는 문서" 조회
2. u field로 Aggregation
예상수행 시간
- Matching Document 개수에 비례
- "조건에 맞는 문서" 개수가 0건이면 0초에 가까워야 한다
- Aggregation할 대상이 없으므로
Execution Hint (3)
Matching Document 개수
실험 결과
JVM Tuning (1)
Stop-The-World phase
Full GC 자체가 문제는 아니지만 종종 STW가 발생함
[INFO ][monitor.jvm ]
[hostname]
[gc][old][109757][7966]
duration [15.9s],
collections [2]/[16.2s], <= 16초 동안 아무 응답이 없음
total [15.9s]/[12.8m], memory [12.9gb]->[11.2gb]/[14.5gb],
all_pools {[young] [1.2gb]->[146.1mb]/[1.2gb]}{[survivor]
[394.7mb]->[0b]/[438.8mb]}{[old] [11.3gb]->[11gb]/[12.8gb]}
<ES Log에서 발췌>
JVM Tuning (2)
Tuning 전
JVM Tuning (3)
JVM Option – OLD Gen.으로 옮길 경향을 줄인다
-XX:MaxTenuringThreshold=15
-XX:NewRatio=7
-XX:SurvivorRatio=3
-XX:-UseAdaptiveSizePolicy
<Default GC Option> <GC Tuning>
Node별 GC 옵션을 다르게 한 뒤 입수 시, Heap 사용량 그래프
g1 gc (1)
• 100B docs are indexed
• 5 nodes in the cluster
• 3 nodes with cms gc
• 2 nodes with g1 gc
-XX:+UseG1GC
-XX:+PerfDisableSharedMem
-XX:+ParallelRefProcEnabled
-XX:G1HeapRegionSize=8m
-XX:MaxGCPauseMillis=250
-XX:InitiatingHeapOccupancyPercent=75
-XX:+UseLargePages
-XX:+AggressiveOpts
<g1 gc option>
https://wiki.apache.org/solr/ShawnHeisey#GC_Tuning
<Disclaimer>
elastic.co would like to recommend G1GC someday,
but not for now
g1 gc (2)
"gc": {
"collectors": {
"young": {
"collection_count": 141144,
"collection_time": "1.7h",
"collection_time_in_millis": 6295572
},
"old": {
"collection_count": 13005,
"collection_time": "20.6m",
"collection_time_in_millis": 1241134
}
}
}
"gc": {
"collectors": {
"young": {
"collection_count": 117135,
"collection_time": "1.4h",
"collection_time_in_millis": 5061268
},
"old": {
"collection_count": 2,
"collection_time": "27s",
"collection_time_in_millis": 27075
}
}
}
<cms gc> <g1 gc>
the output of node status (/_nodes/hostname/) API
Which one looks better?
g1 gc (3)
[INFO ][monitor.jvm ]
[hostname] [gc][old][109757][7966]
duration [15.9s], collections
[2]/[16.2s], total [15.9s]/[12.8m],
memory [12.9gb]->[11.2gb]/[14.5gb],
all_pools {[young] [1.2gb]-
>[146.1mb]/[1.2gb]}{[survivor]
[394.7mb]->[0b]/[438.8mb]}{[old]
[11.3gb]->[11gb]/[12.8gb]}
[2017-01-02 01:47:16,525][WARN ][monitor.jvm ]
[hostname] [gc][old][111127][1] duration [14.4s],
collections [1]/[15.2s], total [14.4s]/[14.4s],
memory [13.5gb]->[11.2gb]/[15gb], all_pools
{[young] [176mb]->[40mb]/[0b]}{[survivor]
[96mb]->[0b]/[0b]}{[old] [13.2gb]-
>[11.2gb]/[15gb]}
[2017-01-02 03:28:27,815][WARN ][monitor.jvm ]
[hostname] [gc][old][117128][2] duration [12.6s],
collections [1]/[13.5s], total [12.6s]/[27s],
memory [14.1gb]->[11gb]/[15gb], all_pools
{[young] [320mb]->[112mb]/[0b]}{[survivor]
[96mb]->[0b]/[0b]}{[old] [13.8gb]-
>[10.9gb]/[15gb]}
<cms gc>
stw occurred 1 time, 16.2s
<g1 gc>
stw occurred 2 times, 28.7s
STW with g1 gc took a longer time than cms gc
Circuit Breaker (1)
SELCT c, u, COUNT(*)
FROM monthly_idx // 수십억건짜리 Index
GROUP BY c, u
과도한 메모리 사용
GROUP BY with more than two high cardinality fields causes OOM
Full GC만 계속 발생
모든 질의에 대한 응답 없음 ES Full Start 방법 밖에 없음
Circuit Breaker (2)
• 전체 메모리의 2.5% 이상 사용 시, 수행 중인 Query가 Fail되지만,
• Cluster 전체가 먹통되는 현상 방지 가능
PUT /_cluster/settings
{
"persistent": {
"indices.breaker.request.limit": "2.5%"
}
}
Index 휴지통 기능 (1)
• 사전 개념 - alias
daily_2017.01.01
(alias)
daily_2017.01.01_ver_1
(실제 index)
장점
Partial Data가 서비스 되는 것을 맊을 수 있음
(all or nothing)
입수 중
Client
조회 요청
Alias가 없으므로
조회되는 Data 없음
Index 휴지통 기능 (2)
• 사전 개념 - alias
daily_2017.01.01
(alias)
daily_2017.01.01_ver_1
(실제 index)
Data가 온전히 입수 완료되었을 경우에만 alias 생성
입수 완료
Client
조회 요청
ver_1에 속한
Data가 전송
Index 휴지통 기능 (3)
• 사전 개념 - alias
daily_2017.01.01
(alias)
daily_2017.01.01_ver_1
(실제 index)
Rollback도 가능
재입수
daily_2017.01.01_ver_2
(실제 index)
Client
조회 요청
ver_2에 속한
Data가 전송 입수 완료 후 alias 교체
Index 휴지통 기능 (4)
daily_2017.01.01
(alias)
daily_2017.01.01_ver_1
(실제 index)
.Trash
(alias)
index 삭제 – Alias만 끊는다. Data 조회 안 됨
주기적으로 .Trash에 Alias 걸린 Index 삭제
Client
Index 휴지통 기능 (5)
daily_2017.01.01
(alias)
daily_2017.01.01_ver_1
(실제 index)
.Trash
(alias)
실수로 삭제한 경우 Alias만 교체하면 됨
Client
{
"actions": [
{
"remove": {
"indices": ["daily_2017.01.01_ver1"],
"alias": "*"
}
},
{
"add": {
"indices": ["daily_2017.01.01_ver1"],
"alias": ".Trash"
}
}
}
Index 휴지통 기능 (6)
DELETE /daily_2017.01.01_ver1
적절 Shard 개수, Size
Num of shards Docs per shard shard size Query 1 (sec) Qeury 2 (sec) Query 3 (sec)
5 4천만 17GB 0.6524 0.7728 0.8876
10 2천만 8.5GB 0.5328 0.5554 0.4526
20 1천만 4.2GB 0.8972 0.5044 0.5578
Shard Size별 Query 응답 시간 조사
문서 개수 2억개 기준
• Shard Size별 응답 시간이 크지 않음
• 저희는 Shard Size를 10GB 이내로 사용 중입니다
• Index 개수가 많지 않은 경우 Shard 개수는 (Core 개수 * 2)개 정도가 좋습니다
Reduce Disk Size
• Disabling _all field: 18.6% 감소
• Disabling _source field: 20% reduced
• Think before disabling the _source field
Logstash option for exactly-once (1)
Options for File input
• start_position => "beginning" for log rotate
• http://jason-heo.github.io/elasticsearch/2016/02/28/logstash-offset.html
Options for Kafka Output
• acks => "all"
• retries => n
Logstash option for exactly-once (2)
access_log
stat_interval (1초)
discover_interval (15초)
log rotate 시점
(신규 파일 생성)
end인 경우 유실 발생
• stat_interval: 파일 갱신 여부 검사 주기
• discover_interval: pattern에 맞는 신규 파일 생성 여부 검사 주기
access_log
신규 파일 인지 시점
Logstash option for exactly-once (3)
Broker 1
Leader
Broker 2
Follower 1
output
{
kafka {
...
compression_type => 'gzip'
acks => "all" # default:1
retries => 5 # defualt:0
}
}
Broker n
Follower m
ack
ack
The leader waits for all the acks sent by followers
Pros: Strongest available guarantee.
Cons: Slow
cf) acks=>"1" means that the leader will respond
without waiting the follower's ack
Option for the Kafka Output
Nested Document format (1)
[
{
"c": "blogger1",
"u": "url1",
"g": "m",
"a": "1",
"pv": 10"
},
{
"c": "blogger1",
"u": "url1",
"g": "f",
"a": "2",
"pv": 20"
}
]
[
{
"c": "blogger1",
"u": "url1",
"page_views": [
{
"g": "m",
"a": "1",
"pv": 10"
},
{
"g": "f",
"a": "2",
"pv": 20"
}
]
}
]
<Nested Doc><Flattened Doc>
• c: blogger id
• u: url
• g: gender
• a: age
Nested Document format (2)
sqlContext.sql("
SELECT c, u, g, a, COUNT(*) AS pv
FROM logs
GROUP BY c, u, g, a
").saveToEs("index_name/doc_type")
일반적인 저장 모델 - Flattened Doc Model
<입수 스크립트>
[
{
"c": "blogger1",
"u": "url1",
"g": "m",
"a": "1",
"pv": 10"
},
{
"c": "blogger1",
"u": "url1",
"g": "f",
"a": "2",
"pv": 20"
}
]
<문서 포맷>
Data 중복
Nested Document format (3)
case class PageView(g: String, a: String, pv:
Integer)
sqlContext.udf.register("page_view", (c: String, u:
String, pv: Integer) => PageView(c, u, pv))
sqlContext.sql("
SELECT c, u, COLLECT_LIST(page_view) AS page_views
FROM (
SELECT c, u, page_view(g, a, pv) AS page_view
FROM (
SELECT c, u, g, a, COUNT(*) AS pv
FROM logs
GROUP BY c, u, g, a
) t1
) t2
GROUP BY c, u
").saveToEs("index_name/doc_type")
Nested Doc Model
<입수 스크립트>
[
{
"c": "blogger1",
"u": "url1",
"page_views": [
{
"g": "m",
"a": "1",
"pv": 10"
},
{
"g": "f",
"a": "2",
"pv": 20"
}
]
}
]
중복 제거
Nested Document format (4)
• Pros
• Data size is 49% smaller than Flattened Model
• Bulk Loading time is 52% faster than Flattened Model (including
extra processing time)
• Cons
• Extra processing is required using SparkSQL
• But the bottleneck is saving the result to ES. Extra processing time is not a
problem
• ES gets slower when nested field has too many children
• So, use it when the number of children is small
{
"properties" : [
...
"c" : {
...
},
"type" : {
...
},
...
]
}
복합 필드 (1)
초기 Schema
질의 패턴
• c로도 조회: 5%
• type으로 조회: 3%
• 두 개 필드 AND 조회: 92%
위의 질의 패턴을 모두 지원해야 함
참고: ES에는 복합키 개념이 없다
{
"properties" : [
...
"c": {
...
},
"type": {
...
},
"ctype": {
...
}
]
}
복합 필드 (2)
c와 type을 조합한 1개 추가 생성
<schema>
{
"c": "blogger_id",
"type": "channel_pv",
"ctype": "blogger_id:channel_pv",
"pv": 10
}
<Document 예>
복합 필드 (3)
응답 속도 40% 개선 (Page Cache Miss 시)
{
"query_type": "BooleanQuery",
"lucene": "+c:blogger_id +type: channel_cv"
"time": "269.686223ms"
}
{
"query_type": "ConstantScoreQuery",
"lucene": "ConstantScore (ctype:c:blogger_id:channel_cv)",
"time": "124.790570ms"
}
<ES Query Profile 결과>
single doc의 일부 field 조회 개선 (1)
{
"query": {
"bool": {
"must": [ {
"term": {
"primary_key": "xx"
}
}]
}
},
"_source": {
"includes": ["pv"]
}
}
SELECT pv
FROM tab
WHERE primary_key = 'xx'
<DSL>
<SQL>
_source 필드에서 Data 조회
single doc의 일부 field 조회 개선 (2)
{
"query": {
...
...
},
"aggregations": {
"MAX(pv)": {
"max": {
"field": "pv"
}
}
}
}
SELECT MAX(pv)
FROM tab
WHERE primary_key = 'xx'
<DSL>
<SQL>
Doc Value에서 Data 조회
조회 문서가 1건이므로
pv = MAX(pv) = MIN(pv) = AVG(pv)
single doc의 일부 field 조회 개선 (3)
Query 조회 방식 처리량 (QPS) 평균 응답 시간 (ms)
Q1
_source 활용 4,604 107
Doc Value 활용 7,484 66
Q2
_source 활용 5,024 98
Doc Value 활용 7,595 65
single doc의 일부 field 조회 개선 (4)
_source Doc Value
single doc의 일부 field 조회 개선 (5)
• ES 5.x에는 Doc Value Fields라는 것이 생겼음
• 앞 장과 같은 용도로 사용되는 것인지는 테스트 못해 봤습니다 ㅠㅠ
GET /_search
{
"query" : {
"match_all": {}
},
"docvalue_fields" : ["test1", "test2"]
}
Segment Merge (1)
1 + 1 < 2
Segment 2개를 1개로 합치면 더 적은 Resource를 사용합니다
Segment Merge (2)
https://github.com/exo-archives/exo-es-search
Segment Merge (3)
• Lucene Memory: 36.8% 감소
• Index Size: 15% 감소
POST /index-name/_forcemerge/?max_num_segments=1
Segment Merge (4)
Segment Merge (5)
Segment Merge를 안 했다면…
꽉 차는 기간을 늘릴 뿐,
이 문제에 대한 완벽한 해결
책은 아님
Segment Merge (6)
주의: 간혹 Heap이 오히려 증가하는 경우도 있습니다
Q&A
Q. 엘라스틱서치와 스파크의 연동작업 중 주의해야할 사항 또는 같이 사용
했을 때의 시너지 효과에 대해 묻고 싶습니다
A.
WRITE 관점 관점 READ 관점
• 입수가 편하다
• dataframe을 saveToEs()만
호출하면 자동 입수
• 에러 처리를 es-hadoop이 다 해줌
• 다양한 옵션들
• 입수 진행율을 Spark Job 모니터링
을 통해서 쉽게 알 수 있다
• 편하다
• 다양한 Data Source와 JOIN 가능
• Index Backup이 쉽다
• filter push down
주의 사항
Write 관점: Spark worker 개수를 늘려도 어느 임계점 이후부터는 CPU 사용량만 많아질 뿐
indexing rate는 동일
Read 관점: Shard 개수와 worker 개수를 맞추는 것이 좋음

Contenu connexe

Tendances

[211] HBase 기반 검색 데이터 저장소 (공개용)
[211] HBase 기반 검색 데이터 저장소 (공개용)[211] HBase 기반 검색 데이터 저장소 (공개용)
[211] HBase 기반 검색 데이터 저장소 (공개용)NAVER D2
 
[243]kaleido 노현걸
[243]kaleido 노현걸[243]kaleido 노현걸
[243]kaleido 노현걸NAVER D2
 
Apache kafka performance(throughput) - without data loss and guaranteeing dat...
Apache kafka performance(throughput) - without data loss and guaranteeing dat...Apache kafka performance(throughput) - without data loss and guaranteeing dat...
Apache kafka performance(throughput) - without data loss and guaranteeing dat...SANG WON PARK
 
Big data analysis with R and Apache Tajo (in Korean)
Big data analysis with R and Apache Tajo (in Korean)Big data analysis with R and Apache Tajo (in Korean)
Big data analysis with R and Apache Tajo (in Korean)Gruter
 
서비스 모니터링 구현 사례 공유 - Realtime log monitoring platform-PMon을 ...
서비스 모니터링 구현 사례 공유 - Realtime log monitoring platform-PMon을 ...서비스 모니터링 구현 사례 공유 - Realtime log monitoring platform-PMon을 ...
서비스 모니터링 구현 사례 공유 - Realtime log monitoring platform-PMon을 ...Jemin Huh
 
Cloud dw benchmark using tpd-ds( Snowflake vs Redshift vs EMR Hive )
Cloud dw benchmark using tpd-ds( Snowflake vs Redshift vs EMR Hive )Cloud dw benchmark using tpd-ds( Snowflake vs Redshift vs EMR Hive )
Cloud dw benchmark using tpd-ds( Snowflake vs Redshift vs EMR Hive )SANG WON PARK
 
Vectorized processing in_a_nutshell_DeView2014
Vectorized processing in_a_nutshell_DeView2014Vectorized processing in_a_nutshell_DeView2014
Vectorized processing in_a_nutshell_DeView2014Gruter
 
Apache kafka performance(latency)_benchmark_v0.3
Apache kafka performance(latency)_benchmark_v0.3Apache kafka performance(latency)_benchmark_v0.3
Apache kafka performance(latency)_benchmark_v0.3SANG WON PARK
 
스타트업사례로 본 로그 데이터분석 : Tajo on AWS
스타트업사례로 본 로그 데이터분석 : Tajo on AWS스타트업사례로 본 로그 데이터분석 : Tajo on AWS
스타트업사례로 본 로그 데이터분석 : Tajo on AWSGruter
 
[NDC 2018] Spark, Flintrock, Airflow 로 구현하는 탄력적이고 유연한 데이터 분산처리 자동화 인프라 구축
[NDC 2018] Spark, Flintrock, Airflow 로 구현하는 탄력적이고 유연한 데이터 분산처리 자동화 인프라 구축[NDC 2018] Spark, Flintrock, Airflow 로 구현하는 탄력적이고 유연한 데이터 분산처리 자동화 인프라 구축
[NDC 2018] Spark, Flintrock, Airflow 로 구현하는 탄력적이고 유연한 데이터 분산처리 자동화 인프라 구축Juhong Park
 
Spark Day 2017@Seoul(Spark Bootcamp)
Spark Day 2017@Seoul(Spark Bootcamp)Spark Day 2017@Seoul(Spark Bootcamp)
Spark Day 2017@Seoul(Spark Bootcamp)Sang-bae Lim
 
[215]네이버콘텐츠통계서비스소개 김기영
[215]네이버콘텐츠통계서비스소개 김기영[215]네이버콘텐츠통계서비스소개 김기영
[215]네이버콘텐츠통계서비스소개 김기영NAVER D2
 
대용량 로그분석 Bigquery로 간단히 사용하기 (20170215 T아카데미)
대용량 로그분석 Bigquery로 간단히 사용하기 (20170215 T아카데미)대용량 로그분석 Bigquery로 간단히 사용하기 (20170215 T아카데미)
대용량 로그분석 Bigquery로 간단히 사용하기 (20170215 T아카데미)Jaikwang Lee
 
[235]루빅스개발이야기 황지수
[235]루빅스개발이야기 황지수[235]루빅스개발이야기 황지수
[235]루빅스개발이야기 황지수NAVER D2
 
Understanding of Apache kafka metrics for monitoring
Understanding of Apache kafka metrics for monitoring Understanding of Apache kafka metrics for monitoring
Understanding of Apache kafka metrics for monitoring SANG WON PARK
 
[Pgday.Seoul 2019] Advanced FDW
[Pgday.Seoul 2019] Advanced FDW[Pgday.Seoul 2019] Advanced FDW
[Pgday.Seoul 2019] Advanced FDWPgDay.Seoul
 
Gruter TECHDAY 2014 MelOn BigData
Gruter TECHDAY 2014 MelOn BigDataGruter TECHDAY 2014 MelOn BigData
Gruter TECHDAY 2014 MelOn BigDataGruter
 
Hadoop security DeView 2014
Hadoop security DeView 2014Hadoop security DeView 2014
Hadoop security DeView 2014Gruter
 
Introduction to Apache Tajo
Introduction to Apache TajoIntroduction to Apache Tajo
Introduction to Apache TajoGruter
 
Expanding Your Data Warehouse with Tajo
Expanding Your Data Warehouse with TajoExpanding Your Data Warehouse with Tajo
Expanding Your Data Warehouse with TajoMatthew (정재화)
 

Tendances (20)

[211] HBase 기반 검색 데이터 저장소 (공개용)
[211] HBase 기반 검색 데이터 저장소 (공개용)[211] HBase 기반 검색 데이터 저장소 (공개용)
[211] HBase 기반 검색 데이터 저장소 (공개용)
 
[243]kaleido 노현걸
[243]kaleido 노현걸[243]kaleido 노현걸
[243]kaleido 노현걸
 
Apache kafka performance(throughput) - without data loss and guaranteeing dat...
Apache kafka performance(throughput) - without data loss and guaranteeing dat...Apache kafka performance(throughput) - without data loss and guaranteeing dat...
Apache kafka performance(throughput) - without data loss and guaranteeing dat...
 
Big data analysis with R and Apache Tajo (in Korean)
Big data analysis with R and Apache Tajo (in Korean)Big data analysis with R and Apache Tajo (in Korean)
Big data analysis with R and Apache Tajo (in Korean)
 
서비스 모니터링 구현 사례 공유 - Realtime log monitoring platform-PMon을 ...
서비스 모니터링 구현 사례 공유 - Realtime log monitoring platform-PMon을 ...서비스 모니터링 구현 사례 공유 - Realtime log monitoring platform-PMon을 ...
서비스 모니터링 구현 사례 공유 - Realtime log monitoring platform-PMon을 ...
 
Cloud dw benchmark using tpd-ds( Snowflake vs Redshift vs EMR Hive )
Cloud dw benchmark using tpd-ds( Snowflake vs Redshift vs EMR Hive )Cloud dw benchmark using tpd-ds( Snowflake vs Redshift vs EMR Hive )
Cloud dw benchmark using tpd-ds( Snowflake vs Redshift vs EMR Hive )
 
Vectorized processing in_a_nutshell_DeView2014
Vectorized processing in_a_nutshell_DeView2014Vectorized processing in_a_nutshell_DeView2014
Vectorized processing in_a_nutshell_DeView2014
 
Apache kafka performance(latency)_benchmark_v0.3
Apache kafka performance(latency)_benchmark_v0.3Apache kafka performance(latency)_benchmark_v0.3
Apache kafka performance(latency)_benchmark_v0.3
 
스타트업사례로 본 로그 데이터분석 : Tajo on AWS
스타트업사례로 본 로그 데이터분석 : Tajo on AWS스타트업사례로 본 로그 데이터분석 : Tajo on AWS
스타트업사례로 본 로그 데이터분석 : Tajo on AWS
 
[NDC 2018] Spark, Flintrock, Airflow 로 구현하는 탄력적이고 유연한 데이터 분산처리 자동화 인프라 구축
[NDC 2018] Spark, Flintrock, Airflow 로 구현하는 탄력적이고 유연한 데이터 분산처리 자동화 인프라 구축[NDC 2018] Spark, Flintrock, Airflow 로 구현하는 탄력적이고 유연한 데이터 분산처리 자동화 인프라 구축
[NDC 2018] Spark, Flintrock, Airflow 로 구현하는 탄력적이고 유연한 데이터 분산처리 자동화 인프라 구축
 
Spark Day 2017@Seoul(Spark Bootcamp)
Spark Day 2017@Seoul(Spark Bootcamp)Spark Day 2017@Seoul(Spark Bootcamp)
Spark Day 2017@Seoul(Spark Bootcamp)
 
[215]네이버콘텐츠통계서비스소개 김기영
[215]네이버콘텐츠통계서비스소개 김기영[215]네이버콘텐츠통계서비스소개 김기영
[215]네이버콘텐츠통계서비스소개 김기영
 
대용량 로그분석 Bigquery로 간단히 사용하기 (20170215 T아카데미)
대용량 로그분석 Bigquery로 간단히 사용하기 (20170215 T아카데미)대용량 로그분석 Bigquery로 간단히 사용하기 (20170215 T아카데미)
대용량 로그분석 Bigquery로 간단히 사용하기 (20170215 T아카데미)
 
[235]루빅스개발이야기 황지수
[235]루빅스개발이야기 황지수[235]루빅스개발이야기 황지수
[235]루빅스개발이야기 황지수
 
Understanding of Apache kafka metrics for monitoring
Understanding of Apache kafka metrics for monitoring Understanding of Apache kafka metrics for monitoring
Understanding of Apache kafka metrics for monitoring
 
[Pgday.Seoul 2019] Advanced FDW
[Pgday.Seoul 2019] Advanced FDW[Pgday.Seoul 2019] Advanced FDW
[Pgday.Seoul 2019] Advanced FDW
 
Gruter TECHDAY 2014 MelOn BigData
Gruter TECHDAY 2014 MelOn BigDataGruter TECHDAY 2014 MelOn BigData
Gruter TECHDAY 2014 MelOn BigData
 
Hadoop security DeView 2014
Hadoop security DeView 2014Hadoop security DeView 2014
Hadoop security DeView 2014
 
Introduction to Apache Tajo
Introduction to Apache TajoIntroduction to Apache Tajo
Introduction to Apache Tajo
 
Expanding Your Data Warehouse with Tajo
Expanding Your Data Warehouse with TajoExpanding Your Data Warehouse with Tajo
Expanding Your Data Warehouse with Tajo
 

Similaire à Web Analytics at Scale with Elasticsearch @ naver.com - Part 2 - Lessons Learned

Mongo db 시작하기
Mongo db 시작하기Mongo db 시작하기
Mongo db 시작하기OnGameServer
 
Tajo and SQL-on-Hadoop in Tech Planet 2013
Tajo and SQL-on-Hadoop in Tech Planet 2013Tajo and SQL-on-Hadoop in Tech Planet 2013
Tajo and SQL-on-Hadoop in Tech Planet 2013Gruter
 
제 5회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 5회 엑셈 수요 세미나 자료 연구컨텐츠팀제 5회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 5회 엑셈 수요 세미나 자료 연구컨텐츠팀EXEM
 
광안 1반 2팀 엠퀴즈 최종 발표 자료.pptx
광안 1반 2팀 엠퀴즈 최종 발표 자료.pptx광안 1반 2팀 엠퀴즈 최종 발표 자료.pptx
광안 1반 2팀 엠퀴즈 최종 발표 자료.pptxYeongKiKim1
 
[오픈소스컨설팅]Java Performance Tuning
[오픈소스컨설팅]Java Performance Tuning[오픈소스컨설팅]Java Performance Tuning
[오픈소스컨설팅]Java Performance TuningJi-Woong Choi
 
[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화
[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화
[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화NAVER D2
 
3.[d2 오픈세미나]분산시스템 개발 및 교훈 n base arc
3.[d2 오픈세미나]분산시스템 개발 및 교훈 n base arc3.[d2 오픈세미나]분산시스템 개발 및 교훈 n base arc
3.[d2 오픈세미나]분산시스템 개발 및 교훈 n base arcNAVER D2
 
MySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software TestMySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software TestI Goo Lee
 
Fluentd with MySQL
Fluentd with MySQLFluentd with MySQL
Fluentd with MySQLI Goo Lee
 
Final 07.컨테이너 환경에서 모니터링 이슈와 해결 방안
Final 07.컨테이너 환경에서 모니터링 이슈와 해결 방안Final 07.컨테이너 환경에서 모니터링 이슈와 해결 방안
Final 07.컨테이너 환경에서 모니터링 이슈와 해결 방안Opennaru, inc.
 
GRUTER가 들려주는 Big Data Platform 구축 전략과 적용 사례: 인터넷 쇼핑몰의 실시간 분석 플랫폼 구축 사례
GRUTER가 들려주는 Big Data Platform 구축 전략과 적용 사례: 인터넷 쇼핑몰의 실시간 분석 플랫폼 구축 사례GRUTER가 들려주는 Big Data Platform 구축 전략과 적용 사례: 인터넷 쇼핑몰의 실시간 분석 플랫폼 구축 사례
GRUTER가 들려주는 Big Data Platform 구축 전략과 적용 사례: 인터넷 쇼핑몰의 실시간 분석 플랫폼 구축 사례Gruter
 
초초초 (초고속 초저지연 초연결) 5G IoT 플랫폼 개발 이야기
초초초 (초고속 초저지연 초연결) 5G IoT 플랫폼 개발 이야기초초초 (초고속 초저지연 초연결) 5G IoT 플랫폼 개발 이야기
초초초 (초고속 초저지연 초연결) 5G IoT 플랫폼 개발 이야기ksdc2019
 
SQL-on-Hadoop with Apache Tajo, and application case of SK Telecom
SQL-on-Hadoop with Apache Tajo,  and application case of SK TelecomSQL-on-Hadoop with Apache Tajo,  and application case of SK Telecom
SQL-on-Hadoop with Apache Tajo, and application case of SK TelecomGruter
 
제 10회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 10회 엑셈 수요 세미나 자료 연구컨텐츠팀제 10회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 10회 엑셈 수요 세미나 자료 연구컨텐츠팀EXEM
 
Intro KaKao ADT (Almighty Data Transmitter)
Intro KaKao ADT (Almighty Data Transmitter)Intro KaKao ADT (Almighty Data Transmitter)
Intro KaKao ADT (Almighty Data Transmitter)I Goo Lee
 
[Ansible] Solution Guide V0.4_20181204.pdf
[Ansible] Solution Guide V0.4_20181204.pdf[Ansible] Solution Guide V0.4_20181204.pdf
[Ansible] Solution Guide V0.4_20181204.pdfHeeJung Chae
 
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재PgDay.Seoul
 
AWS Aurora 운영사례 (by 배은미)
AWS Aurora 운영사례 (by 배은미)AWS Aurora 운영사례 (by 배은미)
AWS Aurora 운영사례 (by 배은미)I Goo Lee.
 
SK ICT Tech Summit 2019_BIG DATA-11번가_DP_v1.2.pdf
SK ICT Tech Summit 2019_BIG DATA-11번가_DP_v1.2.pdfSK ICT Tech Summit 2019_BIG DATA-11번가_DP_v1.2.pdf
SK ICT Tech Summit 2019_BIG DATA-11번가_DP_v1.2.pdfDeukJin Jeon
 

Similaire à Web Analytics at Scale with Elasticsearch @ naver.com - Part 2 - Lessons Learned (20)

Mongo db 시작하기
Mongo db 시작하기Mongo db 시작하기
Mongo db 시작하기
 
Tajo and SQL-on-Hadoop in Tech Planet 2013
Tajo and SQL-on-Hadoop in Tech Planet 2013Tajo and SQL-on-Hadoop in Tech Planet 2013
Tajo and SQL-on-Hadoop in Tech Planet 2013
 
제 5회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 5회 엑셈 수요 세미나 자료 연구컨텐츠팀제 5회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 5회 엑셈 수요 세미나 자료 연구컨텐츠팀
 
광안 1반 2팀 엠퀴즈 최종 발표 자료.pptx
광안 1반 2팀 엠퀴즈 최종 발표 자료.pptx광안 1반 2팀 엠퀴즈 최종 발표 자료.pptx
광안 1반 2팀 엠퀴즈 최종 발표 자료.pptx
 
[오픈소스컨설팅]Java Performance Tuning
[오픈소스컨설팅]Java Performance Tuning[오픈소스컨설팅]Java Performance Tuning
[오픈소스컨설팅]Java Performance Tuning
 
[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화
[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화
[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화
 
3.[d2 오픈세미나]분산시스템 개발 및 교훈 n base arc
3.[d2 오픈세미나]분산시스템 개발 및 교훈 n base arc3.[d2 오픈세미나]분산시스템 개발 및 교훈 n base arc
3.[d2 오픈세미나]분산시스템 개발 및 교훈 n base arc
 
MySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software TestMySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software Test
 
Fluentd with MySQL
Fluentd with MySQLFluentd with MySQL
Fluentd with MySQL
 
Final 07.컨테이너 환경에서 모니터링 이슈와 해결 방안
Final 07.컨테이너 환경에서 모니터링 이슈와 해결 방안Final 07.컨테이너 환경에서 모니터링 이슈와 해결 방안
Final 07.컨테이너 환경에서 모니터링 이슈와 해결 방안
 
GRUTER가 들려주는 Big Data Platform 구축 전략과 적용 사례: 인터넷 쇼핑몰의 실시간 분석 플랫폼 구축 사례
GRUTER가 들려주는 Big Data Platform 구축 전략과 적용 사례: 인터넷 쇼핑몰의 실시간 분석 플랫폼 구축 사례GRUTER가 들려주는 Big Data Platform 구축 전략과 적용 사례: 인터넷 쇼핑몰의 실시간 분석 플랫폼 구축 사례
GRUTER가 들려주는 Big Data Platform 구축 전략과 적용 사례: 인터넷 쇼핑몰의 실시간 분석 플랫폼 구축 사례
 
초초초 (초고속 초저지연 초연결) 5G IoT 플랫폼 개발 이야기
초초초 (초고속 초저지연 초연결) 5G IoT 플랫폼 개발 이야기초초초 (초고속 초저지연 초연결) 5G IoT 플랫폼 개발 이야기
초초초 (초고속 초저지연 초연결) 5G IoT 플랫폼 개발 이야기
 
SQL-on-Hadoop with Apache Tajo, and application case of SK Telecom
SQL-on-Hadoop with Apache Tajo,  and application case of SK TelecomSQL-on-Hadoop with Apache Tajo,  and application case of SK Telecom
SQL-on-Hadoop with Apache Tajo, and application case of SK Telecom
 
제 10회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 10회 엑셈 수요 세미나 자료 연구컨텐츠팀제 10회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 10회 엑셈 수요 세미나 자료 연구컨텐츠팀
 
Intro KaKao ADT (Almighty Data Transmitter)
Intro KaKao ADT (Almighty Data Transmitter)Intro KaKao ADT (Almighty Data Transmitter)
Intro KaKao ADT (Almighty Data Transmitter)
 
[Ansible] Solution Guide V0.4_20181204.pdf
[Ansible] Solution Guide V0.4_20181204.pdf[Ansible] Solution Guide V0.4_20181204.pdf
[Ansible] Solution Guide V0.4_20181204.pdf
 
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
 
AWS Aurora 운영사례 (by 배은미)
AWS Aurora 운영사례 (by 배은미)AWS Aurora 운영사례 (by 배은미)
AWS Aurora 운영사례 (by 배은미)
 
SK ICT Tech Summit 2019_BIG DATA-11번가_DP_v1.2.pdf
SK ICT Tech Summit 2019_BIG DATA-11번가_DP_v1.2.pdfSK ICT Tech Summit 2019_BIG DATA-11번가_DP_v1.2.pdf
SK ICT Tech Summit 2019_BIG DATA-11번가_DP_v1.2.pdf
 
Scala for play
Scala for playScala for play
Scala for play
 

Dernier

데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법JMP Korea
 
JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례JMP Korea
 
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개JMP Korea
 
JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!JMP Korea
 
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?Jay Park
 
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement MethodologyJMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement MethodologyJMP Korea
 
공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화JMP Korea
 
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석JMP Korea
 

Dernier (8)

데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법
 
JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례
 
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
 
JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!
 
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
 
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement MethodologyJMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
 
공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화
 
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
 

Web Analytics at Scale with Elasticsearch @ naver.com - Part 2 - Lessons Learned

  • 1. Web Analytics at Scale with Elasticsearch @ naver.com Part 2 - Lessons Learned 허정수 / 네이버 jason.heo.sde@gmail.com
  • 2. Agenda • Introduction • 콘텐츠소비통계 • Part I - Architecture • Initial Architecture -> Problems & Solutions -> Proven Architecture • Data Pipelines • Part II - Lessons Learned • 성능 개선 Tip • 운영 Tip 2017.06.22. 밋업 발표 내용
  • 3. Part 1 발표 영상 https://youtu.be/Mc9gy-5d60w?t=10m40s
  • 4. 콘텐츠소비통계 회사 내부 직원용이 아닌, 네이버 사용자를 위한 서비스 네이버 블로그 (2016.06. 서비스 시작) 공통통계플랫폼 (2016.01. 개발 시작) 네이버 사용자 YYY 서비스 (2017.07. 서비스 시작) 다양한 네이버의 서비스들 OOO 서비스 (2016.09. 서비스 시작) … … XXX 서비스 (2017.10. 서비스 계획) …
  • 7. Architecture Kafka 1 (Raw Log) Kafka 2 (Refined Log)Transform Realtime ESLoader Parquet Loader Scoreboard Loader Logstash nginx access log Realtime ES Cluster Batch ES Cluster Parquet Files nBase-ARC (Redis Cluster) SparkSQL Node.jsEnd Users SparkSQL Impala 업무 요청 & 내부 지표Zeppelin
  • 8. Versions 1. Elasticsearch 2.3 & es-hadoop 2.3 2. Logstash 2.1 3. Spark 1.6 4. JDK 1.8 for ES, 1.7 for Spark 5. CDH 5.8 6. Storm 0.10 7. CentOS 7.2 8. Kafka 0.9 9. nBase-ARC 1.3
  • 9. Agenda • Introduction • 콘텐츠소비통계 • Part I - Architecture • Initial Architecture -> Problems & Solutions -> Proven Architecture • Data Pipelines • Part II - Lessons Learned • 성능 개선 Tip • 운영 Tip 8월 10일 밋업 내용
  • 10. Execution Hint (1) { "query": { "match": {...} }, "aggr": { "terms": { "field": "u", "execution_hint": "map" } }
  • 11. Execution Hint (2) SELECT u, COUNT(*) FROM tab WHERE <조건> GROUP BY u SQL 실행 순서 1. "조건에 맞는 문서" 조회 2. u field로 Aggregation 예상수행 시간 - Matching Document 개수에 비례 - "조건에 맞는 문서" 개수가 0건이면 0초에 가까워야 한다 - Aggregation할 대상이 없으므로
  • 12. Execution Hint (3) Matching Document 개수 실험 결과
  • 13. JVM Tuning (1) Stop-The-World phase Full GC 자체가 문제는 아니지만 종종 STW가 발생함 [INFO ][monitor.jvm ] [hostname] [gc][old][109757][7966] duration [15.9s], collections [2]/[16.2s], <= 16초 동안 아무 응답이 없음 total [15.9s]/[12.8m], memory [12.9gb]->[11.2gb]/[14.5gb], all_pools {[young] [1.2gb]->[146.1mb]/[1.2gb]}{[survivor] [394.7mb]->[0b]/[438.8mb]}{[old] [11.3gb]->[11gb]/[12.8gb]} <ES Log에서 발췌>
  • 15. JVM Tuning (3) JVM Option – OLD Gen.으로 옮길 경향을 줄인다 -XX:MaxTenuringThreshold=15 -XX:NewRatio=7 -XX:SurvivorRatio=3 -XX:-UseAdaptiveSizePolicy <Default GC Option> <GC Tuning> Node별 GC 옵션을 다르게 한 뒤 입수 시, Heap 사용량 그래프
  • 16. g1 gc (1) • 100B docs are indexed • 5 nodes in the cluster • 3 nodes with cms gc • 2 nodes with g1 gc -XX:+UseG1GC -XX:+PerfDisableSharedMem -XX:+ParallelRefProcEnabled -XX:G1HeapRegionSize=8m -XX:MaxGCPauseMillis=250 -XX:InitiatingHeapOccupancyPercent=75 -XX:+UseLargePages -XX:+AggressiveOpts <g1 gc option> https://wiki.apache.org/solr/ShawnHeisey#GC_Tuning <Disclaimer> elastic.co would like to recommend G1GC someday, but not for now
  • 17. g1 gc (2) "gc": { "collectors": { "young": { "collection_count": 141144, "collection_time": "1.7h", "collection_time_in_millis": 6295572 }, "old": { "collection_count": 13005, "collection_time": "20.6m", "collection_time_in_millis": 1241134 } } } "gc": { "collectors": { "young": { "collection_count": 117135, "collection_time": "1.4h", "collection_time_in_millis": 5061268 }, "old": { "collection_count": 2, "collection_time": "27s", "collection_time_in_millis": 27075 } } } <cms gc> <g1 gc> the output of node status (/_nodes/hostname/) API Which one looks better?
  • 18. g1 gc (3) [INFO ][monitor.jvm ] [hostname] [gc][old][109757][7966] duration [15.9s], collections [2]/[16.2s], total [15.9s]/[12.8m], memory [12.9gb]->[11.2gb]/[14.5gb], all_pools {[young] [1.2gb]- >[146.1mb]/[1.2gb]}{[survivor] [394.7mb]->[0b]/[438.8mb]}{[old] [11.3gb]->[11gb]/[12.8gb]} [2017-01-02 01:47:16,525][WARN ][monitor.jvm ] [hostname] [gc][old][111127][1] duration [14.4s], collections [1]/[15.2s], total [14.4s]/[14.4s], memory [13.5gb]->[11.2gb]/[15gb], all_pools {[young] [176mb]->[40mb]/[0b]}{[survivor] [96mb]->[0b]/[0b]}{[old] [13.2gb]- >[11.2gb]/[15gb]} [2017-01-02 03:28:27,815][WARN ][monitor.jvm ] [hostname] [gc][old][117128][2] duration [12.6s], collections [1]/[13.5s], total [12.6s]/[27s], memory [14.1gb]->[11gb]/[15gb], all_pools {[young] [320mb]->[112mb]/[0b]}{[survivor] [96mb]->[0b]/[0b]}{[old] [13.8gb]- >[10.9gb]/[15gb]} <cms gc> stw occurred 1 time, 16.2s <g1 gc> stw occurred 2 times, 28.7s STW with g1 gc took a longer time than cms gc
  • 19. Circuit Breaker (1) SELCT c, u, COUNT(*) FROM monthly_idx // 수십억건짜리 Index GROUP BY c, u 과도한 메모리 사용 GROUP BY with more than two high cardinality fields causes OOM Full GC만 계속 발생 모든 질의에 대한 응답 없음 ES Full Start 방법 밖에 없음
  • 20. Circuit Breaker (2) • 전체 메모리의 2.5% 이상 사용 시, 수행 중인 Query가 Fail되지만, • Cluster 전체가 먹통되는 현상 방지 가능 PUT /_cluster/settings { "persistent": { "indices.breaker.request.limit": "2.5%" } }
  • 21. Index 휴지통 기능 (1) • 사전 개념 - alias daily_2017.01.01 (alias) daily_2017.01.01_ver_1 (실제 index) 장점 Partial Data가 서비스 되는 것을 맊을 수 있음 (all or nothing) 입수 중 Client 조회 요청 Alias가 없으므로 조회되는 Data 없음
  • 22. Index 휴지통 기능 (2) • 사전 개념 - alias daily_2017.01.01 (alias) daily_2017.01.01_ver_1 (실제 index) Data가 온전히 입수 완료되었을 경우에만 alias 생성 입수 완료 Client 조회 요청 ver_1에 속한 Data가 전송
  • 23. Index 휴지통 기능 (3) • 사전 개념 - alias daily_2017.01.01 (alias) daily_2017.01.01_ver_1 (실제 index) Rollback도 가능 재입수 daily_2017.01.01_ver_2 (실제 index) Client 조회 요청 ver_2에 속한 Data가 전송 입수 완료 후 alias 교체
  • 24. Index 휴지통 기능 (4) daily_2017.01.01 (alias) daily_2017.01.01_ver_1 (실제 index) .Trash (alias) index 삭제 – Alias만 끊는다. Data 조회 안 됨 주기적으로 .Trash에 Alias 걸린 Index 삭제 Client
  • 25. Index 휴지통 기능 (5) daily_2017.01.01 (alias) daily_2017.01.01_ver_1 (실제 index) .Trash (alias) 실수로 삭제한 경우 Alias만 교체하면 됨 Client
  • 26. { "actions": [ { "remove": { "indices": ["daily_2017.01.01_ver1"], "alias": "*" } }, { "add": { "indices": ["daily_2017.01.01_ver1"], "alias": ".Trash" } } } Index 휴지통 기능 (6) DELETE /daily_2017.01.01_ver1
  • 27. 적절 Shard 개수, Size Num of shards Docs per shard shard size Query 1 (sec) Qeury 2 (sec) Query 3 (sec) 5 4천만 17GB 0.6524 0.7728 0.8876 10 2천만 8.5GB 0.5328 0.5554 0.4526 20 1천만 4.2GB 0.8972 0.5044 0.5578 Shard Size별 Query 응답 시간 조사 문서 개수 2억개 기준 • Shard Size별 응답 시간이 크지 않음 • 저희는 Shard Size를 10GB 이내로 사용 중입니다 • Index 개수가 많지 않은 경우 Shard 개수는 (Core 개수 * 2)개 정도가 좋습니다
  • 28. Reduce Disk Size • Disabling _all field: 18.6% 감소 • Disabling _source field: 20% reduced • Think before disabling the _source field
  • 29. Logstash option for exactly-once (1) Options for File input • start_position => "beginning" for log rotate • http://jason-heo.github.io/elasticsearch/2016/02/28/logstash-offset.html Options for Kafka Output • acks => "all" • retries => n
  • 30. Logstash option for exactly-once (2) access_log stat_interval (1초) discover_interval (15초) log rotate 시점 (신규 파일 생성) end인 경우 유실 발생 • stat_interval: 파일 갱신 여부 검사 주기 • discover_interval: pattern에 맞는 신규 파일 생성 여부 검사 주기 access_log 신규 파일 인지 시점
  • 31. Logstash option for exactly-once (3) Broker 1 Leader Broker 2 Follower 1 output { kafka { ... compression_type => 'gzip' acks => "all" # default:1 retries => 5 # defualt:0 } } Broker n Follower m ack ack The leader waits for all the acks sent by followers Pros: Strongest available guarantee. Cons: Slow cf) acks=>"1" means that the leader will respond without waiting the follower's ack Option for the Kafka Output
  • 32. Nested Document format (1) [ { "c": "blogger1", "u": "url1", "g": "m", "a": "1", "pv": 10" }, { "c": "blogger1", "u": "url1", "g": "f", "a": "2", "pv": 20" } ] [ { "c": "blogger1", "u": "url1", "page_views": [ { "g": "m", "a": "1", "pv": 10" }, { "g": "f", "a": "2", "pv": 20" } ] } ] <Nested Doc><Flattened Doc> • c: blogger id • u: url • g: gender • a: age
  • 33. Nested Document format (2) sqlContext.sql(" SELECT c, u, g, a, COUNT(*) AS pv FROM logs GROUP BY c, u, g, a ").saveToEs("index_name/doc_type") 일반적인 저장 모델 - Flattened Doc Model <입수 스크립트> [ { "c": "blogger1", "u": "url1", "g": "m", "a": "1", "pv": 10" }, { "c": "blogger1", "u": "url1", "g": "f", "a": "2", "pv": 20" } ] <문서 포맷> Data 중복
  • 34. Nested Document format (3) case class PageView(g: String, a: String, pv: Integer) sqlContext.udf.register("page_view", (c: String, u: String, pv: Integer) => PageView(c, u, pv)) sqlContext.sql(" SELECT c, u, COLLECT_LIST(page_view) AS page_views FROM ( SELECT c, u, page_view(g, a, pv) AS page_view FROM ( SELECT c, u, g, a, COUNT(*) AS pv FROM logs GROUP BY c, u, g, a ) t1 ) t2 GROUP BY c, u ").saveToEs("index_name/doc_type") Nested Doc Model <입수 스크립트> [ { "c": "blogger1", "u": "url1", "page_views": [ { "g": "m", "a": "1", "pv": 10" }, { "g": "f", "a": "2", "pv": 20" } ] } ] 중복 제거
  • 35. Nested Document format (4) • Pros • Data size is 49% smaller than Flattened Model • Bulk Loading time is 52% faster than Flattened Model (including extra processing time) • Cons • Extra processing is required using SparkSQL • But the bottleneck is saving the result to ES. Extra processing time is not a problem • ES gets slower when nested field has too many children • So, use it when the number of children is small
  • 36. { "properties" : [ ... "c" : { ... }, "type" : { ... }, ... ] } 복합 필드 (1) 초기 Schema 질의 패턴 • c로도 조회: 5% • type으로 조회: 3% • 두 개 필드 AND 조회: 92% 위의 질의 패턴을 모두 지원해야 함 참고: ES에는 복합키 개념이 없다
  • 37. { "properties" : [ ... "c": { ... }, "type": { ... }, "ctype": { ... } ] } 복합 필드 (2) c와 type을 조합한 1개 추가 생성 <schema> { "c": "blogger_id", "type": "channel_pv", "ctype": "blogger_id:channel_pv", "pv": 10 } <Document 예>
  • 38. 복합 필드 (3) 응답 속도 40% 개선 (Page Cache Miss 시) { "query_type": "BooleanQuery", "lucene": "+c:blogger_id +type: channel_cv" "time": "269.686223ms" } { "query_type": "ConstantScoreQuery", "lucene": "ConstantScore (ctype:c:blogger_id:channel_cv)", "time": "124.790570ms" } <ES Query Profile 결과>
  • 39. single doc의 일부 field 조회 개선 (1) { "query": { "bool": { "must": [ { "term": { "primary_key": "xx" } }] } }, "_source": { "includes": ["pv"] } } SELECT pv FROM tab WHERE primary_key = 'xx' <DSL> <SQL> _source 필드에서 Data 조회
  • 40. single doc의 일부 field 조회 개선 (2) { "query": { ... ... }, "aggregations": { "MAX(pv)": { "max": { "field": "pv" } } } } SELECT MAX(pv) FROM tab WHERE primary_key = 'xx' <DSL> <SQL> Doc Value에서 Data 조회 조회 문서가 1건이므로 pv = MAX(pv) = MIN(pv) = AVG(pv)
  • 41. single doc의 일부 field 조회 개선 (3) Query 조회 방식 처리량 (QPS) 평균 응답 시간 (ms) Q1 _source 활용 4,604 107 Doc Value 활용 7,484 66 Q2 _source 활용 5,024 98 Doc Value 활용 7,595 65
  • 42. single doc의 일부 field 조회 개선 (4) _source Doc Value
  • 43. single doc의 일부 field 조회 개선 (5) • ES 5.x에는 Doc Value Fields라는 것이 생겼음 • 앞 장과 같은 용도로 사용되는 것인지는 테스트 못해 봤습니다 ㅠㅠ GET /_search { "query" : { "match_all": {} }, "docvalue_fields" : ["test1", "test2"] }
  • 44. Segment Merge (1) 1 + 1 < 2 Segment 2개를 1개로 합치면 더 적은 Resource를 사용합니다
  • 46. Segment Merge (3) • Lucene Memory: 36.8% 감소 • Index Size: 15% 감소 POST /index-name/_forcemerge/?max_num_segments=1
  • 48. Segment Merge (5) Segment Merge를 안 했다면… 꽉 차는 기간을 늘릴 뿐, 이 문제에 대한 완벽한 해결 책은 아님
  • 49. Segment Merge (6) 주의: 간혹 Heap이 오히려 증가하는 경우도 있습니다
  • 50. Q&A
  • 51. Q. 엘라스틱서치와 스파크의 연동작업 중 주의해야할 사항 또는 같이 사용 했을 때의 시너지 효과에 대해 묻고 싶습니다 A. WRITE 관점 관점 READ 관점 • 입수가 편하다 • dataframe을 saveToEs()만 호출하면 자동 입수 • 에러 처리를 es-hadoop이 다 해줌 • 다양한 옵션들 • 입수 진행율을 Spark Job 모니터링 을 통해서 쉽게 알 수 있다 • 편하다 • 다양한 Data Source와 JOIN 가능 • Index Backup이 쉽다 • filter push down 주의 사항 Write 관점: Spark worker 개수를 늘려도 어느 임계점 이후부터는 CPU 사용량만 많아질 뿐 indexing rate는 동일 Read 관점: Shard 개수와 worker 개수를 맞추는 것이 좋음