{"id":242369,"date":"2014-11-05T23:02:03","date_gmt":"2014-11-05T19:02:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=242369"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=242369","title":{"rendered":"<span class=\"post_title\">\u041a\u0430\u043a \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u0434\u043b\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/files\/a82\/6ce\/c72\/a826cec721994f70bc8514323ce30eb2.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0431\u044b\u043b\u0430 <a href=\"http:\/\/habrahabr.ru\/company\/ivi\/blog\/236253\/\">\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f<\/a> \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u043d\u0430 ivi.ru. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u0440\u0443\u043f\u043d\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430. \u0417\u0430\u043a\u0430\u0437\u0447\u0438\u043a, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043b \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u0430\u0439\u0442. \u0415\u0441\u043b\u0438 \u0432\u0435\u0440\u0438\u0442\u044c Alexa Rank, \u0442\u043e \u0442\u0440\u0430\u0444\u0438\u043a \u043d\u0430 \u0441\u0430\u0439\u0442\u0435, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443, \u0440\u0430\u0437 \u0432 10 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u0430 ivi.ru.<br \/>   <a name=\"habracut\"><\/a>  <\/p>\n<h1>\u041f\u0440\u0438\u0447\u0438\u043d\u044b \u0438 \u0446\u0435\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438<\/h1>\n<p>  \u0418\u0437-\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0439 \u0441\u0430\u0439\u0442\u0430 \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u0438\u0448\u043b\u043e \u043f\u0438\u0441\u044c\u043c\u043e \u043e\u0442 Google \u0441 \u043f\u0440\u043e\u0441\u044c\u0431\u043e\u0439 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u0438\u043b\u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u043d\u0435\u043c\u0443, \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 Google Analytics.<\/p>\n<p>  \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0438 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u0445:<\/p>\n<ul>\n<li>\u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u044b \u0441\u0442\u0440\u0430\u043d\u0438\u0446 (refer,IP,UAgent, \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u044d\u043a\u0440\u0430\u043d\u0430);<\/li>\n<li>active\/passive;<\/li>\n<li>\u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044f;<\/li>\n<li>\u043f\u0435\u0440\u0435\u043c\u043e\u0442\u043a\u0438.<\/li>\n<\/ul>\n<p>  \u041e\u043a\u043e\u043b\u043e 70% \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 \u0432\u0438\u0434\u0435\u043e\u043f\u043b\u0435\u0435\u0440\u043e\u043c, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0431\u044b\u043b\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0441 \u044d\u0442\u0438\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446. \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 active\/passive \u2014 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u044b\u043b \u0430\u043a\u0442\u0438\u0432\u0435\u043d \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435, \u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434 \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u0430 \u2014 \u043e\u0442\u043a\u0440\u044b\u0442\u0430 \u043a\u0430\u043a \u0432\u043a\u043b\u0430\u0434\u043a\u0430. \u0422\u0430\u043a\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0431\u044b\u043b\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438 (\u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442 \u0432\u0438\u0434\u0435\u043e \u0438\u043b\u0438 \u043d\u0435\u0442 \u0438 \u043a\u0430\u043a \u0434\u043e\u043b\u0433\u043e \u043e\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f), \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u043e\u0442\u043e\u043a \u0438 \u0441 \u043a\u0430\u043a\u043e\u0439 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043d\u0430 \u043a\u0430\u043a\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430 \u0432\u0441\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u043b\u0441\u044f javascript \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0441\u0442\u0443\u043a\u0438\u0432\u0430\u043b \u043a\u0430\u0436\u0434\u044b\u0435 30 \u0441\u0435\u043a\u0443\u043d\u0434 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0439 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<h4>\u041a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c <\/h4>\n<p>  \u0421\u043a\u0440\u0438\u043f\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043e\u043d \u0434\u0435\u0440\u0433\u0430\u0435\u0442 \u0434\u0432\u0435 \u043e\u0434\u043d\u043e-\u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0432 \u0443\u0440\u043b\u0435 \u044d\u0442\u0438\u0445 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a. \u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a? \u041d\u0430 \u043d\u0430\u0448 \u0432\u0437\u0433\u043b\u044f\u0434, \u0441\u0430\u043c\u043e\u0435 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0432 \u043b\u044e\u0431\u044b\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445 \u0438 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445. \u0415\u0441\u043b\u0438 \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 AJAX, \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u0440\u0435\u0448\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0441 \u043a\u0440\u043e\u0441\u0441\u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445. \u0415\u0441\u0442\u044c \u0434\u0432\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 stat.gif \u0438 p.gif, \u043f\u0435\u0440\u0432\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435, \u0432\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u0440\u0433\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0435 15 \u0441\u0435\u043a\u0443\u043d\u0434 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (active\/passive, \u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u043f\u0435\u0440\u0435\u043c\u043e\u0442\u043a\u0438).<\/p>\n<p>  \u042d\u0442\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u0435\u0440\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<pre><code class=\"html\">\/stat.gif?pid=p0oGejy139055323022216801050bny0&l=http%3A%2F%2Fsite.ru%2F8637994&r=http%3A%2F%2Fsite.ru%2F&w=1680&h=1050&a=Mozilla%2F5.0%20(Windows%20NT%206.1%3B%20rv%3A26.0)%20Gecko%2F20100101%20Firefox%2F26.0&k=1390553230222&i=30000&vr=3.0 <\/code><\/pre>\n<p>  \u042d\u0442\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u0435\u0440\u0433\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0435 30 \u0441\u0435\u043a\u0443\u043d\u0434:<\/p>\n<pre><code class=\"html\">\/p.gif?pid=p0oGejy139055323022216801050bny0&rand=6752416&b=1&time=2-188x190-57x50-349x251-83x0-235x&pl=29&fpl=46&ld=552&efsc=true&tfsc=19&tac=89&tpas=70&vr=3.0 <\/code><\/pre>\n<p>  \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u044b \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u0444\u0438\u043a\u0430. PID \u2014 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0448\u043b\u0438 \u0438\u0437 stat.gif \u0438 p.gif.<\/p>\n<h1>\u0421\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/h1>\n<p>  \u0421 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438\u0441\u044c, \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c MongoDB (\u0431\u044b\u0441\u0442\u0440\u0430\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0430, \u0434\u0430\u043d\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0445, \u043d\u0435\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430). \u041f\u0435\u0440\u0432\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0430 php, \u043f\u0435\u0440\u0432\u044b\u0435 \u0436\u0435 \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u0434 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b: <\/p>\n<ul>\n<li>\u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 php-fpm \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 nginx \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u043b \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430;<\/li>\n<li>\u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 stat.gif \u0432 MongoDB \u0434\u0435\u043b\u0430\u043b\u0430\u0441\u044c \u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u0434\u0430\u043b\u0435\u0435 \u043a\u0430\u0436\u0434\u044b\u0435 15 \u0441\u0435\u043a\u0443\u043d\u0434 \u0432 \u043d\u0435\u0433\u043e \u0430\u043f\u0434\u0435\u0439\u0442\u0438\u043b\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0441 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439 p.gif.<\/li>\n<\/ul>\n<p>  \u0421\u0442\u0430\u043b\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 stat.gif \u0438 p.gif \u043d\u0443\u0436\u043d\u043e \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043c\u043e\u043d\u0433\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 p.gif. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a MongoDB \u0438 \u0441\u0430\u043c\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 insert (\u0431\u0435\u0437 Update). \u041d\u0430 PHP \u043d\u0435 \u043c\u043e\u0433\u0443 \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0442\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441 \u043e \u0432\u044b\u0431\u043e\u0440\u0435 \u043d\u043e\u0432\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b. \u041d\u0443\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 web-\u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0448 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 NodeJS. \u041f\u0440\u0438\u0447\u0438\u043d\u044b: \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u044c, \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c, \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 (\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u043f\u044b\u0442 JavaScript), \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430. \u0411\u043e\u043b\u044c\u0448\u043e\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 NodeJS \u0434\u0430\u043b\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f <a href=\"http:\/\/habrahabr.ru\/post\/123154\/\">\u00ab\u041c\u0438\u043b\u043b\u0438\u043e\u043d \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u043d\u0430 Node.js\u00bb<\/a> \u0437\u0430 \u0430\u0432\u0442\u043e\u0440\u0441\u0442\u0432\u043e\u043c <a href=\"http:\/\/habrahabr.ru\/users\/ashtuchkin\/\" class=\"user_link\">ashtuchkin<\/a> \u2014 \u043c\u044b \u0443 \u0441\u0435\u0431\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043b\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442.<\/p>\n<p>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0442\u0440\u0430\u0444\u0438\u043a\u0435 \u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432: \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u043e\u0442\u0441\u0442\u0443\u043a\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0435 15 \u0441\u0435\u043a\u0443\u043d\u0434 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. \u0423 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0438 \u0432\u0441\u0435 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0438\u043b\u0438 \u043d\u0435\u0442. \u0418 \u044d\u0442\u043e \u0432\u0441\u0435 \u043f\u0440\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e ~ 40 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430\u0445 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432 \u0432 \u0441\u0443\u0442\u043a\u0438!<\/p>\n<h4>\u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 NodeJS<\/h4>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0421\u043a\u0440\u0438\u043f\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u0432 \u043d\u0435\u043c request \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 stat.gif \u0438 p.gif \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438 \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432.<\/p>\n<pre><code class=\"php\">Array (     [PID] =&gt; Array         (             [stat] =&gt; \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439 stat.gif   \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b             [pgif] =&gt; \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439 p.gif (\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0435 15 \u0441\u0435\u043a\u0443\u043d\u0434)             [time] =&gt; \u042e\u041d\u0418\u041a\u0421 \u043c\u0435\u0442\u043a\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0434\u0430\u0442\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 PID         ) ) <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043f\u043e \u0442\u0430\u0439\u043c\u0435\u0440\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0435\u0441\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 PID \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 PID (Array[PID][time]). \u0415\u0441\u043b\u0438 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0448\u043b\u043e \u0431\u043e\u043b\u0435\u0435 90 \u0441\u0435\u043a\u0443\u043d\u0434 (\u0440\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u043e\u0442 \u044e\u0437\u0435\u0440\u0430 \u043a\u0430\u0436\u0434\u044b\u0435 15 \u0441\u0435\u043a\u0443\u043d\u0434, \u0437\u043d\u0430\u0447\u0438\u0442, \u043e\u043d \u0437\u0430\u043a\u0440\u044b\u043b \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0438\u043b\u0438 \u043f\u0440\u043e\u043f\u0430\u043b \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442), \u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 MongoDB \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437 \u0441\u0430\u043c\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u041f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e, \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e (\u0447\u0442\u043e\u0431\u044b \u043f\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430).<\/p>\n<p>  \u0412 NodeJS \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044e <a href=\"http:\/\/nodejs.org\/api\/cluster.html#cluster_cluster\">Cluster<\/a>. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 (\u043e\u0431 \u044d\u0442\u043e\u043c \u0438 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e), \u0441\u043a\u0430\u0436\u0443 \u0442\u043e\u043b\u044c\u043a\u043e, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u0445 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445 \u0438 \u0434\u0430\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0441 \u0433\u043e\u043b\u043e\u0432\u043d\u044b\u043c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u041b\u043e\u0433\u0438\u043a\u0430 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043c\u0435\u0436\u0434\u0443 \u0433\u043e\u043b\u043e\u0432\u043d\u044b\u043c \u0438 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438:<br \/>  \u0414\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b\u0438 http \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442\u0434\u0430\u0432\u0430\u043b\u0438 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043e\u0434\u043d\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443, \u0430 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0441 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439 \u0432 get-\u0437\u0430\u043f\u0440\u043e\u0441\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0438 \u0432 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 worker- \u0430 (\u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430):<\/p>\n<pre><code class=\"javascript\">\/\/\u0427\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u0431\u043e\u0440  \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 server.on('request', function(req, res) {   -  \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430  GET \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \tvar url_parts = url.parse(req.url, true); \tvar query = url_parts.query; \tvar url_string = url_parts.pathname.slice(1); \tvar cookies = {}; \tswitch(url_string){    \/\/  \u0412\u0441\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e  \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0443\u0440\u043b\u0430  \/p.gif   \u0438  \/stat.gif     \t\tcase 'p.gif': \t\t\tprocess.send({ routeType: 'p.gif', params: url_parts.query});   \/\/  \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c  \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \t\t\tif(image == undefined){  \/\/ \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430   \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043d\u0435 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u0438 \u0435\u0435 \u043d\u0435\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0442\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u043e\u0442\u0434\u0430\u0435\u043c   -- \u043e\u0434\u043d\u043e\u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \t\t\t\tfs.stat('p.gif', function(err, stat) { \t\t\t\t\tif (!err){ \t\t\t\t\t\timage = fs.readFileSync('p.gif'); \t\t\t\t\t\tres.end(image); \t\t\t\t\t} \t\t\t\t\telse \t\t\t\t\t\tres.end(); \t\t\t\t}); \t\t\t}else \t\t\t\tres.end(image); \t\t\tbreak; \t\tcase 'stat.gif': \t\t\turl_parts.query.ip = req.connection.remoteAddress; \t\t\tprocess.send({ routeType: 'stat.gif', params: url_parts.query});  \/\/  \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c  \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \t\t\tif(image == undefined){ \/\/ \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430   \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043d\u0435 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u0438 \u0435\u0435 \u043d\u0435\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0442\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u043e\u0442\u0434\u0430\u0435\u043c   -- \u043e\u0434\u043d\u043e\u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \t\t\t\tfs.stat('p.gif', function(err, stat) { \t\t\t\t\tif (!err){ \t\t\t\t\t\timage = fs.readFileSync('p.gif'); \t\t\t\t\t\tres.end(image); \t\t\t\t\t} \t\t\t\t\telse \t\t\t\t\t\tres.end(); \t\t\t\t}); \t\t\t}else \t\t\t\tres.end(image); \t\t\tbreak; \t\tdefault:  \/\/ \t\t\tres.end('No file'); \t\t\tbreak; \t} }); <\/code><\/pre>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0435 \u0432 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"http:\/\/nodejs.org\/api\/child_process.html#child_process_example_sending_server_object\">process.send({})<\/a>.<\/p>\n<p>  \u0412 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <br \/>  <a href=\"http:\/\/nodejs.org\/api\/cluster.html#cluster_event_message\">worker.on(&#8216;message&#8217;, function(data) {})<\/a> \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430:<\/p>\n<pre><code class=\"javascript\">\u0427\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430,  \u0432\u0435\u0448\u0430\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430         worker.on('message', function(data) { \t\t\tswitch(data.routeType){                 case 'p.gif':                     counter++;                     if(data.params.pid != undefined && dataObject[data.params.pid] != undefined){ \/\/\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d PID, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0442\u043e \u044e\u0437\u0435\u0440 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435                         dataObject[data.params.pid]['pgif'] = data.params; \/\/\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439, \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441                         dataObject[data.params.pid]['time'] = Math.ceil(new Date().getTime()\/1000); \/\/\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0434\u0430\u0442\u0443 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0438                     }                     break;                 case 'stat.gif':                     counter++;                     if(data.params.pid != undefined){                         if(dataObject[data.params.pid] == undefined) \/\/\u0415\u0441\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0435\u0433\u043e                             dataObject[data.params.pid] = [];                         dataObject[data.params.pid]['stat'] = data.params; \/\/\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441                         dataObject[data.params.pid]['time'] = Math.ceil(new Date().getTime()\/1000); \/\/\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u0442\u0443 \u043a\u043e\u0433\u0434\u0430 \u0431\u044b\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u043d\u0430 \u043f\u0435\u0440\u0432\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c, \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u044e\u0437\u0435\u0440 \u0437\u0430\u043a\u0440\u044b\u043b \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0431\u044b\u043b \u0432\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441                     }                     break; \t\t\t\tdefault: \t\t\t\t\tbreak; \t\t\t}         }); <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0432 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u0439\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u0431\u0430\u0437\u0443 MongoDB \u0442\u0435, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435 \u0431\u044b\u043b\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c 90 \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<h3>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>  \u0421 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043d\u044e\u0430\u043d\u0441\u044b, \u0432 \u0445\u043e\u0434\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u0432\u044b\u0432\u043e\u0434\u0443, \u0447\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 (\u0430\u043d\u0430\u043b\u043e\u0433 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 MySQL) \u2014 \u043f\u043b\u043e\u0445\u0430\u044f \u0438\u0434\u0435\u044f. \u0420\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u2014 \u0431\u043b\u0430\u0433\u043e \u0432 MongoDB \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043b\u0435\u0433\u043a\u043e: \u0435\u0441\u043b\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0432\u044b \u043f\u044b\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u0432 \u043d\u0435\u0435 \u0447\u0442\u043e-\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c, \u043e\u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432 \u0445\u043e\u0434\u0435 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0438\u0448\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0441 \u0434\u0430\u0442\u043e\u0439 \u0432 \u0438\u043c\u0435\u043d\u0438: stat20141102, stat20141103, stat20141104. <\/p>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/b99\/1a1\/d3b\/b991a1d3be9f41e3bb3d36f166c28f04.jpg\"\/><\/p>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 (\u043e\u0434\u0438\u043d \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0443):<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/861\/1a5\/349\/8611a534979c409bacfd1bc56fa87c10.jpg\"\/><\/p>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0435 \u0437\u0430 \u043e\u0434\u0438\u043d \u0434\u0435\u043d\u044c \u0432\u0435\u0441\u044f\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u043e \u2014 \u043e\u043a\u043e\u043b\u043e 500 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442 \u044d\u0442\u043e \u043f\u0440\u0438 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 1\/10 (\u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 10 % \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0435\u0439 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430), \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0431\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0438 \u0431\u0435\u0437 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0437\u0430 \u043e\u0434\u0438\u043d \u0434\u0435\u043d\u044c \u0432\u0435\u0441\u0438\u043b\u0430 \u0431\u044b 5 \u0413\u0438\u0433\u0430\u0431\u0430\u0439\u0442. \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0441 \u0441\u044b\u0440\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u043e 5 \u0434\u043d\u0435\u0439, \u0437\u0430\u0442\u0435\u043c \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430 \u043d\u0435\u043d\u0430\u0434\u043e\u0431\u043d\u043e\u0441\u0442\u044c\u044e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b-\u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043a\u0440\u043e\u043d\u0443, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0441\u044b\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u0438\u0445 \u0443\u0436\u0435 \u0432 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u043c \u043e\u0431\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u2013 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432, \u043e\u0442\u0447\u0435\u0442\u043e\u0432.<\/p>\n<h3>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043e\u0442\u0447\u0435\u0442\u043e\u0432<\/h3>\n<p>  \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u0447\u0435\u0442\u044b \u0441\u0442\u0440\u043e\u0438\u043b\u0438\u0441\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e find() \u0438 <a href=\"http:\/\/docs.mongodb.org\/manual\/core\/map-reduce\/\">Map-Reduce<\/a>. \u041c\u0435\u0442\u043e\u0434 collection.find() \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0432\u044b\u0431\u043e\u0440\u043e\u043a, \u0430 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u0438\u043b\u0438\u0441\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Map-Reduce. \u0412\u0442\u043e\u0440\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430. \u0417\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 MySQL \u0440\u0435\u0448\u0430\u043b\u0438\u0441\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 AVG,SUM, ORDER BY, \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0443\u0445\u0438\u0449\u0440\u0435\u043d\u0438\u0439 \u0441 Map-Reduce \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0425\u043e\u0440\u043e\u0448\u0438\u043c \u043f\u043e\u0434\u0430\u0440\u043a\u043e\u043c \u0434\u043b\u044f \u043d\u0430\u0441 \u0432 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0442\u0430\u043b \u0432\u044b\u0445\u043e\u0434 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 MongoDB 2.2, \u0432 \u043d\u0435\u0439 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f <a href=\"http:\/\/docs.mongodb.org\/master\/reference\/command\/aggregate\/#dbcmd.aggregate\">Aggregation Framework<\/a>, \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u0438 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b, \u043d\u0435 \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u044e \u043a Map-Reduce.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0447\u0435\u0440\u0435\u0437 aggregate (\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e id \u0432\u0438\u0434\u0435\u043e \u0438 \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u0442| \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043f\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c):<\/p>\n<pre><code class=\"javascript\"> db.stat20141103.aggregate([ \t { $match : { $nor : [{ ap : {$gt: 20}, loaded :0 }]} } , \t\t { $group: { \t\t\t\t\t_id:&quot;$video_id&quot;, \t\t\t\t\tsum:{$sum:1}, \t\t\t\t\tactive:{$sum:&quot;$active&quot; }, \t\t\t\t\tpassive:{$sum:&quot;$passive&quot; }, \t\t\t\t\tbuffer:{$sum:&quot;$buffer&quot; }, \t\t\t\t\trewind:{$avg:&quot;$rewindn&quot; }, \t\t\t\t\tplayed:{$sum:&quot;$played&quot; } \t\t\t\t\t}  \t\t } \t]); <\/code><\/pre>\n<h3>\u0414\u0435\u043f\u043b\u043e\u0439 \u0438 \u041e\u0442\u043b\u0430\u0434\u043a\u0430<\/h3>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043f\u043e\u0434 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ol>\n<li>\u0412 \u0441\u0430\u043c\u043e\u0439 OS \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 Ubuntu \u044d\u0442\u043e:\n<pre><code class=\"bash\">#\/etc\/security\/limits.conf  # \u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u043b\u0438\u043c\u0438\u0442 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u0444\u0430\u0439\u043b\u043e\u0432 (\u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443).  * - nofile 1048576 <\/code><\/pre>\n<p>  \u0412 \u0434\u0440\u0443\u0433\u0438\u0445 Linux-\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \/etc\/sysctl.conf.  <\/li>\n<li>\u0414\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b MongoDB \u0444\u0430\u0439\u043b\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043b\u0438 \u043d\u0430 SSD \u0434\u0438\u0441\u043a\u0435. \u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433 \u0431\u0430\u0437\u044b: \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043b\u0438 Journalin, \u0438 \u043f\u043e\u0438\u0433\u0440\u0430\u043b\u0438\u0441\u044c \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0441\u0431\u0440\u043e\u0441\u0430 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a (storage.syncPeriodSecs \u2014 \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e MongoDB \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a).\n<pre><code class=\"bash\">\/etc\/mongodb.conf journal:       enabled: false <\/code><\/pre>\n<p>  <\/li>\n<\/ol>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/242369\/\"> http:\/\/habrahabr.ru\/post\/242369\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/files\/a82\/6ce\/c72\/a826cec721994f70bc8514323ce30eb2.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0431\u044b\u043b\u0430 <a href=\"http:\/\/habrahabr.ru\/company\/ivi\/blog\/236253\/\">\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f<\/a> \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u043d\u0430 ivi.ru. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u0440\u0443\u043f\u043d\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430. \u0417\u0430\u043a\u0430\u0437\u0447\u0438\u043a, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043b \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u0430\u0439\u0442. \u0415\u0441\u043b\u0438 \u0432\u0435\u0440\u0438\u0442\u044c Alexa Rank, \u0442\u043e \u0442\u0440\u0430\u0444\u0438\u043a \u043d\u0430 \u0441\u0430\u0439\u0442\u0435, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443, \u0440\u0430\u0437 \u0432 10 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u0430 ivi.ru.   <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-242369","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/242369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=242369"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/242369\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=242369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=242369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=242369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}