Thanks for your answers!
> How did you write the code to read the file?
> What language did you write it in? You haven't provided enough information.
I wrote it in haskell, just reading file and writting it out using ByteString:
import Network.FastCGI
import qualified Data.ByteString.Lazy as BL
main = runFastCGIConcurrent 1000 (handleErrors cgiMain)
cgiMain :: CGI CGIResult
cgiMain = do
setHeader "Content-type" "image/jpeg"
b <- liftIO $ BL.readFile "/usr/lib/cgi-bin/pic.jpg"
outputFPS b
> FastCGI is not particularly appropriate for this task. Apache is most
> likely much more efficient at the fairly simple task of streaming files via
> HTTP, and doesn't incur the overhead that FastCGI does in performing that
> task.
I am planning to write complex content management system with storing pictures in dedicated storage, that's why I have to output pictures through the application.
> FastCGI is more appropriate for tasks that you would otherwise write a CGI
> program to do, and should be faster in those cases. It is also appropriate
> for tasks where you would consider loading mod_php, mod_perl, etc. into
> your Apache configuration; in those cases, the performance difference will
> probably be negligible, but you have a lot more control over the design in
> terms of load-balancing and security.
So, I will use something different than fastcgi.