Boost logo

Boost Users :

Subject: [Boost-users] [Boost Asio]Difference between asynchronous (proactor pattern) and synchronous model in web server
From: Tu Hoang Do (solidius4747_at_[hidden])
Date: 2011-10-05 15:39:43


 I'm learning network programming and boost asio on my own, so there's
something I need clarification in my understanding..

In synchronous model, when a client connects to the server, both the client
and server have to sync with each other to finish some operations.

Meanwhile, the asynchronous model allows client and server to work separated
and independently. The client sends a request to establish a connection and
do something. While the server is processing the request, the client can do
something else. Upon completion of an operation, the completion event is
placed onto a queue in an Event Demultiplexer, waiting for a Proactor (such
as HTTP Handler) to send the request back and invoke a Completion Handler
(on the client). The terms are used as in boost::asio document The Proactor
Design Pattern: Concurrency Without
Threads<http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/overview/core/async.html>
.

By working this way, the asynchronous model can accepts simultaneous
connections without having to create a thread per connection, thus improve
overall performance. In order to achieve the same effect as asynchronous
model, the first model (synchronous) must be multi-threaded. For more
detail, refer to: Proactor
Pattern<http://www.google.com/url?sa=t&source=web&cd=1&sqi=2&ved=0CBsQFjAA&url=http://www.cs.wustl.edu/%7Eschmidt/PDF/proactor.pdf&rct=j&q=proactor%20pattern&ei=iE6MTredOuiViQfmv5XmBw&usg=AFQjCNFoNeWioIF2nqgsmIsjIi403tXOhQ&sig2=vrccRX1YLUI_nDv0addKcw&cad=rja>(I
actually learn proactor pattern which is used to asynchronous model
from
that document. In here it has description on a typical synchronous I/O web
server).

Is my understanding on the subject correct? If so, which means the
asynchronous server can accepts request and return results asynchronously
(the first connection request the service on web server does not need to be
the first to reply to)? In essence, asynchronous model does not use
threading (or threading is used in individual components, such as in the
Proactor, Asynchronous Event Multiplexer (boost::asio document) component,
not by creating an entire client-server application stack, which is describe
in the multi-threaded model in Proactor Pattern document, section 2.2 - *Common
Traps and Pitfalls of Conventional Concurrency Models*).



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net