How to build a High Performance PSGI/Plack Server PSGI/Plackã»Monocerosã§å¦ã¶ ãã¤ããã©ã¼ãã³ã¹ Webã¢ããªã±ã¼ã·ã§ã³ãµã¼ãã®ä½ãæ¹Read less
Monoceros 㯠@kazeburo ãããéçºãã¦ã Plack ç¨ã¦ã§ããµã¼ããpreforkåã ãã©ãå¾ æ©ä¸ã®æ¥ç¶ãã¤ãã³ãããªãã³ã®ããã¼ã¸ã£ã§ç®¡çãããã¨ã§ãåææ¥ç¶10,000æ¬ã¨ãè¡ããï¼ã½ã±ããã®åã渡ã㯠SCM_RIGHTS ã¨ã使ãï¼ã ã§ãéæ 大好ãï¼ï¼ï¼ Starletããé ãåé¡ã¯ã以ä¸ã®ããã«ããã°è§£æ±ºã§ããã¨æã listen ããã½ã±ããã« TCP_DEFER_ACCEPT ã¤ãã¦ãaccept(2) 㯠worker ã§ã®ã¿å®è¡ãã worker 㯠HTTP ã¬ã¹ãã³ã¹éä¿¡å¾ã« read(2) ãã¦ã¿ã¦ãå¾ç¶ã®ãªã¯ã¨ã¹ããæ¥ã¦ãªãå ´åã«ã®ã¿ãããã¼ã¸ã£ããã»ã¹ã«ã½ã±ãããè¿éãã (追è¨) ãè¿éãã§ã¯ãªããããã¼ã¸ã£ããã»ã¹ã管çãã¦ããã½ã±ããã®ããããã«ãã¼ã¿ããã¦ããå ´åã®ã¿ããã®ã½ã±ããã¨workerã®ã½ã±ãããã交æããããã¨ããã°
ä¸è¬ç㪠Web Programmer ãªãã°ãHTTP Status code ã¯ãã¹ã¦æè¨ãã¦ããã¨èãã¾ããã ããããåã¯åå¿è ãªã®ã§ããªããªãè¦ãããã¦ããªãã®ã§ãHTTPã®ã¹ãã¼ã¿ã¹ã³ã¼ãããããã®ã«ä¾¿å©ãªãã¼ã«ãç¨æãã¾ãããApp::httpstatus ã§ããã¤ã³ã¹ãã¼ã«æ¹æ³ã¯ cpanm App::httpstatus ã§ããã¨ãããä¾åã¨ããªãã®ã§http://api.metacpan.org/source/TOKUHIROM/App-httpstatus-v1.0.0/httpstatus ãã³ãã¼ãã¦ããã°ãããã¾ãã 使ãæ¹ã¯ä»¥ä¸ã®ã¨ããã§ãã 4xx ãªã³ã¼ããåæããã % httpstatus 4 400 Bad Request 401 Unauthorized 402 Payment Required 403 Forbidden 404 Not Foun
ãHTTPã³ã³ãã³ãå§ç¸®ã¯ã©ã®ã¬ã¤ã¤ã¼ã§è¡ãã®ãããããã§æ¸ããããã¾ããããé«ãã©ãã£ãã¯ç°å¢ã§ã¯ããµã¼ãéã®éä¿¡éãåé¡ã¨ãªããããApplicationãµã¼ãã§ãHTTPå§ç¸®ããããã»ãè¯ããã§ããPlackã«ã¯æ¢ã«Plack::Middleware::Deflaterã¨ããApacheã®mod_deflateç¸å½ã®Middlewareãããã®ã§ãããã¡ããã¡ããå¼ã£ã¦ãããããã®ã§ãã®ç´¹ä»ã ãã®åã«ãHTTPã³ã³ãã³ãå§ç¸®ã®ããããã§ããHTTPå§ç¸®ã¯ãªã¯ã¨ã¹ãã®Accept-Encodingã«gzipãdeflateããã£ãå ´åã«ãã³ã³ãã³ããgzipãdeflateãªã©ã§å§ç¸®ããã¬ã¹ãã³ã¹ã®Content-Encodingãããã«å§ç¸®ã«ç¨ããæ¹å¼ã表è¨ãããã¨ã§å®ç¾ããã¾ããããã«ãã¯ã©ã¤ã¢ã³ããµã¼ãéã«ãã£ãã·ã¥ãµã¼ããåå¨ããå ´åã«ãAccept-Encodingãéã£ã¦
å··ã§ã¨ã£ã¦ãéãã¦ä¾¿å©ã ãããã£ã¦ãªã£ã¦ã HTTP Client ã§ããã¨ããã® Furl ã®ç°¡åãªã¤ããæ¹ãç´¹ä»ãã¾ãã ãããã Furl ã¯ä½ãã£ã¦ããã¨ãperl ã«ã¯ LWP ã£ã¦ããè¶ é«æ©è½ãª HTTP Client ããã£ã¦ããããããã¡ã¯ãã«ãªã£ã¦ããã§ããã ã§ããããã£ã¦çµæ§æãããã£ã¦ããã¤éåé·å¤§ãªã¢ã¸ã¥ã¼ã«ç¾¤ãªã®ã§çµæ§é ãããã§ããã¨ãã« CPU 使ç¨çãé«ãã ãããªããã§ãlibcurl ãããéãã¦è»½ã HTTP Client ãããã¨ããããã£ã¦ãã¨ã§éçºãããã®ã Furl ã§ãã èªã¿æ¹ã¯ ãµãã¼ãã use strict; use warnings; use 5.0100; use Furl; my $furl = Furl->new(agent => 'Madoka-Magica/chu-2'); my $res = $furl->get('ht
multipart/mixed 㨠PSGI ã¨ã Perl ã¨ã HTTP Server ããè¤æ°ã®ãã¡ã¤ã«ãä¸åã®ã¬ã¹ãã³ã¹ã§ãããããã¨ã㯠multipart/mixed ãã¤ããã®ãæ®éã ã¨ãããã®ã ããã©ãããã Perl ã§ããã«ã¯ã©ãããããããã¨ãã話é¡ã multipart/mixed ã Plack ãªã¢ããªã§ã ãã«ã¯ãã©ã¤ãã©ãªãã¤ããã®ã§ã¯ãªãæã§ã ããæ¹ãçµå±æ¥½ã£ã½ãã ã¯ã©ã¤ã¢ã³ãå´ã§ã¯ãLWP 㯠multipart/mixed ã«å¯¾å¿ãã¦ããã®ã§ãç´ ç´ã« my $res = $ua->get(...); # $res is-a HTTP::Response. for my $part ($res->parts) { say $part->content_type; } ãªã©ã¨ããã°ããããã
HTTP::Request::StreamingUpload - çã¡ã¢ãªã§request bodyãupload Today I created a good wrapper for request body upload HTTP::Request. this module is use few memory on file upload. also too big file. http://search.cpan.org/dist/HTTP-Request-StreamingUpload/ http://github.com/yappo/p5-HTTP-Request-StreamingUpload DESCRIPTION HTTP::Request::StreamingUpload is streaming upload wrapper for HTTP::Request. It
ãã¼ãã¨æã£ã¦ãæ¸ãããGitHub - kazuho/p5-http-parser-xs: a fast http parser BLURB ã¯ã PSGI ã®ãªã¯ã¨ã¹ããªãã¸ã§ã¯ããè¿ã é«é åæ httpd, éåæ httpd ã®ã©ã¡ããå®è£ ããéã«ã使ç¨å¯è½ POST ã³ã³ãã³ãã®ãã³ããªã³ã°ã¯ãèªå㧠ãã£ãããã¡ã¤ã«ã«å ¥ããããããããè¦ä»¶ããããããã¼ã¹ä½æ¥ã¯çºçããªãã®ã§ Perl ã§ããã¾ãé ããªããªããã ã¦ãªæãã§ãã以ä¸ãã³ããã¼ã¯ã $ ./http-parser-vs-xs-benchmark.pl Rate HTTP::Parser HTTP::Parser::XS HTTP::Parser 2978/s -- -95% HTTP::Parser::XS 54348/s 1725% --ãã³ããã¼ã¯ã«ä½¿ã£ãã³ã¼ãã¯ã以ä¸ã®ã¨ããã #! /usr/bin/
ååã®ã¾ãã¾ã§ãããApacheã®ã¢ã¯ã»ã¹ãã°ããHTTP::Requestãªãã¸ã§ã¯ããä½ãã¢ã¸ã¥ã¼ã«ãCPANã«ãï½ãã¦ããã¾ããã http://search.cpan.org/~miki/HTTP-Request-FromLog-0.00001/ å©ç¨ç¨éã§ãããéçºç°å¢ã¨åç¨ç°å¢ãåããã¦ãããããªå ´åã«ãåç¨ç°å¢ã®ãµã¼ãã«æµãã¦ãããã©ããã¯ãéçºç°å¢ã®ãã·ã³ã«ãæµãã¦ããããï¼ã¨ãããããªã±ã¼ã¹ãæ³å®ãã¦ãã¾ãã åç´ãªçºæ³ã§ãããåç¨ç°å¢ã®access_logããHTTP::Requestãªãã¸ã§ã¯ããåçãã¦éçºç°å¢ã®ãã·ã³ã«æãã¦ããã°ãä¸å¿ããã£ã½ããã¨ã¯ã§ããããªã¨ã ã¡ãªã¿ã«å é¨ã®ã¨ã³ã¸ã³ï¼ãã°ãparseããé¨åï¼ã¯ããã©ã«ãã ã¨Parse::AccessLogEntryã¨ããCPANã¢ã¸ã¥ã¼ã«ä½¿ã£ã¦ã¾ãããããã¯èªç±ã«å·®ãæ¿ãå¯è½ã§ãã ãªã®ã§ããã¡ã®ãã°ãã©
CPAN風ã«perl moduleãæ¸ãã¦ã人ã¯testã³ã¼ããã¬ã³ã¬ã³æ¸ãã¦make testããªãããæ¥ã ãã£ã¨ããã¦ãã¨æããã§ããã ä»æ¥ã¯ã¡ãã£ã¨ããã§ããã£ãã®ã§ãå¿ããªãããã«ã¡ã¢ã¡ã¢ã testã³ã¼ãã®ä¸ã§ãç°¡æãªHTTP Serverãèµ·åãããã¨ãã¾ãã ãµã¼ãã®ã³ã¼ãã¯server.plã§ãPOE::Component::Server::HTTPãããã§ã¡ããã£ã¨æ¸ãããã®ã ã¨ãã¾ãããã ããã¤ã¯ä¸å¿ãã¼ã¢ã³ãªã®ã§ããã¹ãã³ã¼ãããã¯ï¼ãã¤ãã¦ããã¯ã°ã©ã³ãã¸ã§ãã¨ãã¦èµ·åãã¾ãã ã§ããã®ãã¼ã¢ã³ã«å¯¾ãã¦HTTPãªã¯ã¨ã¹ãããªãã¦çµæããã¹ãããã¨ãã¾ãã ãã¹ãã³ã¼ãã¯ãããªæããï¼dummy_server.tã¨ãã¾ãï¼ use strict; use LWP::Simple; use Test::More tests=>1; BEGIN{ system("t/
æ¹ãã¦åå¼·ãããã£ãã®ã§ããããªãã¹ããã¦ã¿ã¾ããã Apacheã®è¨å®ã¨ãã¹ãå 容 <VirtualHost *:80> ServerAdmin zigorou@localhost DocumentRoot /home/zigorou/www/cache ServerName cachetest.art-code.org ExpiresDefault "access plus 5 minutes" Alias /test1 /home/zigorou/www/cache/test Alias /test2 /home/zigorou/www/cache/test Alias /test3 /home/zigorou/www/cache/test <Location /test1> FileETag None ExpiresActive Off </Location> <Location
HTTP::Daemon forkããªãã®ã§ã1åè©°ã¾ãã¨å¾ç¶ã®ãªã¯ã¨ã¹ãã¯å¾ ããããã HTTP::Simple::Server ããã©ã«ãã§ã¯forkããªãã HTTP::Simple::Server ï¼ Net::Server::Fork forkããã®ã§å¤éåå¯è½ããããªã¯ã¨ã¹ããã¨ã«æ°ããããã»ã¹ãforkãã¡ããã HTTP::Simple::Server ï¼ Net::Server::PreFork forkããã®ã§å¤éåå¯è½ãpre-forkããã®ã§ããã»ã¹ã¯ä½¿ãã¾ãããã Net::HTTPServer type=>'forking'ã§pre-forkããã URLã®ãã¹ã¨é¢æ°ããããã³ã°ã§ããã®ããããã PerlBal Danga::Socketãã¼ã¹ãªã®ã§ãIOå¤éå(epollã¨ã)ãªå®è£ ãï¼ã ã¨æããï¼ POE::Component::Server::HTTP
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}