[CEDEC 2021] éç¨ä¸ã¿ã¤ãã«ã§ãæããªãï¼ ãã¡ã«ã¯ã¹ãã¼ãªã¢ãã«ããããã¤ããã©ã¼ãã³ã¹ã»ãã¼ã³ã¹ããªãªã¢ã«ã¿ã¤ã éä¿¡æè¡ã®å°å ¥äºä¾
[CEDEC 2021] éç¨ä¸ã¿ã¤ãã«ã§ãæããªãï¼ ãã¡ã«ã¯ã¹ãã¼ãªã¢ãã«ããããã¤ããã©ã¼ãã³ã¹ã»ãã¼ã³ã¹ããªãªã¢ã«ã¿ã¤ã éä¿¡æè¡ã®å°å ¥äºä¾
æ°å¹´åãWebã¯å ¨ä½çã«æå·åããã¦ãã¾ããã§ãããHTTPSã¯Webãã¼ã¸ã®æãéè¦ãªé¨åã ãã®ããã«ç¢ºä¿ããã¦ãã¾ãããæå·åãå¿ è¦ãªã®ã¯å¤§åãªã¦ã¼ã¶ãã¼ã¿ã ãã§ãWebãã¼ã¸ã®å ¬éãããé¨åã¯æå·åããã«éã£ã¦ãããã¨ãããã¨ã§æè¦ãä¸è´ãã¦ãã¾ããã ãããã ä»ã¯ ç¶æ³ ã éãã¾ã ãç¾å¨ã§ã¯ãã©ããªWebãã©ãã£ãã¯ã§ãæå·åããã¦ããªãã®ã¯è¯ããªãã¨ãããã¨ãåãã£ã¦ããã®ã§ãWebãµã¤ããéå¶ãã誰ããã³ã³ãã³ãã«é¢ä¿ãªãå¼·åºãªHTTPSãè¨å®ããªããã°ãªãã¾ããã ãæ¥ãããã話ã§ãããç§èªèº«ã®Webãµã¤ãã¯2å¹´è¿ããå ¨ãHTTPSããµãã¼ããã¦ãã¾ããã§ãã ^(1) ã Eric Mill ã® ä»ããç¡æã§HTTPSã«åãæ¿ããã ã¨ããç´ æ´ãããè¨äºãæçµçã«ç§ã«åãå ¥ãã¦ããã¾ãããç§ã¯ä¼æä¸ãHTTPSãã»ããã¢ããã㦠Qualys SSL Report ã§
解説 worker_processes auto; - Nginxæ¬ä½ã®ããã»ã¹æ°ãautoã«ãã¦nginxå é¨å¤å®ã«ä»»ããã®ã¯è³¢æ worker_rlimit_nofile 100000; - workerããã»ã¹ãæå¤§ã«éãããã¡ã¤ã«æ°ã®å¶éããã®ããã«è¨å®ããããulimit -a以ä¸ã®ãã¡ã¤ã«æ°ãå¦çã§ããããã«ãªããtoo many open filesåé¡ãåé¿ã§ãã worker_connections 2048; - ä¸ã¤ã®workerããã»ã°ãéããæå¤§ã³ãã¯ã·ã§ã³æ° multi_accept on; - ã§ããã ãã¯ã©ã¤ã¢ã³ãããã®ãªã¯ã¨ã¹ããåãåã use epoll; - Linuxã«ã¼ãã«2.6以ä¸ã®å ´åã¯epollãBSDã®å ´åkqueue server_tokens off; - ã»ãã¥ãªãã£å¯¾çã§ããã¨ã©ã¼ç»é¢ã®nginxãã¼ã¸ã§ã³çªå·ãé表示 sendf
Nginx + Luaãç¨ããããã¤ããã©ã¼ãã³ã¹ã§åçãªãããã·ãµã¼ããèå¯ä¸ã§ãã ãã®ããã®æ½çã®ä¸ã¤ã¨ãã¦ ä¸æµãµã¼ãã¸ã®ã¢ã¯ã»ã¹ãKeepAliveãã ã¨ããæ¹æ³ãããã¾ãã ãã®éããããã·ãµã¼ãã«ã©ã®ç¨åº¦æ§è½ã«å¤åãããã®ãã調æ»ãã¦ã¿ã¾ããã ãªãã¼ã¹ãããã·ã®keepaliveè¨å® åææ¡ä»¶ã¨ã㦠Nginx > 1.1.4 ãå¿ è¦ã upstreamã« keepalive ã¨ããattributeãããã®ã§ãããè¨å®ãã¾ãã ããã¨åæã«ããããã·ãããã¼ã«HTTP/1.1è¨å®ãªã©ãè¡ãã¾ãããã ã¡ãªã¿ã«proxy_passã ãã ã¨keepaliveã§ããªãããã§ããupstreamå¿ é ã ãã¨ããã¡ããããã¯ã¨ã³ããµã¼ãå´ãkeepaliveè¨å®ãã¦ããã¾ãã upstream http_backend { server oreore.micro.service;
å¦çè½åã®é«ããªã©ãçç±ã«ãè¿å¹´ãå¤§è¦æ¨¡ãµã¤ããä¸å¿ã«æ¥éã«ã·ã§ã¢ãæ¡å¤§ãã¦ããWebãµã¼ãã¼ãNginxãããã®é£è¼ã§ã¯ããã®ç¹å¾´ã¨é åãåãããããç´¹ä»ãã¾ãã 第3ã®Webãµã¼ãã¼ã¨ãã¦æ³¨ç®ãéããNginx 1æ¥ã«æ°åãªã¯ã¨ã¹ããå¦çãããããªå¤§è¦æ¨¡ãµã¤ããä¸å¿ã«ãè¿å¹´æ¥éã«ã·ã§ã¢ãæ¡å¤§ãã¦ããWebãµã¼ãã¼ããNginxï¼ã¨ã³ã¸ã³ã¨ãã¯ã¹ï¼ãã§ããHTMLããã¥ã¡ã³ããç»åãã¡ã¤ã«ã¨ãã£ãéçã³ã³ãã³ããé«éã§é ä¿¡ããæ¶è²»ã¡ã¢ãªãå°ãªãããªãã¼ã¹Proxyããã¼ããã©ã³ãµã¼ã¨ãã£ãæ©è½ãæããæ³¨ç®ã®è»½éWebãµã¼ãã¼ã§ãããããã¯ã©ãã社ã®èª¿æ»ã«ããã¨ã2014å¹´6ææç¹ã§Apache HTTPãMicrosoft IISã«æ¬¡ã第3ä½ã®ã·ã§ã¢ãç²å¾ãã¦ãã¾ãã ä¾ç¶ã¨ãã¦Apache HTTPãMicrosoft IISã®ã·ã§ã¢ã¯é«ããã®ã®ãNginxã®èªç¥åº¦ã¯æ¥ã«æ¥ã«é«ããªã£ã¦
[Infrataster] Infratasterã§Nginxã®ã«ã¼ãã£ã³ã°ã®ãã¹ãæ¸ãã¦ããµã¼ãã¼ã®ãã¹ãã¯Serverspecã§æ¸ãã¦ãããã ãã©ãNginxã®è¨å®ãã¡ã¤ã«ã§æ¸ãã¦ããã¦ã§ããµã¼ãã¼ã®ã«ã¼ãã£ã³ã°ã®ãã¹ããã©ãããããã¨æã£ã¦ãã¾ãããèªåã§ãç°¡åãªãã¼ã«ã§ãæ¸ãã¹ãããªãã¨ã /path/to/app ã§ã¢ããªã±ã¼ã·ã§ã³ã«ããã¯ã·ã¼ãã ä½ãcookieããªãå ´åã¯éçãã¡ã¤ã«ããµã¼ããã /path/to/static/file ã§éçãã¡ã¤ã«ãNginxãç´æ¥ãµã¼ããã /path/to/health/check ã§ãã«ã¹ãã§ãã¯ç¨ã®ã¬ã¹ãã³ã¹ãè¿ããä½ãHTTPãããã¼ãè¦ã¦æ®éã®ãã©ã¦ã¶ã¼ã¢ã¯ã»ã¹ã§ã¯Forbiddenã«ãã ãã¼ãã£ã«ãã¡ã¤ã³ãã¨ã«å¾®å¦ã«ãã¹ã¨ããéã ã¿ãããªã«ã¼ãã£ã³ã°ã®ãã¹ãã¯ãå¤å´ããã®ãã¹ããªã®ã§ã¡ãã£ã¨Serverspecã®ã¹ã³ã¼
ã¢ããªã±ã¼ã·ã§ã³ã§ã©ããã¦ãæããªãéã®ãªã¯ã¨ã¹ãã䏿çã«æ¼ãå¯ãã¦ãã¾ãå ´åãã¢ããªã±ã¼ã·ã§ã³ãµã¼ããæ»ã¬ã®ãé¿ããããã« GET ã¯å¶éãæãããããPOST ã¯ãªãã©ã¤ãé¢åãªã®ã§ãªãã¹ãéãã¦ãããããã¨ãããããªè¦æ±ã nginx ã§å¦çã§ãããã©ããã å®è£ ã¨ãã¦ä¸çªæã¾ããã®ã¯ GET 㯠100 req/sec ã§å¶é (è¶ ããã503) POST ã¯ç¡å¶é ã®ããã«ã¡ã½ãããã¨ã«å¥ã ã®å¶éãæãããã¨ã ã£ãã®ã§ãããã¨ãããã HttpLimitReqModule ã使ããã¨ã§ãã¡ã½ãããã¨ã«åä¸ã®ä¸éãè¨å®ãããã¨ã¯ã§ãã¾ããã http { limit_req_zone $request_method zone=method:1m rate=100r/s; server { listen 80; location / { limit_req zone=method;
PyFes 2012.11 çºè¡¨è³æã§ãã ã·ã¹ãã ã³ã¼ã«ã«ç¦ç¹ãå½ã¦ã¦ã meinheld ã®ã¢ã¼ããã¯ãã£ãç´¹ä»ãã¾ãã ã¢ã¼ããã¯ãã£ã説æããããã« Pure Python ã§ãµã³ãã«å®è£ ãæ¸ãã¦ãã¾ãããã¡ããã¨åãããHTTPãªã¯ã¨ã¹ãã®ãã¼ã¹ã端æã£ã¦ããã®ã§ 10000req/sec 以ä¸åºã¾ãã ã¤ãã³ãããªãã³ã®ã³ã¼ãã§ããã¼ãå¤ãã«ããå ´å㯠python -mtrace -t --ignore-module socket webserver1.py ãªã©ã®ããã«ãã¬ã¼ã¹ããªããå®è¡ããã¨ããã§ãããã åæ ä»æ¥ã¯ãã·ã³ãã«ãªã¬ã¹ãã³ã¹ãè¿ãã ãã®æ¡ä»¶ã§ãã²ããã req/sec ã追æ±ãã話ããã¾ãã ãã¨ãã°ã nginx ã® lua ã¢ã¸ã¥ã¼ã«ã§ "hello" ã¨è¿ãã ãã¨ãã§ãã éçãã¡ã¤ã«ãé ä¿¡ãããµã¼ãã¼ã¨ãã ã¨ãã£ã¨å¥ã®ãã¨ãèããªãã¨ããã¾ããã
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}