id:torutk:20121103ã®ç¶ãã§ããRubyã®Webï¼Rackï¼ãµã¼ãã¼Unicornã®å¿çæ§æ¹åçã¨ãã¦ç´¹ä»ããã¦ããOobGCã¨GC.disableã試ãã¦ã¿ã¾ããã
è¨å®ãã¡ã¤ã«ã®å¤æ´
次ã®2ã¤ã®è¨å®ãã¡ã¤ã«ãä¿®æ£ãã¾ããã
/config.ru /config/unicorn.rb
config.ru
--- /var/lib/redmine-2.1.2/config.ru.1 2012-09-30 19:42:00.000000000 +0900 +++ /var/lib/redmine-2.1.2/config.ru 2012-11-04 13:34:23.530340955 +0900 @@ -1,4 +1,8 @@ # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) +require 'unicorn/oob_gc' + +use Unicorn::OobGC, 5 + run RedmineApp::Application
unicorn.rb
--- /var/lib/redmine-2.1.2/config/unicorn.rb.1 2012-10-24 04:01:10.737323459 +0900 +++ /var/lib/redmine-2.1.2/config/unicorn.rb 2012-11-04 13:35:40.382851408 +0900 @@ -36,6 +36,7 @@ Process::GID.change_privilege(target_gid) Process::UID.change_privilege(target_uid) end + GC.disable # GCåæ¢ï¼5ãªã¯ã¨ã¹ãæ¯ã«GCå®è¡ããè¨å®ï¼ rescue if RAILS_ENV = "development" STDERR.puts "could not change user, oh well"
ã¡ã¢ãªè¨æ¸¬
æåã512MBã®ã¡ã¢ãªãå²ãå½ã¦ããä»®æ³ãã·ã³ï¼KVMï¼ä¸ã®CentOS 6ã§å®é¨ãã¦ãããããã¡ã¢ãªãæ¯æ¸ãã¹ã©ãã·ã³ã°ãçºçãèããå¿çæ§ãå£åãã¦ãã¾ãã¾ããã
ããã§ã2GBã®ã¡ã¢ãªå²ãå½ã¦ã«å¢å¼·ããRedmineã¸ã®ã¢ã¯ã»ã¹åãã¢ã¯ã»ã¹å¾ï¼1åç®ã2åç®ãã»ã»ã»ï¼ã®ã¡ã¢ãªä½¿ç¨éãtopã³ãã³ãã§èª¿æ»ãã¦ã¿ã¾ããã
ãªããUnicornã¯ã¯ã¼ã«ã¼ããã»ã¹ã2ã¤èµ·åããè¨å®ã«ãã¦ãã¾ãã
èµ·åç´å¾ã®top
Mem: 1922880k total, 276152k used, 1646728k free, 14800k buffers Swap: 2064376k total, 0k used, 2064376k free, 74900k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1477 root 20 0 414m 85m 6064 S 0.0 4.6 0:07.97 ruby 1486 redmine 20 0 415m 83m 2032 S 0.0 4.4 0:00.00 ruby 1489 redmine 20 0 415m 83m 2028 S 0.0 4.4 0:00.00 ruby
unicornã¯ã¼ã«ã¼ããã»ã¹ï¼PIDã1486, 1489ï¼ã®ã¡ã¢ãªå¸¸é§éï¼RESï¼ã¯80MBå¼·ã§ãã
1åç®ã®Redmineã¢ã¯ã»ã¹ç´å¾
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1489 redmine 20 0 931m 597m 2940 S 0.0 31.8 0:04.53 ruby 1477 root 20 0 414m 85m 6064 S 0.0 4.6 0:07.97 ruby 1486 redmine 20 0 417m 84m 2312 S 0.0 4.5 0:00.01 ruby
unicornã¯ã¼ã«ã¼ããã»ã¹ã®1ã¤ï¼PID:1489ï¼ãä¸æ°ã«600MBè¿ãã¡ã¢ãªå¸¸é§éã¨ãªã£ã¦ãã¾ãã
2åç®ã®Redmineã¢ã¯ã»ã¹ç´å¾
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1486 redmine 20 0 934m 601m 3044 S 0.0 32.0 0:04.89 ruby 1489 redmine 20 0 931m 597m 2940 S 0.0 31.8 0:04.53 ruby 1477 root 20 0 414m 85m 6064 S 0.0 4.6 0:07.97 ruby
unicornã¯ã¼ã«ã¼ããã»ã¹ã®ãã1ã¤ï¼PID:1486ï¼ãä¸æ°ã«600MBã®ã¡ã¢ãªå¸¸é§éã«ãªãã¾ããã