C++ web script

Hi,

I am writing a web site script in Visual C++ under Windows.
The site runs on Windows 2008 R2 (IIS 7)
The program forms html page line by line and stores it in a string.
The string has 2-byte UTF-16 encoding.
At the end of the run the script converts buffer to UTF-8 and sends it to the standard output.

The questions are:

- Is it a good idea to collect the whole page, convert and send it as a single batch?
I can convert and send the page line by line as it is formed but I thought a single conversion call would be quicker.
It is also possible that user browser can accept part of the page and start displaying it before the whole page arrives. In this case line-by-line transfer is better. I don't know.

- I can output data using 'cout' or 'printf'. I've read somewhere that printf is quicker. Is there any difference?

The script runs millions times a day so I need to optimize it in every way.
The bad thing is that some calls end up with 502 errors and I don't know why.
It seems the server just terminates some script instances when under load.
I will most naturally look into IIS settings but other things could turn up as well.
Topic archived. No new replies allowed.