Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Perl in Mercari YAPC::Okinawa 2018 ONNASON
Search
kazeburo
March 03, 2018
Technology
8
5.5k
Perl in Mercari YAPC::Okinawa 2018 ONNASON
Perl in Mercari
YAPC::Okinawa 2018 ONNASON スペシャルセッション
kazeburo
March 03, 2018
Tweet
Share
More Decks by kazeburo
See All by kazeburo
[さくらのTech Day] ガバメントクラウド開発と変化と成長する組織 / sakura techday, Develop govcloud and the team
kazeburo
0
1.1k
ガバメントクラウド開発と変化と成長する組織 / Organizational change and growth in developing a government cloud
kazeburo
4
2k
DNS水責め攻撃と監視 / DNS water torture attack Monitoring and SLO
kazeburo
5
4k
DBやめてみた / DNS water torture attack and countermeasures
kazeburo
13
13k
IaaSにおけるPlatform Engineeringとこれから / Platform engineering in IaaS
kazeburo
2
1.3k
高信頼IaaSを実現するDevOps / DevOps for Highly Reliable IaaS
kazeburo
1
570
権威DNSサービスへのDDoSと ハイパフォーマンスなベンチマーカ / DNS Pseudo random subdomain attack and High performance Benchmarker
kazeburo
3
5.2k
DNS権威サーバのクラウドサービス向けに行われた攻撃および対策 / DNS Pseudo-Random Subdomain Attack and mitigations
kazeburo
7
13k
sacloudns
kazeburo
2
320
Other Decks in Technology
See All in Technology
マイクロサービスにおける容易なトランザクション管理に向けて
scalar
0
130
Amazon Kendra GenAI Index 登場でどう変わる? 評価から学ぶ最適なRAG構成
naoki_0531
0
110
C++26 エラー性動作
faithandbrave
2
730
非機能品質を作り込むための実践アーキテクチャ
knih
5
1.3k
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
380
KubeCon NA 2024 Recap: How to Move from Ingress to Gateway API with Minimal Hassle
ysakotch
0
200
ブラックフライデーで購入したPixel9で、Gemini Nanoを動かしてみた
marchin1989
1
530
Qiita埋め込み用スライド
naoki_0531
0
5.1k
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
170
UI State設計とテスト方針
rmakiyama
2
580
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
140
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Making Projects Easy
brettharned
116
5.9k
The Invisible Side of Design
smashingmag
298
50k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Documentation Writing (for coders)
carmenintech
66
4.5k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
KATA
mclloyd
29
14k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Transcript
Perl in Mercari 2018 @kazeburo YAPC::Okinawa 2018 ONNASON
େͳ͓Βͤ
memcached UDPϦϑϨΫγϣϯDDoS • Πϯλʔωοτʹެ։͞Ε͍ͯΔmemcached 11211/UDPΛར༻ͯ͠UDP ϦϑϨ Ϋγϣϯ͕ߦ͑Δ • github.com ʹ1.3TbpsͷDDoS߈ܸ͕ൃੜ
(2/28) • ͘͞ΒVPS11211/UDPΛϑΟϧλϦϯά • [ॏཁ] memcachedΛάϩʔόϧʹެ։͠ͳ͍ • UDPΛແޮԽ͢Δɻmemcached -U 0Ͱىಈ memcached-1.5.6ͰσϑΥϧτແޮʹͳΓ·ͨ͠
None
Me • խ • PAUSE:KAZEBURO • גࣜձࣾϝϧΧϦ ϓϦϯγύϧΤϯδχΞ Site Reliability
Engineering (SRE) νʔϜ • BASE, Inc ٕज़ΞυόΠβʔ
None
ϝϧΧϦ • ࠃ࠷େڃͷϑϦϚΞϓϦ • 3Ͱ؆୯ʹग़ 1) ࣸਅΛࡱΔ 2) ใΛهೖ 3)
ग़ϘλϯΛԡ͢ • ҆৺҆શͳܾࡁɾऔҾ • ΤεΫϩʔ(͓ۚͷΓͱΓ͕ࣾؒʹհࡏ) • ಗ໊ૹ
KPI μϯϩʔυ GMV(૯औҾֹ) 1ԯDLҎ্(JP+US+UK) ݄ؒ100ԯԁҎ্ ग़ 1100ສҎ্
ϝϧΧϦΛࢧ͑Δ αʔόαΠυͷ ϓϩάϥϛϯάݴޠ
PHP 7
Golang https://github.com/golang-samples/gopher-vector
ϝϧΧϦΛࢧ͑Δϓϩάϥϛϯάݴޠ • ϝϧΧϦͷAPI΄΅શͯPHPʹΑΓ࣮ • ϚΠΫϩαʔϏε/ϛυϧΣΞͰ Golang ͕த৺ • AI/MLͷͰPythonΘΕΔ
1FSMϝΠϯϦʔϜͳݴޠͰͳ͍
͕͔ͩ͠͠ খ͞ͳ Perl εΫϦϓτ͕αʔϏεͷ҆ఆՔಇΛࢧ͑ ཪํͱͯ͠େنͳτϥϑΟοΫΛॲཧ͍ͯ͠Δɻ
slacklog
slacklog = cronlog + Slack notification
cronlog • cronlog kazuho͞Μ࡞ͷPerlεΫϦϓτɻҾͱͯ͠༩͑ΒΕͨίϚϯ υΛ࣮ߦ͠ɺͦͷऴྃίʔυ͕ඇθϩͷ߹ͷΈɺίϚϯυͷग़ྗ (stdout, stderr)Λඪ४ग़ྗʹૹΔ • cronͰར༻͢Δ͜ͱͰΤϥʔ࣌ͷΈMAILTOʹϝʔϧૹ৴ •
`5 * * * * cronlog -- ping -n 5 my-server 2>&1` • ʮࢹͱܧଓతͳςετʯͱ͍͏ݴ༿ΛੜΈग़ͨ͠
slacklog • ίϚϯυͷऴྃίʔυ͕ඇθϩ࣌ʹඪ४ग़ྗͷૹ৴ʹՃ͑ɺslackͷ௨Λߦ͏ • @channel ΛՃ͢Δ͔ࢦఆՄೳ • ىಈͱऴྃ࣌ʹSlackͷ௨ɺsyslogه • hostname,pid
ͷՃ • slackͷ௨ slackboard Λར༻ • ϝϧΧϦͷ΄΅શͯͷcronͰར༻͍ͯ͠Δ
slacklog use slackboard App Batch MySQL App Batch MySQL App
Batch MySQL JP US UK slacklog slacklog slacklog slacklog slacklog slacklog slacklog slacklog slacklog slackborad slackborad slackborad JP US EU HTTP Load Balancer MySQL slacklog slacklog slacklog SlackͷAPI keyͷҰݩཧ Buffering/Queueing Slack https://github.com/cubicdaiya/slackboard
࣮ߦྫ $ slacklog -c test --log-channel test -- perl -E
'$|=1;say "Hello";sleep 3;die' [2018-02-25T01:09:51][21066] *hostname* starting: perl -E $|=1;say "Hello";sleep 3;die [2018-02-25T01:09:51][21066] Hello [2018-02-25T01:09:54][21066] Died at -e line 1. [2018-02-25T01:09:54][21066] command exited with code:255 $
࣮ߦྫ(slack) ىಈऴྃϩά ίϚϯυͷ STDOUT STDERR
ಋೖޮՌ • batchͷΤϥʔͷݕग़ͱ௨ͷଈ࣌ੑΞοϓ • ϝʔϧ͍ɺ͘͠ΈΒΕͯͳ͍ • αʔόαΠυΤϯδχΞͷslack channelʹૹ৴ɻ࣭ͷ্ • ϩάΛ/dev/nullʹࣺͯͳ͍ӡ༻͕Մೳʹ
ಋೖޮՌ • ʮ͋ͷcronىಈ͍ͯ͠·͔͢ʁʯʮࡢϦϦʔεͨ͠batchɺਖ਼͘͠ಈ͍ ͯ·͔͢ʁʯͷΑ͏ͳΤϯδχΞ͔Βͷ֬ೝґཔͷݮ • τΠϧͷ໓
Ӿཡ ཤྺ SERVICE
Ӿཡཤྺ • ͓٬༷ͷӾཡͷཤྺΛαʔόʹ֨ೲ • UX্ͱͱʹɺTimeline Personalizationͷσʔλ ͱͯ͠׆༻ • ͷӾཡઍreq/sec PerlͰߏங͞Εͨ
ServiceͰॲཧ
App App App App App NGINX API(Perl) Q4M Worker (Perl)
browse_item_service NGINX API(Perl) Q4M Worker (Perl) browse_item_service MySQL MySQL memcached memcached memcached "ߋ৽" "ࢀর" cluster (2) DBߋ৽&ཤྺऔಘ (3) cache࡞ (1) enqueue (1) cacheऔಘ/missͨ͠ΒDB App App App App App memcached memcached memcached NGINX API(Perl) Q4M Worker (Perl) browse_item_service DNS-RR by consul
CPAN modules • API • Plack, Gazelle • Worker •
Parallel::Prefork • ڞ௨ • JSON::XS, DBD::mysql, Cache::Memcached::Fast::Safe Web Application Frameworkະ༻ Plack::(Request|Response)ͬͯͳ͍ XS moduleΛ׆༻্ͯ͠
Performance • API/WorkerScale Out͕Մೳ • GazelleʹΑΔAPIαʔόेʹߴ • ϘτϧωοΫ MySQL ͷϨϓϦέʔγϣϯԆ
• ௨ৗͷϨϓϦέʔγϣϯͰઍ transaction/s ͰԆൃੜ • MySQL 5.7ͷ Multi Thread Slave Λར༻ͯ͠ 18,000 t/s ͕ݶք • Sharding ΛॳظઃܭʹΈࠐΈ
Performance (newRelic) ͝ͱͷPVΛܭଌ ͢Δ Service (Golang) Avg time: 3 msec
Ӿཡཤྺ Service (Perl) Avg time: 4 msec PHP DBͳͲ
http://tech.mercari.com/entry/2018/02/26/110237
Կނ Perl?
ͳͥ Perl ? • kazeburo͕ॻ͍͔ͨΒ • System Call friendly ‣
OS ProcessɺNetwork ͷجૅΛֶͿͷʹద͍ͯ͠Δ • (Core Module ͷΈͰ࡞Ε) Deploy ͕༰қ • PerlͰഓΘΕٕͨज़ͷܧঝ ‣ mixi, livedoor (LINE), DeNA, ͯͳ ͳͲେنWebαʔϏεΛࢧ͑ͯ(͍Δ|͖ͨ)ݴޠ
͜Ε͔Β • ϚΠΫϩαʔϏεɾίϯςφத৺ͷInfrustructure • Serverlessɺk8sʹΑΔࣗಈԽ͞Εͨ Infrastructure • OSnetworkͳͲγεςϜΤϯδχΞϦϯάͷ͕ࣝ։ൃऀ͔Βԕ͘ͳΔ • Golang
த৺ɺPerl ΠϯλϓϦλ͕ͳ͍ڥ
͜Ε͔Β • SREݚमͰPerlΛ৮ͬͯΒ͏ • ৽ଔ͚ʹ1ϲ݄͔Β1ϲ݄ఔͷSREݚमΛߦ͍ͬͯΔ • ͦͷதͰͻͱͭPerlΛͬͨΈʹ৮ΕΔػձΛͭ͘Δ • slacklogͷىಈϩάΛSlackʹૹΔػೳSREݚमͰ࡞ͬͯΒͬͨͷ •
OSɾFile SystemɾProcessɾNetworkͱ͍ͬͨϨΠϠʔͷڵຯɾؔ৺ UNIX ֶʹ৮ΕΔػձ • ٕज़ͷఈ্͛ʹඞཁͳݴޠͷҰͭ
Ҏ্ careers.mercari.com/job/