Example HTTP Server 3, Requests are processed one by one on Win32?

Hi, I'm new to boost and it's mailing list and I really like the library! As my first example project, I want to run the boost HTTP Server 3. Interesting points for me are Socket and Threading stuff. To get into the threading stuff, I did add some output to the std::cout in the request_handler part at the top of the method "handle_request" following by a sleep(5000). After this I compile (without errors/warnings) and run the program providing Ip/Port, docroot and threadpool size 20. When I start a request to it with my browser, as expected I get the output on the console. But when I start some requests concurrent, the requests seems processed one by one ( not concurrent as expected). I don't know, but I expect, that the Requests would be processed concurrent (1 Request = 1 Thread?) I'm using Visual Studio 10 with boost 1.47.0 on windows server 2k8 rc2 and following example code: http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/examples.html#boost _asio.examples.http_server_3 Any suggestions? Thanks in advance Sven

To get into the threading stuff, I did add some output to the std::cout in the request_handler part at the top of the method “handle_request“ following by a sleep(5000).
After this I compile (without errors/warnings) and run the program providing Ip/Port, docroot and threadpool size 20. When I start a request to it with my browser, as expected I get the output on the console. But when I start some requests concurrent, the requests seems processed one by one (not concurrent as expected). I don’t know, but I expect, that the Requests would be processed concurrent (1 Request = 1 Thread?)
As far as I see, request_handler is called from handle_read, and the latter handler is wrapped with strand -- especially to prevent such a concurrecy: http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/reference/io_servic...

To get into the threading stuff, I did add some output to the std::cout in the request_handler part at the top of the method “handle_request“ following by a sleep(5000).
After this I compile (without errors/warnings) and run the program providing Ip/Port, docroot and threadpool size 20. When I start a request to it with my browser, as expected I get the output on the console. But when I start some requests concurrent, the requests seems processed one by one (not concurrent as expected). I don’t know, but I expect, that the Requests would be processed concurrent (1 Request = 1 Thread?)
As far as I see, request_handler is called from handle_read, and the latter handler is wrapped with strand -- especially to prevent such a concurrecy: http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/reference/io_ service__strand.html
Ahh I see - I currently do not understand the sense of this. It's a HTTP Server, why should it not process requests concurrently? Any ideas?

Ahh I see - I currently do not understand the sense of this. It's a HTTP Server, why should it not process requests concurrently? Any ideas?
I haven't delved into this sample in details, but I guess these completion handlers deal with some shared state, so you anyway have to protect it against race condtions. "Strand" is just the most simple and elegant way to do this.

Ahh I see - I currently do not understand the sense of this. It's a HTTP Server, why should it not process requests concurrently? Any ideas? I haven't delved into this sample in details, but I guess these completion handlers deal with some shared state, so you anyway have to protect it against race condtions. "Strand" is just the most simple and elegant way to do this.
That's really annoying :( Does anybody knows samples about c++ http server (threaded and able to process requests concurrently)?

That's really annoying :( Does anybody knows samples about c++ http server (threaded and able to process requests concurrently)?
Look at HTTP 2 example, it uses io_service-per-cpu design. Very funny, doesn't work, too. Set "thread size" to 20 but he does not care, still processing the requests one by one. I don't know what's wrong...
participants (3)
-
Igor R
-
Sven
-
Sven Kummer