Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Working with UNIX Process 6/7 Chapter
Search
Yuta Totz
March 05, 2016
Programming
82
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Working with UNIX Process 6/7 Chapter
Yuta Totz
March 05, 2016
More Decks by Yuta Totz
See All by Yuta Totz
ウガンダでXcodeをアップデートする方法
totzyuta
0
150
珈琲と僕
totzyuta
0
120
読んで理解するActiveRecordの設計とActiveSupport::Concern
totzyuta
4
1.7k
TDDとVimと
totzyuta
1
560
モテる!筋肉コンパイラ自作入門 - 草食男子からの卒業
totzyuta
0
470
Git/GitHub入門-GitHubでたのしいチーム開発
totzyuta
0
320
Vimmer幼稚園
totzyuta
2
130
たのしいたーみなる
totzyuta
0
61
Other Decks in Programming
See All in Programming
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
530
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
700
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
150
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
120
Intent as Code
shoppingjaws
6
920
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
140
【DroidKaigi 2026】「アクセシビリティを利用するとき、 アクセシビリティもまたこちらを利用している」 〜マルウェアによる攻撃と防衛について〜
halunoyo
0
450
Heart of Swift Concurrency
koher
0
240
Deep dive into the select statement (GopherCon UK)
jespino
0
170
RSSとCodexを使ってX投稿自動化してみた
ochtum
0
110
iOS開発×AI駆動開発 〜最近使って便利だったスキルの話〜
nogu66
0
140
PHPプロジェクトの結合バランスを可視化する #php_night
kajitack
0
230
Featured
See All Featured
How to make the Groovebox
asonas
2
2.4k
Unsuck your backbone
ammeep
672
58k
Are puppies a ranking factor?
jonoalderson
2
3.9k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
410
A Modern Web Designer's Workflow
chriscoyier
699
190k
Facilitating Awesome Meetings
lara
57
7.1k
Code Reviewing Like a Champion
maltzj
528
40k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
720
Rails Girls Zürich Keynote
gr2m
96
14k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
320
Transcript
Working with UNIX Process 6. Resource Limit / 7. Environment
of Processes
ࠓֶͿ͜ͱ • ϓϩηεʹϦιʔεͷ੍ݶ͕͋Δ • ੍ݶͷݟ͚ͭํ • ιϑτϦϛοτͷҾ্͖͛ɺ੍ݶ • ϓϩηεʹڥ͕͋Δ •
ڥมͷࢀরͷํ
6ষ ϓϩηεͷϦιʔε੍ݶ
ϓϩηεʹϦιʔεͷ੍ݶ͕ ͋Δ • Ϧιʔε͕ด͡ΒΕͳ͍ͱϑΝΠϧσΟεΫϦϓλ ͷ൪߸͕૿Ճ͠ଓ͚Δ • 1ϓϩηε͋ͨΓͲΕ͘Β͍ͷϑΝΠϧσΟεΫϦ ϓλΛ࣋ͯΔͷ͔ʁ • =>
ΧʔωϧʹΑͬͯ1ϓϩηε͝ͱʹϦιʔεͷ੍ ݶ͕ઃఆ͞Ε͍ͯΔʂ
੍ݶΛݟ͚ͭΔ • :NOFILEγϯϘϧΛҾʹ͢Δ (Φϓγϣϯతͳ) • [ϑΝΠϧσΟεΫϦϓλͷιϑτϦϛοτ, ~ͷϋʔυϦϛοτ] • http://rurema.clear-code.com/1.9.3/method/Process/m/ getrlimit.html
p Process.getrlimit(:NOFILE) => [256, 9223372036854775807]
ιϑτϦϛοτͱϋʔυϦϛο τ • ιϑτϦϛοτιϑτଆͰنఆ্ͨ͠ݶ • มߋͰ͖Δ • ࣮ମϋʔυϦϛοτͰɺͬͪ͜ͱΜͰͳ͘େ͖ͳ •
sysctl(8) • http://www.usupi.org/sysad/240.html
ιϑτϦϛοτΛҾ্͖͛Δ • ୈ̏ҾͰ৽͍͠ϋʔυϦϛοτࢦఆͰ͖ Δ Process.setrlimit(:NOFILE, 4096) p Process.getrlimit(:NOFILE) => [4096,
4096]
ιϑτϦϛοτΛҾ্͖͛Δ • ιϑτϦϛοτΛϋʔυϦϛοτͷ·ͰҾ ্͖͛Δ ɹProcess.setrlimit(:NOFILE, Process.getrlimit(:NOFILE)[1])
੍ݶΛ͑ͨͱ͖ • ιϑτϦϛοτΛ͑ͨ߹ʹErrno::EMFILEྫ֎Λൃੜ͢Δ # ΦʔϓϯͰ͖ΔϑΝΠϧͷ࠷େΛ3ʹઃఆ # ඪ४ετϦʔϜͰϑΝΠϧσΟεΫϦϓλΛ3ͭ͏ͨΊ # ͢Ͱʹ্ݶʹୡ͍ͯ͠Δঢ়ଶʹͳΔ Process.setrlimit(:NOFILE,
3) File.open(‘/dev/null’) Errno::EMFILE: Too many open files - /dev/null
ͦͷଞͷγεςϜϦιʔεͷ੍ݶͷ֬ೝɾมߋ • Process.getrlimitʹͤΔΦϓγϣϯͷϦετυΩϡϝϯτࢀরɹ • http://ruby-doc.org/core-1.9.3/Process.html#method-c-setrlimit # ϓϩηεͷϢʔβ͕࡞Ͱ͖Δ࠷େϓϩηε Process.getrlimit(:NPROC) # ϓϩηε͕࡞Ͱ͖ΔϑΝΠϧαΠζͷ࠷େ
Process.getrlimit(:FSIZE) # ϓϩηεελοΫͷ࠷େαΠζ Process.getrlimit(:STACK)
࣮༻ྫ • γεςϜϦιʔεͷ੍ݶͷมߋ͕ඞཁʹͳΔϓϩάϥϜ͋Μ·ͳ͍…ɻ͚Ͳಛ ผͳ༻్ͷπʔϧͰͱͯॏཁʹͳΔ • ex. ϓϩηε͕ಉ࣌ʹઍͷωοτϫʔΫίωΫγϣϯΛѻ͏ඞཁ͕͋Δ • httpύϑΥʔϚϯεπʔϧͷhttperf(1) •
httperf —hog —server www —num-conn 5000 • => ಉ࣌ʹ5000ͷίωΫγϣϯΛ࡞͠Α͏ͱ͢Δ • ιϑτϦϛοτ͕σϑΥϧτͩͱ໌Β͔ʹ·͍ͣͷͰɺhttperf(1)࣮ߦલʹࣗ ͷιϑτϦϛοτΛҾ্͖͛Δ
࣮༻ྫ (2) • ੍ݶ͢Δྫ • ୈࡾऀͷίʔυͷ࣮ߦ࣌ʹ੍Λ͚ͭΔ • ϓϩηεࣗʹڐ͞Ε͍ͯΔҎ্ͷϦιʔε ͑ͳ͘ͳΔ
6ষͷγεςϜίʔϧ • getrlimit(2) • Process.getrlimit • setr-limit(2) • Process.setrlimit
7ষ ϓϩηεͷڥ
ϓϩηεʹڥ͕͋Δ • ʮڥʯʹʮڥมʯ • keyͱvalueͷΈ߹Θͤ => ϓϩηεͰ͑ΔσʔλΛ อ࣋͢Δͷ • શͯͷࢠϓϩηεϓϩηε͔ΒڥมΛҾ͖ܧ͙
• ڥมϓϩηε͝ͱʹଘࡏ͠ɺͦΕͧΕͷϓϩηε ͰάϩʔόϧʹΞΫηεͰ͖Δ
example $ MESSAGE=‘wing it’ ruby -e “puts ENV[‘MESSAGE’]” ENV[‘MESSAGE’] =
‘wing it’ system “echo $MESSAGE”
͜Εͬͯϋογϡʁ • ϋογϡΦϒδΣΫτͰͳ͍ (merge͕ͳ͍ͱ ͔) => ϋογϡϥΠΫʹΞΫηεͰ͖ΔAPI͕༻ ҙ͞Ε͍ͯΔ Process.setrlimit(:NOFILE, 4096)
p Process.getrlimit(:NOFILE) => [4096, 4096] puts ENV[‘EDITOR’] => vim puts ENV.has_key?(‘PATH’) => true puts ENV.is_a?(Hash) => false
࣮༻ྫ • ίϚϯυϥΠϯπʔϧʹೖྗΛ͢ํ๏ͱͯ͠Α͘࠾༻͞ΕΔ • ͜ͷํ͕ίϚϯυϥΠϯ͔Β༩͑ΒΕͨΦϓγϣϯΛղੳ͢ ΔΑΓϥΫͱ͍͏ϝϦοτ͋Δ Process.setrlimit(:NOFILE, 4096) p Process.getrlimit(:NOFILE)
=> [4096, 4096] ENV.is $ RAILS_ENV=production rails server $ EDITOR=mate bundle open actionpack $ QUEUE=default rake resque:work
7ষͷγεςϜίʔϧ • setenv(3), getenv(3) • ڥมΛѻ͏Cݴޠͷؔ • environ(7)
ࠓֶͿ͜ͱ • ϓϩηεʹϦιʔεͷ੍ݶ͕͋Δ • ੍ݶͷݟ͚ͭํ • ιϑτϦϛοτͷҾ্͖͛ɺ੍ݶ • ϓϩηεʹڥ͕͋Δ •
ڥมͷࢀরͷํ