RubyKaigiã«è¡ãã¨æ¬ã«ãµã¤ã³ãæ±ãããããããã¨ã³ã¸ãã¢ãæ¸ããhaconiwaã¨ããmruby製ã®ã³ã³ããã¨ã³ã¸ã³ï¼ã³ã³ããç°å¢æ§ç¯ã®åºç¤ãã¼ã«ï¼ãããã®ã§ãããå°ã試ãã¦ã¿ããã¨æã£ã¦ãã¨ãããã1ãµã¼ãä¸ã«1ä¸ã³ã³ãããããåãããã¨ãã¦ã¿ã¾ãããä¹ ã ã«ä»åã¯èªåã®ä½ã£ãOSSã§ã¯ãªããOSSã®æ¤è¨¼ã¬ãã¼ãçãªè¨äºã«ãªãã¾ãã
haconiwaã¯åã®å¥½ããªOSSã®ä¸ã¤ã§ãããã¯ãªããã¨è¨ãã¨ã
- haconiwaã§ã³ã³ãããä½ãéã«ãhaconiwaå®è¡ç°å¢ã«ã¯ã³ã³ããã®è¦ç´ æ©è½ãå ¨ã¦å ¥ã£ã¦ããå¿ è¦ã¯ãªã
- å¿ è¦ãªã³ã³ããã®è¦ç´ æ©è½ãç°¡åã«çµã¿åããã¦ãèªåãå®ç¾ãããã³ã³ããããããã¯ãããã«æºããç°å¢ãä½ãã
- haconiwaã«ããã³ã³ããå®ç¾©ãRubyã®DSLã§è¡¨ç¾ã§ããåçãªè¨å®ãçµã¿åããã®è¨å®ãç°¡åã«ããã
ã¨ãããã¨ãã§ããããã§ãããã®ç¹æ§ãããCentOS6ã®ãããªæ¯è¼çã©ã¤ãã©ãªãå¤ãç°å¢ã§ããè¦æ±ã«å¿ãã¦ç°¡åã«åããäºãã§ãã¾ãã
ã³ã³ããã¨ã³ã¸ã³ã®ãããªã½ããã¦ã§ã¢ã§ã³ã³ããç°å¢ãä½ãæã«ãããã¾ã§ã¯ã³ã³ããã«é¢ããæ©è½ãå¤æ°è¦æ±ãããããæºãããªãç°å¢ã§ã¯ä½¿ããã¨ãã§ããªãã£ãããä½ã£ãã試ãããã«é常ã«æ°ããç°å¢ãä¸å®å®ãªç°å¢ãå¿ è¦ã¨ãããã¿ã¼ã³ãå¤ãã£ãã®ã§ãããhaconiwaã¯åä½ãããOSãæä¾ãã¦ããæ©è½ã ãã使ã£ã¦ããã®ç¶æ³ç¶æ³ã«åããã¦ä½ãããã³ã³ããï¼ä¾ãã°chrootã¨cgroupã ã使ããããã¨ãï¼ãä½ããã¨ãã§ãã¾ããããã«ãè¨å®ãRubyã®DSLã§ç°¡åã«æ¸ããããï¼ãã®è¯ãã¯å¾è¿°ï¼ãæ¡å¼µæ§ã¨çç£æ§ãé«åº¦ã«å®ç¾ãã¦ããã³ã³ããã¨ã³ã¸ã³ãªã®ã§ã¯ãªããã¨æã£ã¦ãã¾ãã
ã¨ãããã¨ã§ãã¾ãã¯æ©é試ãã¦ã¿ã¾ããã
haconiwaããã«ããã
ä»å試ãç°å¢ã¯ãKernelã¯4.8ç³»ãåãã¦ãããã©ãglibcã¯2.1.2ãåãã¦ããã¨ããè¬ç°å¢ãã¨ããããåã®æå ã®CentOS6ãã¹ãç°å¢ãªã®ã§ãããããã§haconiwaããã«ããã¦è©¦ãã¦ã¿ã¾ãããä¾ãã°ããããç¹æ®ãªç¶æ³ã«ããã¦ããhaconiwaã¯ä¸è¨ã«æããç¹æ§ãæ´»ããã¦ãå©ç¨è ãä½ãããä»æ§ã®ã³ã³ãããç°¡åã«ä½ãäºãã§ãã¾ãã
ä»å使ã£ããã¼ãã¦ã§ã¢ã¹ããã¯ã¯ãCPU24ã³ã¢ãã¡ã¢ãª32GBã§ãã
haconiwaã®ãã«ãã¯é常ã«ç°¡åã§ã
rake compile
ã¨ãã¦ããã°è¯ãã ãã§ãããã«ãã§è©°ã¾ã£ãæã¨ãã¦ã¯ã
- libcapã®ãã«ãã«kernel-headersããã
- glibc2.1.2ã¯setnsã®å¼ã³åºãé¢æ°ãå®è£ ããã¦ããããã®å ´åãã«ããã¨ã©ã¼ã«ãªã
ãããã§ãããå¾è ã«ã¤ãã¦ã¯é£ã®ã¨ã³ã¸ãã¢ã«ã½ã£ã¨åããã¨ããã£ã¨ããéã«æ¹ä¿®ãã¦é ããã®ã§é常ã«ä»äºãæãããã§ããã
ããã¦ãã«ããéãã¨ãhaconiwa/mruby/bin/haconiwa
ãã¤ããªãã§ããã®ã§ããããã©ããã«ã³ãã¼ãã¦ä½¿ã£ã¦ã¿ã¾ãããã
ã³ã³ããç°å¢ãä½ã
haconiwaã¯bootstrapçã«lxcãªã©ã使ã£ã¦ã³ã³ããç°å¢ã®ãã³ãã¬ã¼ããä½ã£ã¦ããã便å©æ©è½ãããã®ã§ãããä»åã¯ãããããã®ãå ¥ã£ã¦ããªãç°å¢ã§ããã®ã§ãæ®éã«chrootç°å¢ãä½ã£ã¦è©¦ããã¨ã«ãã¾ããã
ããã§ãApache+mod_phpãåãã¦ãphpinfo.phpãã²ã¨ã¾ãåããããªç°å¢ãudzuraããã«ããã ãã¾ããï¼ããã¯ã¾ãä»åº¦å ¬éãã¾ãï¼ããã®ãããã¯ãchrootç°å¢ã®ä½ãæ¹ãããã¾ã§ã«ã沢山è²ã ãªãµã¤ãããã¼ã«ã§ç´¹ä»ããã¦ããã¨æãã®ã§çç¥ãã¾ããæ®éã«chrootç°å¢ãã¤ããã°è¯ãã¨ããã¤ã¡ã¼ã¸ã§ãã
ãã®chrootç°å¢ã/ã§åºããtarãã¡ã¤ã«ãããã£ãä¸ã§ãhaconiwaãã¤ããªã§DSLãã³ãã¬ã¼ããä½ãã¾ãããã³ãã¬ã¼ãã¯ä»¥ä¸ã®ã³ãã³ãã§ç°¡åã«ä½æã§ãã¾ãã
$ ./haconiwa new phpinfo.haco assign new haconiwa name = haconiwa-2d057697 assign rootfs location = /var/lib/haconiwa/2d057697 create phpinfo.haco
ããã§ãDSLãã³ãã¬ã¼ããã§ãã¾ããã
ã¾ãã¯ãhaconiwaã®æå°è¨å®ãªã©ã試ãã¹ããã³ã¡ã³ããèªã¿ãªãã以ä¸ã®ããã«DSLã®å®ç¾©ããã¾ããã
unless ENV['APACHE_PORT'] raise "env APACHE_PORT not found" end Haconiwa.define do |config| # The container name and container's hostname: config.name = "haconiwa-2d057697-#{ENV['APACHE_PORT']}" # The first process when invoking haconiwa run: config.init_command = ["/usr/bin/env", "APACHE_PORT=#{ENV['APACHE_PORT']}", "APACHE_PID=/var/run/httpd/httpd.#{ENV['APACHE_PORT']}.pid", "/usr/sbin/httpd", "-X"] # If your first process is a daemon, please explicitly daemonize by: config.daemonize! # The rootfs location on your host OS # Pathname class is useful: root = Pathname.new("/var/lib/haconiwa/2d057697") config.chroot_to root # mount point configuration: config.add_mount_point "tmpfs", to: root.join("tmp"), fs: "tmpfs" # Share network etc files from host to contianer # You can reuse /etc/netns/${netnsname}/* files: config.mount_network_etc(root, host_root: "/etc") # Re-mount specific filesystems under new container namespace # These are recommended when namespaces such as pid and net are unshared: config.mount_independent "procfs" config.mount_independent "sysfs" config.mount_independent "devtmpfs" config.mount_independent "devpts" config.mount_independent "shm" end
ä»åã²ã¨ã¾ãã¯ä¸è¨ã®ãããªDSLã«ããçç±ã¨ãã¦ã
- ã¾ãã¯chrootãmountã¨ã³ãã³ãã®ãã¼ã¢ã³åã¬ãã«ã試ããã
- ãã®ä»ã®æ©è½ãå¿ è¦ã«ãªãã°é 次試ãï¼ãããhaconiwaã®è¯ãæï¼
- ã²ã¨ã¤ã®chrootç°å¢ãå ±æãã¦ã³ã³ãããè¤æ°ç«ã¡ä¸ããã
- ã·ã§ã«ããã¯ã³ã©ã¤ã³ã§è¤æ°ã³ã³ããç«ã¡ä¸ããã
- ã³ã³ããã®ãã¡ã¤ã«ã¯å ±æããã®ã§ãpidãã¡ã¤ã«ãportã¯åçã«è¨è¿°ããã
ãããã¾ããé常ã®ã³ã³ããã¨ã³ã¸ã³ã«ãããæ±ããã®ã¯ã¡ãã£ã¨å³ããã®ã§ãããhaconiwaã使ãã°ãã£ã¨ããéã«å®ç¾ã§ãã¾ããä¸è¨ã®ããã«Rubyæ¸ãããã¨ããã人ãªã大æµæ¸ããäºããããããªãç°å¢å¤æ°ã®åã渡ãã«ãã£ã¦å®ç¾ãããã¨ãã§ãã¾ãã
ãã®ä¸ã§ã /var/lib/haconiwa/2d057697
ãchrootç°å¢ã®rootã«ãªãã¾ãã®ã§ããã®ãã£ã¬ã¯ããªã®ä¸ã§ãphpinfoãåãchrootç°å¢ã®tarãå±éãã¦ããã¾ãã
cd /var/lib/haconiwa/2d057697 tar xvf phpinfo-chroot.tar.gz
ãã®ä¸ã§ãchrooté ä¸ã®Apacheã¯2.4ç³»ã§åãã¦ããã®ã§ãç°å¢å¤æ°ããè¨å®ãåãåããããã«ã以ä¸ã®ãããªhttpd.confã«ãã¦ããã¾ãã
Listen ${APACHE_PORT} PidFile ${APACHE_PID}
ããã«ãã£ã¦ãApacheã¯haconiwaããåãåã£ãç°å¢å¤æ°ãå ã«ãåçã«è¨å®ãå¤ãã¦Apacheãèµ·åããããã¨ãã§ãã¾ãã
1ä¸ã³ã³ããåããã¦ã¿ã
ã¨ãããã¨ã§ãmod_phpãçµã¿è¾¼ãã§ãé常ããã©ã«ãã§å ¥ã£ã¦ãããããªApacheã¢ã¸ã¥ã¼ã«ãã³ãã³ãã®httpdï¼RSSã5MBã10MBãããï¼ã1ä¸ååããã¦ã¿ã¾ããããä¸è¨ã®ãããªhaconiwaã®è¨å®ãè¡ã£ãã®ã§ã以ä¸ã®ããã«ã¯ã³ã©ã¤ã³ã§ã³ã³ãããèµ·åããããã¨ãã§ãã¾ãã
for port in `seq 10001 20000`; do echo APACHE_PORT=$port ./haconiwa start phpinfo.haco; sleep 0.01; done
ãããã大éã®ãã¼ã¢ã³ãããã¯ã°ã©ã¦ã³ãã§èµ·åããããä¸æ°ã«æ®ºãããããã¨ãé«è² è·ã«ãªã£ã¦ãµã¼ããè½ã¡ããã¨ãããã®ã§ãã§ããã ãã·ã¼ã±ã³ã·ã£ã«ãªåãã«ãªãããã«ä»åã¯sleepãã¯ããã§è² è·ã調æ´ãã¾ãããããã¦ãä¸è¨ã³ãã³ããå®è¡ããã¨ãhaconiwaã«ãã£ã¦ã³ã³ããã大éã«èµ·åããã¦ããã¾ãã
Container successfully up. PID={container: 13302, supervisor: 13301} Container successfully up. PID={container: 13306, supervisor: 13305} Container successfully up. PID={container: 13310, supervisor: 13309} Container successfully up. PID={container: 13314, supervisor: 13313} Container successfully up. PID={container: 13318, supervisor: 13317} Container successfully up. PID={container: 13322, supervisor: 13321} Container successfully up. PID={container: 13326, supervisor: 13325} Container successfully up. PID={container: 13330, supervisor: 13329} Container successfully up. PID={container: 13335, supervisor: 13334} Container successfully up. PID={container: 13339, supervisor: 13338} Container successfully up. PID={container: 13344, supervisor: 13343} Container successfully up. PID={container: 13348, supervisor: 13347} Container successfully up. PID={container: 13352, supervisor: 13351} Container successfully up. PID={container: 13356, supervisor: 13355} Container successfully up. PID={container: 13360, supervisor: 13359} Container successfully up. PID={container: 13364, supervisor: 13363} Container successfully up. PID={container: 13368, supervisor: 13367} Container successfully up. PID={container: 13372, supervisor: 13371} Container successfully up. PID={container: 13376, supervisor: 13375} Container successfully up. PID={container: 13380, supervisor: 13379} Container successfully up. PID={container: 13384, supervisor: 13383} Container successfully up. PID={container: 13388, supervisor: 13387} Container successfully up. PID={container: 13392, supervisor: 13391} Container successfully up. PID={container: 13396, supervisor: 13395} Container successfully up. PID={container: 13400, supervisor: 13399} Container successfully up. PID={container: 13404, supervisor: 13403} ã» ã» ã»
ããã¦ããã°ããèµ·åãç¶ãã¦ããã¨ã4000ã³ã³ãããããã§èµ·åããªããªãã¾ãããããã§ãã³ã³ããå ã®èµ·åã«å¤±æãã¦ããhttpdã®ã¨ã©ã¼ãã°ã確èªãã¾ãããããã¨ã
[Mon Nov 07 09:53:00.327685 2016] [core:emerg] [pid 4454] (28)No space left on device: AH00023: Couldn't create the rewrite-map mutex AH00016: Configuration Failed
ã¨ã
[Mon Nov 07 09:40:11.671895 2016] [auth_digest:error] [pid 32150] (28)No space left on device: AH01762: Failed to create shared memory segment on file /run/httpd/authdigest_shm.32150
ã¨ããã¨ã©ã¼ãåºåããã¦ãã¾ãããããã¯ãè¤æ°ã®ã³ã³ããã§åä¸ã®httpdã®ç°å¢ãå ±æãã¦ãããããã»ããã©èå¥åãåä¸ã®ãã®ã¨ãªãããã®ä¸éã«å¼ã£ããã£ã¦ããããã§ããå®éã«ãã¥ãããããã®è¾ºãã£ã¨èª¿æ»ãã¦ã
ipcs -s | grep apache | wc -l 32000
ãã®Apacheã®å¤ãã以ä¸ã®ããã«kernel.sem
ã®ä¸éã«ã²ã£ããã£ã¦ãã¾ããã
# sysctl kernel.sem kernel.sem = 32000 1024000000 500 32000
ã¾ããããä¸ã¤ã®åé¡ã¨ãã¦ãåã³ã³ããã§hostnameãå¤æ´ãããããã³ã³ããèµ·åæã®hostnameã®å¤æ´ãã親ã®ãã¹ãã«ã¾ã§å½±é¿ãä¸ããã³ã³ããçæä¸ã«ããããã¨è¦ªã®hostnameãå¤æ´ãç¶ãããããªæåããã¦ãã¾ããã
namespaceæ©è½ã使ã
ç¾å¨ã®DSLã®è¨å®ã¯ããã種ãã¦ã³ããchrootã工夫ãã¦ããã ããªã®ã§ããããã®è¦æ±ã«çãããã¨ãã§ãã¾ãããããããhaconiwaã¯æ§ã ãªã³ã³ããã®è¦ç´ æ©è½ãæã£ã¦ãããããããã§ã¯å®è¡ã³ã³ããã¹ãã®ä¸é¨ãåé¢ããæ©è½ã使ãããã®ã»ããã©èå¥ã®namespaceã§ããIPCã¨ãhostnameã®å¤æ´ãªã©ã«å¯¾ããnamespaceã§ããUTSããã³ã³ããåä½ã§åé¢ããããã«ãã¾ãããããã«ãã£ã¦ãã³ã³ããéããã¹ãã¨namespaceãåé¢ããããããä¸è¨ã®ã»ããã©ã®åé¡ãIPCã®åé¡ããããªãã¯ãã§ãã
ã¨ãããã¨ã§ã以ä¸ã®ããã«DSLã®æçµè¡ã«2è¡è¿½è¨ãã¾ããã
unless ENV['APACHE_PORT'] raise "env APACHE_PORT not found" end Haconiwa.define do |config| # The container name and container's hostname: config.name = "haconiwa-2d057697-#{ENV['APACHE_PORT']}" # The first process when invoking haconiwa run: config.init_command = ["/usr/bin/env", "APACHE_PORT=#{ENV['APACHE_PORT']}", "APACHE_PID=/var/run/httpd/httpd.#{ENV['APACHE_PORT']}.pid", "/usr/sbin/httpd", "-X"] # If your first process is a daemon, please explicitly daemonize by: config.daemonize! # The rootfs location on your host OS # Pathname class is useful: root = Pathname.new("/var/lib/haconiwa/2d057697") config.chroot_to root # mount point configuration: config.add_mount_point "tmpfs", to: root.join("tmp"), fs: "tmpfs" # Share network etc files from host to contianer # You can reuse /etc/netns/${netnsname}/* files: config.mount_network_etc(root, host_root: "/etc") # Re-mount specific filesystems under new container namespace # These are recommended when namespaces such as pid and net are unshared: config.mount_independent "procfs" config.mount_independent "sysfs" config.mount_independent "devtmpfs" config.mount_independent "devpts" config.mount_independent "shm" # namespeaceã®è¨å®ã2è¡è¿½è¨ config.namespace.unshare "ipc" config.namespace.unshare "uts" end
ãã£ãããã ãã§ãIPCã¨UTSã®namespaceãåé¢ããã¾ãã
ããã§ãå度ãã·ã§ã«ãã1ä¸ã³ã³ããã®èµ·åãè¡ãã¾ããã
ããã¨ã4000ãè¶ ãããããã§ãã¨ã©ã¼ãåºããã¨ãªãèµ·åãç¶ãã6615ã³ã³ãããããã¾ã§ç«ã¡ä¸ãã£ãæã§ãã¡ã¢ãªä¸è¶³ã¨ãªãããã以ä¸ã¯èµ·åãã¾ããã§ãããããã«ãã£ã¦IPCãUTSã®åé¡ã¯è§£æ±ºãããã¼ãã¦ã§ã¢ã®ãªã½ã¼ã¹ã®åé¡ã«ç§»ãå¤ãã£ããã¨ããããã¾ãã
ã¤ã¾ããã¡ã¢ãª32GBã®ãµã¼ãã§haconiwaã使ã£ã¦phpinfoãåãããããªãã«é常使ããããªApachã¢ã¸ã¥ã¼ã«ãããã©ã«ãã§å ¥ã£ã¦ããã³ã³ããã1workerï¼masterãå ¼åï¼ã§åããã¨ã6600ãããåãããã¨ãã§ãããã¨ãããã¨ã«ãªãã¾ããå®éã«è¨ç®ãã¦ã¿ã¦ãããã®æã«èµ·åãã¦ããã³ã³ããå ã®httpdã®RSSã5MBãããã§ã»ã¨ãã©CoWã¯å¹ããªãforkã®ä»æ¹ã ã¨æãã®ã§ï¼haconiwa -> httpdã¨ããããã»ã¹ããªã¼ã6600çµã¿ããã¤ã¡ã¼ã¸ï¼ã
irb(main):001:0> 5 * 6600 / 1024 => 32
ã¨ãªãã®ã§ãswapé åãå ¥ããã¨å¤§ä½ãããªããããã¨ããæãã§è¨ç®ã§ãæ¦ãç´å¾ã®å¤ã§ãã
ã¾ããhaconiwaèªä½ã®ã¡ã¢ãªãããããªã³ãã¯ä»¥ä¸ã®ããã«é常ã«å°ããã1MB以ä¸ã«ãªã£ã¦ã¾ããã
root 11969 0.0 0.0 16412 668 ? Ss 20:09 0:00 ./haconiwa start phpinfo.haco apache 11970 0.0 0.0 413556 9636 ? S 20:09 0:00 \_ /usr/sbin/httpd -X
cgroupæ©è½ã使ã
ããã§ãæ¦ã5000ã³ã³ããä½ã ã£ããããæãã§åãããããªã®ã§ãããã«åã³ã³ããã«cgroupæ©è½ãé©ç¨ãã¦ããªã½ã¼ã¹ãå¶å¾¡ãããã¨ã«ãã¾ããããã®éã«ã以ä¸ã®ããã«cgroupã®è¨å®ãæçµè¡ã«æ´ã«2è¡è¿½å ãã¾ãã
unless ENV['APACHE_PORT'] raise "env APACHE_PORT not found" end Haconiwa.define do |config| # The container name and container's hostname: config.name = "haconiwa-2d057697-#{ENV['APACHE_PORT']}" # The first process when invoking haconiwa run: config.init_command = ["/usr/bin/env", "APACHE_PORT=#{ENV['APACHE_PORT']}", "APACHE_PID=/var/run/httpd/httpd.#{ENV['APACHE_PORT']}.pid", "/usr/sbin/httpd", "-X"] # If your first process is a daemon, please explicitly daemonize by: config.daemonize! # The rootfs location on your host OS # Pathname class is useful: root = Pathname.new("/var/lib/haconiwa/2d057697") config.chroot_to root # mount point configuration: config.add_mount_point "tmpfs", to: root.join("tmp"), fs: "tmpfs" # Share network etc files from host to contianer # You can reuse /etc/netns/${netnsname}/* files: config.mount_network_etc(root, host_root: "/etc") # Re-mount specific filesystems under new container namespace # These are recommended when namespaces such as pid and net are unshared: config.mount_independent "procfs" config.mount_independent "sysfs" config.mount_independent "devtmpfs" config.mount_independent "devpts" config.mount_independent "shm" # namespeaceã®è¨å®ã2è¡è¿½è¨ config.namespace.unshare "ipc" config.namespace.unshare "uts" # cgroupã«ãã£ã¦ãã³ã³ããã®CPU使ç¨ä¸éã30%ã«å¶é config.cgroup["cpu.cfs_period_us"] = 100000 config.cgroup["cpu.cfs_quota_us"] = 30000 end
ãã®è¨å®ã«ãããåã³ã³ããã®CPU使ç¨çã30%ã«å¶éãããããã«ãªãã¯ãã§ããããã§ãå度shellããã¯ã³ã©ã¤ã³ã§5000ã³ã³ãããä¸ãã¦ã¿ã¾ãã
for port in `seq 10001 15000`; do APACHE_PORT=$port ./haconiwa start phpinfo.haco; sleep 0.01; done
ããã¨ã以ä¸ã®ããã«æ³å®ã©ãããã¡ãã¨ã³ã³ãããåãã¦ãããã¨ããããã¾ããã¾ããcgroupã«é¢ããè¨å®ãæ¼ããªãé©ç¨ããã¦ããããã§ãã
- èµ·åå¾ã®ããã»ã¹æ°
$ ps auwxf | grep http[d] | wc -l 5000
- èµ·åå¾ã®listenæ°
# netstat -lnpt | grep httpd | wc -l 5000
- èµ·åå¾ã®cgroupã®è¨å®æ°
# ls -l /sys/fs/cgroup/cpu | grep haconiwa | wc -l 5000
- èµ·åå¾ã®memoryã®ç¶æ
$ free -m total used free shared buffers cached Mem: 32091 31699 392 0 12 438 -/+ buffers/cache: 31247 844 Swap: 16383 5992 10391
- curlã§é©å½ã«ã³ã³ããã«ãªã¯ã¨ã¹ãéã£ã¦ã¿ã
$ curl -s localhost:13000/phpinfo.php | grep "Server API" <tr><td class="e">Server API </td><td class="v">Apache 2.0 Handler </td></tr>
- ãã¹ã¦ã®ã³ã³ããã«ãªã¯ã¨ã¹ã
$ for port in `seq 10001 15000`; do curl -s localhost:$port/phpinfo.php; done | grep "Server API" | wc -l 5000
ã¡ããã¨åãã¦ããããã§ãã
ãã³ããã¼ã¯ã§ãªã½ã¼ã¹å¶å¾¡ãã§ãã¦ããã確èª
æå¾ã«ãã¡ããã¨ã³ã³ããåä½ã§è¨å®ã©ãããªã½ã¼ã¹ãåé¢ããã¦ãããã確èªãã¾ãã
ab -l -k -c 10 -n 10000000 http://localhost:14010/phpinfo.php >> result.log 2>&1 & ab -l -k -c 10 -n 10000000 http://localhost:13010/phpinfo.php >> result.log 2>&1 & ab -l -k -c 10 -n 10000000 http://localhost:12010/phpinfo.php >> result.log 2>&1 & ab -l -k -c 10 -n 10000000 http://localhost:12222/phpinfo.php >> result.log 2>&1 & ab -l -k -c 10 -n 10000000 http://localhost:14410/phpinfo.php >> result.log 2>&1 & ab -l -k -c 10 -n 10000000 http://localhost:14411/phpinfo.php >> result.log 2>&1 & ab -l -k -c 10 -n 10000000 http://localhost:14412/phpinfo.php >> result.log 2>&1 & ab -l -k -c 10 -n 10000000 http://localhost:14413/phpinfo.php >> result.log 2>&1 & ab -l -k -c 10 -n 10000000 http://localhost:14414/phpinfo.php >> result.log 2>&1 & ab -l -k -c 10 -n 10000000 http://localhost:14415/phpinfo.php >> result.log 2>&1 & ab -l -k -c 10 -n 10000000 http://localhost:14416/phpinfo.php >> result.log 2>&1 & ab -l -k -c 10 -n 10000000 http://localhost:14417/phpinfo.php >> result.log 2>&1 &
ãããªæãã§é©å½ãªãã¼ãã«è² è·ãããã¦ã¿ã¾ãããããã¨ããã®æã®topã¯ä»¥ä¸ã®ããã«ãªã£ã¦ãã¾ããã
top - 20:41:37 up 3:47, 5 users, load average: 7.75, 2.24, 61.35 Tasks: 10402 total, 13 running, 10387 sleeping, 0 stopped, 2 zombie Cpu(s): 1.9%us, 1.8%sy, 0.0%ni, 90.8%id, 4.4%wa, 0.0%hi, 1.0%si, 0.0%st Mem: 32862188k total, 32529360k used, 332828k free, 8040k buffers Swap: 16777212k total, 8576304k used, 8200908k free, 416080k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 29771 apache 20 0 404m 7632 2400 R 30.4 0.0 0:12.95 httpd 19855 apache 20 0 404m 5616 2400 R 29.0 0.0 0:12.94 httpd 22084 root 20 0 20944 9688 1632 R 29.0 0.0 0:00.33 top 23951 apache 20 0 404m 7628 2400 R 29.0 0.0 0:12.94 httpd 28012 apache 20 0 404m 7628 2400 R 29.0 0.0 0:12.97 httpd 29743 apache 20 0 404m 7628 2400 R 29.0 0.0 0:12.98 httpd 29747 apache 20 0 404m 7628 2400 R 29.0 0.0 0:12.97 httpd 29751 apache 20 0 404m 7632 2400 R 29.0 0.0 0:12.97 httpd 29759 apache 20 0 404m 7628 2400 R 29.0 0.0 0:12.96 httpd 29763 apache 20 0 404m 7632 2400 R 29.0 0.0 0:12.98 httpd 29767 apache 20 0 404m 7632 2400 R 29.0 0.0 0:12.96 httpd 29775 apache 20 0 404m 7628 2400 R 29.0 0.0 0:12.60 httpd 20739 apache 20 0 404m 7012 2400 R 27.6 0.0 0:12.95 httpd 18971 root 20 0 89824 2296 1292 S 6.9 0.0 0:02.26 ab 18987 root 20 0 89824 2320 1316 S 6.9 0.0 0:02.33 ab 18970 root 20 0 89824 2320 1324 S 5.5 0.0 0:02.24 ab 18974 root 20 0 89824 2340 1340 S 5.5 0.0 0:02.31 ab 18975 root 20 0 89824 2316 1316 S 5.5 0.0 0:02.28 ab 18978 root 20 0 89824 2332 1324 S 5.5 0.0 0:02.22 ab 18979 root 20 0 89824 2276 1276 S 5.5 0.0 0:02.31 ab 18982 root 20 0 89824 2312 1304 S 5.5 0.0 0:02.33 ab 18983 root 20 0 89824 2340 1340 S 5.5 0.0 0:02.36 ab 18991 root 20 0 89824 2316 1316 S 5.5 0.0 0:02.21 ab 18986 root 20 0 89824 2320 1320 S 4.1 0.0 0:02.25 ab 18990 root 20 0 89824 2228 1232 S 4.1 0.0 0:02.29 ab 8 root 20 0 0 0 0 S 2.8 0.0 3:55.93 rcu_sched 103 root 20 0 0 0 0 S 1.4 0.0 0:19.20 rcuos/11 6886 root 20 0 4268 960 784 S 1.4 0.0 0:00.93 fsupdated
ã¡ããã¨ã³ã³ããåä½ã§ãªã½ã¼ã¹ã30%ã«æãããã¦ãã¾ãã!!!!!!
åèã¾ã§ã«ã1ã³ã¢CPU30%ã«æãè¾¼ã¾ããæ¡ä»¶ä¸ã§ã®req/secã¯ä»¥ä¸ã®ãããªçµæã§ããã
# ab -l -k -c 10 -n 10000 http://localhost:14000/phpinfo.php Server Software: Apache/2.4.6 Server Hostname: localhost Server Port: 14000 Document Path: /phpinfo.php Document Length: Variable Concurrency Level: 10 Time taken for tests: 51.239 seconds Complete requests: 10000 Failed requests: 0 Keep-Alive requests: 0 Total transferred: 450678756 bytes HTML transferred: 448848756 bytes Requests per second: 195.16 [#/sec] (mean) Time per request: 51.239 [ms] (mean) Time per request: 5.124 [ms] (mean, across all concurrent requests) Transfer rate: 8589.49 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 1 Processing: 2 51 34.6 83 87 Waiting: 2 49 34.7 17 87 Total: 3 51 34.6 83 87 Percentage of the requests served within a certain time (ms) 50% 83 66% 85 75% 85 80% 85 90% 86 95% 86 98% 86 99% 86 100% 87 (longest request)
åæ¢æããä¸æ°ã«killallãªã©ããã¨é«è² è·ã«ãªããããã·ã¼ã±ã³ã·ã£ã«ã«ãã£ããå®å ¨ã«æ®ºãã¦ããã¾ããããæ°åèµ·åãã¦killallã¨ããã¡ããã¨ã以ä¸ã®ãããªãã¼ãã¢ãã¬ã¼ã¸ã«ãªã£ã¦ãkernelã大å¤è¦ãããªãã¾ãã
$ cat /proc/loadavg 8098.64 5875.62 2985.01 8/9805 25330
ã¾ããhaconiwaã¯.hacoãã¡ã¤ã«ã使ã£ã¦ãããã«ã³ã³ãããåæ¢ããæ©è½ããµãã¼ããã¦ãã¾ãã®ã§ãstartã¨åæ§ã以ä¸ã®ããã«æ¸ããã¨ãã§ãã¾ãã
for port in `seq 10001 20000`; do APACHE_PORT=$port ./haconiwa kill phpinfo.haco; sleep 0.1; done
start
ãªãã·ã§ã³ãkill
ã«ããã ãã§ããã
ã¾ã¨ã
ã¨ãããã¨ã§ãhaconiwaãè²ã ã¨å®éã«è§¦ã£ã¦æ¤è¨¼ãã¦ã¿ã¾ããããã¨ã«ããçãæã«æãã¨ã©ãæ¡å¼µæ§ãæã¡ãããã§ãã¦DSLã«ãã£ã¦ç°¡åãã¤é«ãçç£æ§ããã£ã¦ã³ã³ãããã³ã³ããã¼ã«ãããã¨ãã§ããã½ããã¦ã§ã¢ã§ããã¨æ¹ãã¦èªèãã¾ããã
ãã£ã¹ããªãã¥ã¼ã·ã§ã³ã«ãã£ã¦ã¯ãã³ã³ãããæ§æããè¦ç´ æ©è½ãããã£ã¦ããªãã¦ãã¾ãåãããªããã¨ãããã¿ã¼ã³ãå¤ãä¸ã§ã使ç¨å¯è½ãªæ©è½ã ãã§ã¡ãã£ã¨ããã³ã³ãããããã«æºããç°å¢ãããã°ã©ããã«ã«æ¸ããããã¨ããç¨éã«haconiwaã¯ããã¿ãªã§ããã¾ããæ¡å¼µæ§ã¨çç£æ§ã両ç«ããã½ããã¦ã§ã¢ã®è¨è¨ã¨ããã®ã¯ãªããªãé£ããã®ã§ããããããã³ã³ããã®å é¨å®è£ ã¨ããé«åº¦ãªé åã«ããã¦ããé«ãã¬ãã«ã§ä¸¡ç«ã§ãã¦ãã¾ãã
ä»åã¯glibcãå¤ããªã©ã¨ããå¶ç´ãããç°å¢ä¸ã§ã®æ¤è¨¼ã§ããããä»å¾ã¯uidãgidãsetnsãcapabilityãªã©ãhaconiwaã¯ãã®ä»æ²¢å±±ã®æ©è½ãå®è£ ããã¦ããã®ã§ããããã£ãã»ãã¥ãªãã£å¨ãã®æ©è½ããã«ã«ä½¿ã£ã¦ãã³ã³ããç°å¢ãè²ã ã¨ã«ã¹ã¿ãã¤ãºã§ããã°è¯ããªã¨æã£ã¦ãã¾ããã¾ããããããã£ã¨é常ã«ç°¡åã«ã§ããã®ã ãããªã¨ããå°è±¡ãæã¡ã¾ããã®ã§ãæ¯éã³ã³ããã«èå³ããæ¹ã¯haconiwaã使ã£ã¦ã¿ã¦ãã³ã³ããç°å¢æ§ç¯ã楽ãã¿ã¤ã¤ãhaconiwaèªä½ã¸ãã£ã¼ãããã¯ãªã©ãè¡ã£ã¦ãOSSæ´»åç楽ãã¿ãåæã«å³ãã£ã¦ãããã¨è¯ãã®ã§ã¯ãªãã§ããããã
ã¨ãããã¨ã§ãä¹ ã ã«OSSã®æ¤è¨¼ã¬ãã¼ãããéããã¾ããã次ã¯ã¡ã¢ãª256GBã®ç°å¢ã§è©¦ãã¦ã¿ããã¨æãã¾ãã®ã§ã楽ãã¿ã«ã