Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
168 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
c-fastcgi: c-fastcgi.c | ||
gcc -O2 -o c-fastcgi c-fastcgi.c -lfcgi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ab -n 100 -c 20 http://localhost:3000/app/ > c-fastcgi.ab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "fcgi_stdio.h" /* fcgi library; put it first*/ | ||
|
||
#include <stdlib.h> | ||
|
||
void main(void) | ||
{ | ||
while (FCGI_Accept() >= 0) { | ||
int row; | ||
printf("Content-type: text/html\r\n\r\n<table>"); | ||
for (row = 1000; row--;) { | ||
int col; | ||
printf("<tr>"); | ||
for (col = 1; col <= 50; ++col) { | ||
printf("<td>%d</td>", col); | ||
} | ||
printf("</tr>"); | ||
} | ||
printf("</table>"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
server.port = 3000 | ||
server.document-root = "." | ||
server.modules = ("mod_fastcgi") | ||
|
||
fastcgi.server = ( | ||
"/app" => (( | ||
"socket" => "/tmp/test.fastcgi.socket", | ||
"check-local" => "disable", | ||
"bin-path" => "./c-fastcgi", # full path to executable | ||
"min-procs" => 1, | ||
"max-procs" => 4, | ||
"idle-timeout" => 30 | ||
)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lighttpd -D -f lighttpd.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fastcgi: fastcgi.hs | ||
ghc --make fastcgi.hs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ab -n 100 -c 20 http://localhost:3000/app/ > direct-fastcgi.ab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE PackageImports #-} | ||
import Prelude hiding (putStr) | ||
import Data.ByteString.Char8 (ByteString, putStr, pack) | ||
import Numeric (showInt) | ||
import qualified Data.ByteString.Lazy as L | ||
import "direct-fastcgi" Network.FastCGI | ||
import Control.Concurrent | ||
|
||
main = acceptLoop forkIO app | ||
|
||
app = do | ||
setResponseHeader HttpContentType "text/html" | ||
mapM_ fPut content | ||
|
||
content = "<table>" | ||
: foldr ($) ["</table>"] (replicate 1000 makeRow) | ||
|
||
makeRow :: [ByteString] -> [ByteString] | ||
makeRow rest = foldr (:) rest $ map makeCol [1..50] | ||
|
||
makeCol 1 = "<tr><td>1</td>" | ||
makeCol 50 = "<td>50</td></tr>" | ||
makeCol i = pack $ '<' : 't' : 'd' : '>' : showInt i "</td>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
server.port = 3000 | ||
server.document-root = "." | ||
server.modules = ("mod_fastcgi") | ||
|
||
fastcgi.server = ( | ||
"/app" => (( | ||
"socket" => "/tmp/test.fastcgi.socket", | ||
"check-local" => "disable", | ||
"bin-path" => "./fastcgi", # full path to executable | ||
"min-procs" => 1, | ||
"max-procs" => 4, | ||
"idle-timeout" => 30 | ||
)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lighttpd -D -f lighttpd.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fastcgi: fastcgi.hs | ||
ghc --make fastcgi.hs -threaded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ab -n 100 -c 20 http://localhost:3000/app/ > package-fastcgi.ab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE PackageImports #-} | ||
import Prelude hiding (putStr) | ||
import Data.ByteString.Char8 (ByteString, putStr, pack) | ||
import Numeric (showInt) | ||
import qualified Data.ByteString.Lazy as L | ||
import "fastcgi" Network.FastCGI | ||
import Network.CGI | ||
|
||
main = runFastCGIConcurrent 5 app | ||
|
||
app = do | ||
setHeader "Content-Type" "text/html" | ||
outputFPS content | ||
|
||
content = L.fromChunks | ||
$ "<table>" | ||
: foldr ($) ["</table>"] (replicate 1000 makeRow) | ||
|
||
makeRow :: [ByteString] -> [ByteString] | ||
makeRow rest = foldr (:) rest $ map makeCol [1..50] | ||
|
||
makeCol 1 = "<tr><td>1</td>" | ||
makeCol 50 = "<td>50</td></tr>" | ||
makeCol i = pack $ '<' : 't' : 'd' : '>' : showInt i "</td>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
server.port = 3000 | ||
server.document-root = "." | ||
server.modules = ("mod_fastcgi") | ||
|
||
fastcgi.server = ( | ||
"/app" => (( | ||
"socket" => "/tmp/test.fastcgi.socket", | ||
"check-local" => "disable", | ||
"bin-path" => "./fastcgi +RTS -N2", # full path to executable | ||
"min-procs" => 1, | ||
"max-procs" => 4, | ||
"idle-timeout" => 30 | ||
)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lighttpd -D -f lighttpd.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fastcgi: fastcgi.hs | ||
ghc --make fastcgi.hs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ab -n 100 -c 20 http://localhost:3000/app/ > fastcgi.ab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE PackageImports #-} | ||
import Prelude hiding (putStr) | ||
import Data.ByteString.Char8 (ByteString, putStr, pack) | ||
import Numeric (showInt) | ||
import "wai" Network.Wai | ||
import Network.Wai.Enumerator | ||
import Network.Wai.Handler.FastCGI | ||
import qualified Data.ByteString.Lazy as L | ||
|
||
main = run app | ||
|
||
app _ = return $ Response Status200 [(ContentType, "text/html")] $ Right $ | ||
fromLBS content | ||
|
||
content :: L.ByteString | ||
content = L.fromChunks | ||
$ "<table>" | ||
: foldr ($) ["</table>"] (replicate 1000 makeRow) | ||
|
||
makeRow :: [ByteString] -> [ByteString] | ||
makeRow rest = foldr (:) rest $ map makeCol [1..50] | ||
|
||
makeCol 1 = "<tr><td>1</td>" | ||
makeCol 50 = "<td>50</td></tr>" | ||
makeCol i = pack $ '<' : 't' : 'd' : '>' : showInt i "</td>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
server.port = 3000 | ||
server.document-root = "." | ||
server.modules = ("mod_fastcgi") | ||
|
||
fastcgi.server = ( | ||
"/app" => (( | ||
"socket" => "/tmp/test.fastcgi.socket", | ||
"check-local" => "disable", | ||
"bin-path" => "./fastcgi-prof", # full path to executable | ||
"min-procs" => 1, | ||
"max-procs" => 1, | ||
"idle-timeout" => 30 | ||
)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lighttpd -D -f lighttpd.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters