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
13
ガバメントクラウド開発と変化と成長する組織 / Organizational change and growth in developing a government cloud
kazeburo
4
1.8k
DNS水責め攻撃と監視 / DNS water torture attack Monitoring and SLO
kazeburo
5
4k
DBやめてみた / DNS water torture attack and countermeasures
kazeburo
13
12k
IaaSにおけるPlatform Engineeringとこれから / Platform engineering in IaaS
kazeburo
2
1.3k
高信頼IaaSを実現するDevOps / DevOps for Highly Reliable IaaS
kazeburo
1
560
権威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
AGIについてChatGPTに聞いてみた
blueb
0
130
AIチャットボット開発への生成AI活用
ryomrt
0
170
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.7k
Application Development WG Intro at AppDeveloperCon
salaboy
0
190
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
150
『Firebase Dynamic Links終了に備える』 FlutterアプリでのAdjust導入とDeeplink最適化
techiro
0
120
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.5k
Terraform Stacks入門 #HashiTalks
msato
0
360
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
420
SREが投資するAIOps ~ペアーズにおけるLLM for Developerへの取り組み~
takumiogawa
1
420
EventHub Startup CTO of the year 2024 ピッチ資料
eventhub
0
120
Featured
See All Featured
The Invisible Side of Design
smashingmag
298
50k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Practical Orchestrator
shlominoach
186
10k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Thoughts on Productivity
jonyablonski
67
4.3k
Git: the NoSQL Database
bkeepers
PRO
427
64k
4 Signs Your Business is Dying
shpigford
180
21k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
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/