å¤æ°ã®TCPæ¥ç¶ããã³ããªã³ã°ãããµã¼ããæ¸ããªãã1ã³ãã¯ã·ã§ã³1ã¹ã¬ããã®ã¢ãã«ã§ã¯ãªããepollãkqueueã®ãããªã¤ãã³ãé§ååã®I/Oå¤éåãè¡ãã¹ãã ãã¨è¨ããã¾ããã ãããã®ãããªä¸»å¼µã¯ããC10Kåé¡ããæ¸ããã2002å¹´ãã7å¹´çµéããä»ã§ãæå¹ãªã®ã§ããããï¼ãechoãµã¼ããæ¸ãã¦ããã³ããã¼ã¯ãåã£ã¦ã¿ããã¨ã«ãã¾ããã ãµãã¤ã®ã°ã©ãã¯ãããããæ¥ç¶æ°ã¨ã¹ã«ã¼ãããã®é¢ä¿ã表ãã¦ãã¾ããæåã®ã°ã©ãã¯ãå ¨æ¥ç¶ãã¢ã¯ãã£ãã«éä¿¡ããå ´åããã¨ã®ã°ã©ãã¯ãå ¨æ¥ç¶ã®ãã¡å°æ°ã®ã³ãã¯ã·ã§ã³ãé 次ã¢ã¯ãã£ãã«ãªã£ã¦ãããã¨ããã¢ãã«ã§ãããããã®ã°ã©ãããã以ä¸ãããªãã¨ãèªã¿åãã¾ãã epoll ã per-thread ã¢ãã«ããè¯ãã¹ã±ã¼ã«ãã epoll ã¯ãã¯ã¼ã¯ã»ãããå°ããå ´åã« (æ大50%) per-thread ã¢ãã«ãããé«é å°ãªãã¨ãã1ã³ã
Being fast doesn't make you scalable. But it does mean you can handle more capacity with your current infrastructure. Take a look at this diagram of request handlers. You can see that it takes 13 request handling threads to process this amount of load. In the next diagram, the requests arrive at the same rate, but in this picture it takes just 200 milliseconds to answer each one. Same load, but on
æè¿Erlangãåå¼·ä¸ãªã®ã ãã©ï¼ããªãè¯ãæè§¦ï¼ ã¡ã¸ã£ã¼ãããªãè¨èªï¼C/C++ï¼Perlï¼Javaï¼PHPï¼Rubyãããï¼ï¼ã¯ï¼èå³ãæã£ã¦ãï¼å®éã«æ¥åã§å°å ¥ããï¼ã¨ããã¨ããã¾ã§ã¯è¡ããªãã®ã ãã©ï¼Erlangã¯å®éã«ä½¿ãããã¨æãã»ã©ï¼ MLã§Erlangã®è©±ã®è³æãå ¬éããã¦ãã¦ï¼ Threads is evil. Processes are ugly. State machines send you mad. ã¨ãããã¨ã§ï¼Erlangè¯ããï¼ã¨ããå å®¹ï¼ å¤æ°ã®ãªã¯ã¨ã¹ããæ±ããããªãµã¼ãã¢ããªã±ã¼ã·ã§ã³ãä½ãå ´åï¼ã¹ã¬ããã¯è¦ã¤ãã«ãããã°ãããèµ·ããä¸ã«ããã¾ã§ã¹ã±ã¼ã«ããªããï¼ãã«ãããã»ã¹ã¯é ãï¼ã¹ã±ã¼ã«ããªãï¼ C10Kåé¡ã¨è¨ããã¦ãã¦ï¼è§£æ±ºããæ¹æ³ã¨ãã¦ã¯ï¼ãã³ããããã³ã°å¼ã³åºãã¨ãéåæå¼ã³åºãã§èªåã§åã³ãã¯ã·ã§ã³ã®ç¶æ ã管çãã¦ããã°ããããªãã
訳ãã¦ã¿ã. ã¾ã YukiWiki ã«ç½®ããã¦ããã£ã¦ã¾ã. å ãã¿ã¯ "The C10K Problem". å¹´æ«å¹´å§ã«è¨³ããããããã©æéåãã§æ¾ç½®ãã¦ãã£ã. ä»æ¥ã¯ãã¾ãã¡æ°ãããã¨ãããæ°ãããã, å¤åºãã財åããªã, å¾å§æ«ã§ããããã¨åéãã¦å®äº. å¼ç¨ãããå²ã«èªã¾ãã¦ããªãã¨æããã®ã訳ããã¨æã£ãåæ©. è³æç価å¤ã¯é«ãã®ãããããªãããã©, ãããã«èªã¿ç©ã¨ãã¦ã¯ãã¾ããããªã. ç¹ã«å¾åã¯ãããã¯ã®åæã¨ç®æ¡æ¸ãã°ããã§è¨³ãã®ã¯éå±. ã¾ã, ä»æ¹ãªããã ãã©. è³æã ã... èªã¿ç©ã¨ãã¦é¢ç½ããªããã®ã¯è¨³ãã®ãè¾ãã¨å¦ã³ã¾ãã. é·ãã®ã¨éå±ãªã®ã¨ã§ããªãéã«ãªã£ã¦ãã¾ã£ã. æ©æ¢°ç¿»è¨³ã«æ¯ãçãããã®ã¨å²ãåã, æ°ã«ãªãé¨åã¯æ·»åãã¦ããããã¨å¬ãã ããããã¾ã. ããããããã.
TheC10kProblem - ãC10Kåé¡ãï¼ã¯ã©ã¤ã¢ã³ã1ä¸å°åé¡ï¼ã¨ã¯ããã¼ãã¦ã§ã¢ã®æ§è½ä¸ã¯åé¡ããªãã¦ãããã¾ãã«ãã¯ã©ã¤ã¢ã³ãã®æ°ãå¤ããªãã¨ãµã¼ãããã³ã¯ããåé¡ã®ã㨠ç®æ¬¡ ãã®ææ¸ã«ã¤ã㦠C10K åé¡ é¢é£ãµã¤ã ã¾ãèªãã¹ãæ¬ I/O ãã¬ã¼ã ã¯ã¼ã¯ I/O æ¦ç¥ 1. åã¹ã¬ãããè¤æ°ã®ã¯ã©ã¤ã¢ã³ããåãä»ãã. ããã¦ãã³ããããã³ã° I/O 㨠ã¬ãã«ã»ããªã¬åã®å®äºéç¥ãå©ç¨ãã. ä¼çµ±ç㪠select() ä¼çµ±ç㪠poll() /dev/poll kqueue() 2. åã¹ã¬ãããè¤æ°ã®ã¯ã©ã¤ã¢ã³ããåãä»ãã. ããã¦ãã³ããããã³ã° I/O 㨠å¤æ´åã®å®äºéç¥(readiness change notification)ãå©ç¨ãã. kqueue() epoll ãªã¢ã«ã¿ã¤ã ã»ã·ã°ãã« fd åä½ã®ã·ã°ãã« (Signal-per-fd)
This week I helped dealing with performance problems (part MySQL related and part related to LAMP in general) of system which does quite a bit of content delivery, serving file downloads and images â something a lot of web sites need to do these days. There were quite a bit of mistakes in design for this one which I though worth to note, adding some issues seen in other systems. Note this list app
ããã®ã¨ããæè¡ç³»ããã¬ã¼ã®éã§è©±é¡ã«ãªã£ã¦ããããC10Kåé¡ï¼åç §ï¼ãåç §ï¼ï¼ãã¯ãã²ã¨ãã¨ã§è¨ãã°ãå¤ãã®ã¦ã§ãã»ãµã¼ãã¼ã§æ¡ç¨ããã¦ããmulti-threadãmulti-processã«é ¼ã£ãï¼ãããã¯é ¼ããããï¼å¤éå¦çã¨ããã¢ã¼ããã¯ãã£ã¼ã®ã¹ã±ã¼ã©ããªãã£ã«å¯¾ãã極ãã¦ã¾ã£ã¨ããªè¦åã§ããã ãã®è©±ã¯ã決ãã¦æè¿ã«ãªã£ã¦å§ã¾ã£ã話ã§ã¯ãªãããã½ã³ã³æ¥çã§ã¯ãã½ã³ã³ã®OSã«preemptiveãªãã«ãã¿ã¹ã¯ãå°å ¥ããã¯ãããï¼ï¼å¹´ä»£ã®ååãããããã«é¡ãã¨ãDECãä¸å¿ã«ãã¯ããã¸ã¼ãé²åããããã³ã³ã®æ代ãããã½ããã¦ã§ã¢ã»ã¨ã³ã¸ãã¢ãã¡ã®éã§çãã«è¨è«ããã¦ãããã¼ãã§ããï¼ãããã«ãã¡ã¤ã³ãã¬ã¼ã æ代ã®è©±ã¯ç§ã¯ç¥ããªãï¼ã åæ°å¹´ãçµãä»ã§ãããã¾ã ã«æ±ºçãä»ãã¦ããªããã®åé¡ã¯ãç§ã®å¤§å¥½ããªãã¼ãã®ä¸ã¤ã§ãããããããç§ãå士å·ãããããåå¾ãããã¨ããã®ã§ããã°ã
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}