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
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
370
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
120
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
440
OpenAIの蒸留機能(Model Distillation)を使用して運用中のLLMのコストを削減する取り組み
pharma_x_tech
4
540
Amazon VPC Lattice 最新アップデート紹介 - PrivateLink も似たようなアップデートあったけど違いとは
bigmuramura
0
190
re:Invent 2024 Innovation Talks(NET201)で語られた大切なこと
shotashiratori
0
300
フロントエンド設計にモブ設計を導入してみた / 20241212_cloudsign_TechFrontMeetup
bengo4com
0
1.9k
複雑性の高いオブジェクト編集に向き合う: プラガブルなReactフォーム設計
righttouch
PRO
0
110
MLOps の現場から
asei
6
630
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
320
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
190
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
170
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
510
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
How GitHub (no longer) Works
holman
311
140k
Designing for Performance
lara
604
68k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Become a Pro
speakerdeck
PRO
26
5k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
94
XXLCSS - How to scale CSS and keep your sanity
sugarenia
247
1.3M
Embracing the Ebb and Flow
colly
84
4.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
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/