selectããkqueue,epoll(apache2ã®ã¹ã¹ã¡)
æè¿3人ã»ã©ã®ã¨ã³ã¸ãã¢ã¨è©±ããã®ã ãapache2ã«å¯¾ãã¦å²ã¨ãã¬ãã£ããªæè¦ãæã£ã¦ãã.
æ°ããæ¢åã¢ã¸ã¥ã¼ã«ã使ããªãããã
æ°ããã¹ã¬ãããã¼ã¹ã£ã¦ã¡ãã£ã¨ããã
æ°ããWEBã§ãã話èããªãããã
3人ãã話ãã¦ãªããã ãã©,3人ã¨ããapache2ã¯ã¹ã¬ããã§ããåããªããã¨æãããã§ãããã§ã¡ãã£ã¨ãã©ããã.apache2ã§ã
StartServers 5 MinSpareServers 5 MaxSpareServers 64 MaxClients 100 MaxRequestsPerChild 10000
ã¨ããè¨å®ããããã¨ã§ä»ã¾ã§ã©ããpreforkã¢ãã«ã§åãããã¨ã¯ã§ãã.preforkã¢ãã«ã ã¨å種ãã³ãã©ãã¹ã¬ããã»ã¼ãã«ç¡çã«ãããã¨ã¯ãªãã®ã§,ããã£ã¦ã¦ä½¿ãåã«ã¯åé¡ãªã.
ç§ãapache2ãå§ãã1çªã®çç±ã¯apache2ã§ã¯ãªã¯ã¨ã¹ãã®å¤éåå¦çãå¾æ¥ã®selectããkqueueãã¼ã¹(Linuxã§ã¯epoll)ã«ãã¦ããã¨ããã¨ããã .squid2.6のCOSSの話(その2)ã«ãæ¸ããã¨ãã,apache1.3ã®å¦çã«ãããselectã®å²åã¯æ¯è¼çé«ã,大éã«HTTPã¢ã¯ã»ã¹ãåãã¦ãããµã¼ãã«ã¨ã£ã¦ãã®ã³ã¹ãã¯é常ã«å¤§ãã.ãªã®ã§ããã«selectãé ã,ããã¦kqueueãå¹çããããç¥ã£ã¦ãããããã¨æã.
select(2)ã使ã£ããµã¼ãããã°ã©ã ã®ã½ã±ããå¦çé¨ã¯å¤§ä½ãããªæãã«ãªã£ã¦ãã.
while(1){ if (ã½ã±ããã«ãã±ãããå±ãã¦ãã){ ãªã¯ã¨ã¹ãå¦ç } }
ããã§ã®ãã½ã±ããã«ãã±ãããå±ãã¦ãããã調ã¹ãã®ãselect(2)ãªããã ã,ããã¤ã¯èª¿ã¹ããã½ã±ãããã«ã¼ãã§å ¨é¨èª¿ã¹ãã¨ããå®è£ ã«ãªã£ã¦ãããã,ãªã¼ãã³ãã¦ããã½ã±ãããå¤ãã»ã©é ããªã(ããã¡ãã£ã¨æ£ç¢ºã«ã¯å ¨é¨ãããªãã¦å¯¾è±¡ã½ã±ããã®ãã¡1024ååãäºåã«ç»é²ãã¨ãã¦ããã調ã¹ã).ããã¯HTTPã¢ã¯ã»ã¹ãé常ã«å¤ãWebãµã¼ãã§ã¯çµæ§è´å½çãªå®è£ ã§,ããã«æªããã¨ã«ã½ã±ããã®æ å ±ã¯ã«ã¼ãã«ã¡ã¢ãªã«ãããªãã®ã§ã·ã¹ãã ã³ã¼ã«ãå¼ã°ãããå¾ãªã,ããã¾ãé ã.ã¾ãä¸è¨ã®whileæã¯åºæ¬ç¡éã«ã¼ãã«ãªã£ã¦ãã¦,ãã¨ãä»ã½ã±ããã«èªã¿åºãã¹ããã¼ã¿ããªãã¨ãã¦ãselectãå¼ã³åºãçµæã«ãã,ããã«é ãã«æè»ãããã.
ããã§éçºãããã®ãkqueueã .kqueueã¯ãã¡ã¤ã«ãã³ãã«ã«å¯¾ãã¦èµ·ããå種ã¤ãã³ã(æ¶ãããã¨ãWriteãããã¨ã)ã«å¯¾ãã¦å®è¡ãããé¢æ°ãã¤ã³ã¿ãç»é²ãã¦ããæ©æ§ã .ãã®æ¹å¼ã ã¨ã«ã¼ãã«å´ããã¤ãã³ããéç¥ãã¦ããããã®ã§,selectã¨éã£ã¦æ¯åç¡é§ãªã«ã¼ããèµ°ãããå¿ è¦ã®ãªãåéã.
ããã¯ãã¶ã¤ã³ãã¿ã¼ã³ã§ããã¨ããã®ãObserverãã¿ã¼ã³ããªã®ã§,èå³ããã人ã¯ãã¡ããããããã®ãããã ããã¨æã.
ãã£ã¨ã ãselectãé ã(ããã¦kqueueãå¹çãã)ã®ã¯ç解ãã¦ããããã¨æã.ã¡ãªã¿ã«lighttpdãapache1.3ã«æ¯ã¹ã¦éã大ããªçç±ã®ã²ã¨ã¤ãããã§,ç¨éã«ããããã©apache1.3ããapache2.Xã«å¤æ´ããã ãã§3å²ä»¥ä¸ããã©ã¼ãã³ã¹ãã¢ãããããã¨ãããã®ã§,èå³ãã人ã¯ãã²ã¨ã試ãã¦ããããã.
(ããã¾ã)
追è¨2006/11/08
ããã¡ãã£ã¨æ£ç¢ºã«ã¯select(2)ãé ãã¨ããããselectã使ã£ãããã°ã©ãã³ã°ã¢ãã«ãé ãã¨ããã®ãæ£ç¢ºãªã¨ããã ãã.selectèªä½ãããããé ãã,whileã«ã¼ããã¾ãããã¨ã«ããç¡é§ãªãã§ãã¯ãããã¦ããã¨èªä½ãé ãåå ã«ãªã£ã¦ãã.
yamazçæ¥å¸¸
19Ã19ã®æãç®ã®è¦ãæ¹ã®æ¬ãèªãã .12ãã19ã¾ã§ã®æ°åã«8人ã®ç»å ´äººç©ãå²ãå½ã¦,ãã®çµã¿åããã«ã¹ãã¼ãªã¼ãã¤ãããã¨ã«ãã£ã¦19Ã19ã®æãç®ãç°¡åã«è¦ããããããã«å·¥å¤«ããã¦ã¦ãªããªãæå¿ãã.
16*16=256ã¯ããã°ã©ããªã®ã§å½ç¶ç¥ã£ã¦ã¾ããã,15*17=255ã¨ããã®ã¯ä»ã¾ã§æ°ã¥ãã¦ã¾ããã§ããã..
ãªãã¤ã³ãã§ã¯å°å¦çã®æ®µéã§20Ã22ã®æãç®ãã§ããããã«ãªã£ã¦ããããã®ã§,æ¥æ¬äººãè² ããªãããã«ããã°ã£ã¦ãããã.
19Ã19 ãã¯ãã¯âæ¥æ¬äººã®ã¢ã¿ãããã£ã¨ãããã2æ¡ããç®
- ä½è : ãããããã,COO
- åºç社/ã¡ã¼ã«ã¼: ã¯ã¤ãã©ã¹
- çºå£²æ¥: 2005/11
- ã¡ãã£ã¢: åè¡æ¬
- è³¼å ¥: 10人 ã¯ãªãã¯: 67å
- ãã®ååãå«ãããã° (9件) ãè¦ã
ãããã¦è¦ãã¦ãããã ã2^10(2ã®10ä¹)ã¯1024ã
æ®éã®äººã«ã¨ã£ã¦1024ã¯ä¸è¬çãªæ°åãããªãã®ã§,
ï½¢2^10ã¯ã ããã1000ãã®æ¹ãæ¥å¸¸çã«ã¯å½¹ã«ç«ã¤ã§ããã.
ãã¨1000Ã1000ï¼100ä¸,1K(1024)Ã1K(1024)=1Mã¨ã.