Submit Search
Upload
DSPでgolangの屍を超えた話
•
Download as PPTX, PDF
•
1 like
•
278 views
K
katada-yuki
Follow
Ameba DSPのプロジェクトを立ち上げるにあたり、golangを採用して起こった問題・解決策とその原因究明方法を紹介します。
Read less
Read more
Engineering
Report
Share
Report
Share
1 of 33
Download now
Recommended
Lets scala
Lets scala
smdkk
AmebaDSPを掘り下げる
AmebaDSPを掘り下げる
katada-yuki
Good-Bye Swagger
Good-Bye Swagger
katada-yuki
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Recommended
Lets scala
Lets scala
smdkk
AmebaDSPを掘り下げる
AmebaDSPを掘り下げる
katada-yuki
Good-Bye Swagger
Good-Bye Swagger
katada-yuki
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
ChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference
More Related Content
Featured
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
ChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference
Featured
(20)
Skeleton Culture Code
Skeleton Culture Code
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
How to have difficult conversations
How to have difficult conversations
Introduction to Data Science
Introduction to Data Science
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
The six step guide to practical project management
The six step guide to practical project management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
ChatGPT webinar slides
ChatGPT webinar slides
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DSPでgolangの屍を超えた話
1.
DSPでgolangの屍 を超えた話 1
2.
片田 雄樹 先日リリースしたAmebaDSPの開発責任者としてエンジニア兼任で 分析とかやってます。 主な使用言語: Scala、Go言語 最近はまっていること:
Tableauで個性的なダッシュボードを作る 2
3.
Agenda » Ameba DSPで起きた問題 »
対応策と結果 » チューニング方法 » まとめ 3
4.
※ 今回の話は、golangをある程度触 ったことがある人が主な対象となり ます。 4
5.
1. Ameba DSPで起きた問題たち Problems happened
in Ameba DSP 5
6.
golangを使った理由 ちょっと触った感じ簡単だし、流行ってるか らいい感じなんじゃね!?(*´∀`*) 6
7.
最強の壁: 速度問題 DSPなので、リクエストからレスポンスまで 100ms以内に返さなきゃいけない。 なかなか思ったような速度出ない…(涙) 7
8.
イライラ: structが勝手にデフォ ルト値にしやがる問題 ログで「0」値を吐きたいのにnullにする また、structに詰めるときに勝手に「0」が入る 。 そもそも値が返ってきてるのかわからん! 8
9.
イライラ2: コード荒れる問題 他の言語で書くよりgolangで書くとやたらコー ド荒れる。 キレイになったかと思えばコード量半端ない… 9
10.
2. 解決策 Solutions the problem 10
11.
最強の壁: 速度問題 今回はこの問題にフォーカスします。 (100ms以内にレスポンスしなきゃいけない問題) 11
12.
そもそもの原因として、I/Oのレイテンシーをなめてた。 最初は、1000QPSで130msぐらいかかってました… 12
13.
解決策その1 13
14.
最強の壁: 速度問題(解決策その1) 14 goroutineを内部で使用していたライブラリ例 » net/http
(https://github.com/golang/go/tree/master/src/net/http) » ruslog (社内ライブラリ)
15.
最強の壁: 速度問題(解決策その1) 15 それぞれgoroutineの実装部分でかなりのオーバ ーヘッドが発生していました…
16.
最強の壁: 速度問題(解決策その1) 16 ライブラリ変更後 » net/http →
fasthttp (https://github.com/valyala/fasthttp) » ruslog (社内Loggerライブラリ) → zap logger (https://github.com/uber-go/zap)
17.
ライブラリ変更することで、30msぐらいは速く なった! 最強の壁: 速度問題(解決策その1) 17
18.
最強の壁: 速度問題(解決策その1) 教訓その1 ライブラリの実装を見れば割と簡単に問題に気 づくので、使用するライブラリはちゃんと内部 実装を確認しましょう。 18
19.
解決策その2 19
20.
最強の壁: 速度問題(解決策その2) ココ 20
21.
二つのサーバに並列(goroutine)でリク エストしてました。 最強の壁: 速度問題(解決策その2) 21
22.
最強の壁: 速度問題(解決策その2) こんな感じで、Wait Group
使ってアクセスし てました。(サンプルコード) 22
23.
プロファイルとってみると、goroutineを生成し すぎてたせいかレイテンシーの原因になってる ことが判明。 シーケンシャルな処理(goroutine/wgをなくした )にしたら20msくらい改善! 最強の壁: 速度問題(解決策その2) 23
24.
最強の壁: 速度問題(解決策その2) 教訓その2 goroutineを使うにもいくらかコストがかかるの で、意識して実装しましょう。 24
25.
3. チューニング方法 Performance tuning 25
26.
パフォーマンスチューニングの要はプ ロファイルを取ることだった。 Golangの「pprof」は超優秀です。 https://golang.org/pkg/net/http/pprof/ 26
27.
今回使ったのはこちら、 echo-contrib/echopprof (github.com) https://github.com/echo-contrib/echopprof 27
28.
> go tool
pprof ./main http://localhost:xxx/debug/pprof/block (pprof) このようにビルド後のバイナリ(./main)とエンドポイント(http://localhost:xxx/debug/pprof/block)を 指定することで (pprof) が立ち上がります。 28
29.
例えば、「list 関数名」コマンドで関数呼び出しにかかった時間を調べることができます。 29
30.
DEMO 30
31.
4. まとめ Conclusion 31
32.
屍を超えて学んだこと » ライブラリの内部実装はしっかり確認しましょう (golangは比較的読みやすいので) » 決してgoroutineが悪いわけではなく、軽量で簡単に実装で きるからといって使い方を誤るとボトルネックになります »
めんどくさがらず、プロファイリングしてボトルネックを見 つけていきましょう 32
33.
ご清聴ありがとうございました。 33
Download now