mod_mruby ã§ç¹å®ã®CGIã®CPU使ç¨çãå¶éãã¦ã¿ããæåãã話
RubyKaigiã§ç¥ã£ããmod_mruby/ngx_mrubyãªããªã¯ã¨ã¹ãåä½ã§ãªã½ã¼ã¹å²ãå½ã¦ã§ããã¨ãã話ã管çä¸ã®ãµã¼ãã§ç¹å®ã®CGIã¸ã®ã¢ã¯ã»ã¹ã®ã¿CPUãªã½ã¼ã¹ãå¶éããããªã£ãã®ã§è©¦ãã¦ã¿ã¾ããã
çµè«ããè¨ãã¨ãé常ã«ä¾¿å©ã§ãã
- ãµã¼ãã®åèµ·åãªãã«ã«ã¼ã«ãå¤æ´ã§ããï¼ããã©ã¼ãã³ã¹ã¸ã®å½±é¿ããã¾ãããã¾ããï¼ï¼
- Rubyã§ã«ã¼ã«ãæ¸ãã
ç°å¢
Cgroups
Cgroupsã«ã¤ãã¦ã¯ãã®ããã
cgroup ã«ã¤ãã¦ç解ãã - ãã¾ããå®è·µ! Linuxã·ã¹ãã 管ç / Vol.228
CentOS6ã®å ´åã¯
$ sudo yum install -y libcgroup
$ sudo vi /etc/cgconfig.conf
cpu = /cgroup/cpu;
$ sudo chkconfig cgconfig on
$ sudo service cgconfig start
ã§ã¤ã³ã¹ãã¼ã«ã§ãã¾ãã
mod_mruby + mruby-cgroup
äºåã«å¿ è¦ãªããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ãã¦ããã¾ãã
$ sudo yum install -y hiredis-devel libcgroup-devel
ãã¨ã¯åèè¨äºã®éãã«ã¤ã³ã¹ãã¼ã«ã
ã¾ããApacheã®ããã»ã¹ã¯apache権éã§åä½ãã¦ããã®ã§ãäºåã«cgroup以ä¸ã«apache権éã§ã¢ã¯ã»ã¹ã§ããcgroupãä½ã£ã¦ããå¿ è¦ãããã¾ããä¾ãã°/sys/fs/cgroup/cpu/apacheãä½ããchmod -R apache.aparchã§æ¨©éãå¤æ´ãã¦ããã¾ãããã
CentOSã®å ´åã¯/cgroup/
以ä¸ã«ãªãã®ã§ãããªæãã§ãã
$ sudo mkdir /cgroup/cpu/apache
$ ls /cgroup/cpu/apache/
cgroup.event_control cpu.cfs_period_us cpu.rt_period_us cpu.shares notify_on_release
cgroup.procs cpu.cfs_quota_us cpu.rt_runtime_us cpu.stat tasks
$ sudo chown -R httpd:httpd /cgroup/cpu/apache
/cgroup/cpu/apache
ã®apache
ã®é¨åã¯ãcgroup_attach.rb
ã®
c = Cgroup::CPU.new("apache/mod_mruby_group")
ã®é¨åã«ãªãã¾ããå®è¡å¾ls /cgroup/cpu/apache
ãã¦ã¿ãã¨ããããããã¨ãããã¾ãã
æ§è½ã¨ã
åèå ã®ã¹ã©ã¤ãã«è©³ããã§ãã
https://speakerdeck.com/matsumoto_r/rubykaigi-2014-mod-mruby-ngx-mruby