You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Lars Benner <LB...@tomtec.de> on 2013/10/24 10:36:01 UTC
Documentation, differences multithreaded server and non-blocking
server
I have at the moment a simple, single threaded server running in C++ and I figured out, I can have only a single client connection at a time. Ok this did not really surprise me.
Since I need to multiple client/server connections at the same time, I assume I have use either a multithreaded or a non-blocking server. Therefore, I would like to know, what the differences between a multithreaded server and a non-blocking server are. I have a general understanding of these concepts. But I do not know, how they are implemented in thrift and what for implications these different concepts have for my server functionality implementation and the client usage.
So exist some documentation, which I couldn't find, describing this? Or can somebody give me an overview from 10,000 ft?
Thanks a lot,
- Lars
Re: Documentation, differences multithreaded server and non-blocking server
Posted by Randy Abernethy <ra...@gmail.com>.
Hello Lars,
>From 10,000 feet, the key difference between the Apache Thrift C++
multi-threaded blocking/non-blocking servers is that the blocking servers
create one thread per client connection and the non-blocking servers create
a pool of threads which collectively process client requests (any worker
thread can be dispatched to process any client request). The blocking model
is simpler and has fewer dependencies, the non-blocking model is more
complex and requires libevent, but is more scalable at the extreme because
it doesn't need to create 10,000 threads to manage 10,000 connections.
Happy to go into more detail if you need it.
Regards,
Randy
On Thu, Oct 24, 2013 at 1:36 AM, Lars Benner <LB...@tomtec.de> wrote:
> I have at the moment a simple, single threaded server running in C++ and I
> figured out, I can have only a single client connection at a time. Ok this
> did not really surprise me.
>
> Since I need to multiple client/server connections at the same time, I
> assume I have use either a multithreaded or a non-blocking server.
> Therefore, I would like to know, what the differences between a
> multithreaded server and a non-blocking server are. I have a general
> understanding of these concepts. But I do not know, how they are
> implemented in thrift and what for implications these different concepts
> have for my server functionality implementation and the client usage.
>
> So exist some documentation, which I couldn't find, describing this? Or
> can somebody give me an overview from 10,000 ft?
>
> Thanks a lot,
> - Lars
>
RE: Documentation, differences multithreaded server and
non-blocking server
Posted by Lars Benner <LB...@tomtec.de>.
Hello Randy, hello Benjamin,
thank you very much for your explanations and I learned what I was looking for.
I knew now, that I will go for the TThreadPoolServer. My server has to handle only a very limited number of concurrent connections, but a lot of them in a row, so I assume the thread pool version to be faster.
Thanks again,
- Lars
________________________________________
From: Benjamin Beier [benjamin@desaster-games.com]
Sent: Thursday, October 24, 2013 19:03
To: user@thrift.apache.org
Subject: Re: Documentation, differences multithreaded server and non-blocking server
On 10/24/2013 10:36 AM, Lars Benner wrote:
> I have at the moment a simple, single threaded server running in C++ and I figured out, I can have only a single client connection at a time. Ok this did not really surprise me.
>
> Since I need to multiple client/server connections at the same time, I assume I have use either a multithreaded or a non-blocking server. Therefore, I would like to know, what the differences between a multithreaded server and a non-blocking server are. I have a general understanding of these concepts. But I do not know, how they are implemented in thrift and what for implications these different concepts have for my server functionality implementation and the client usage.
>
> So exist some documentation, which I couldn't find, describing this? Or can somebody give me an overview from 10,000 ft?
>
> Thanks a lot,
> - Lars
I am new to thrift myself, but from what i understand, it works as follows:
TThreadedServer:
Each client connection is handled by one thread, until all threads
are in use.
With 8 threads you can handle 8 concurrent client connections.
Every time a client connects to the server a new thread is created
and destroyed again at disconnection.
TThreadPoolServer:
Each client connection is handled by one thread, until all threads
of the pool are in use.
With a pool size of 8 threads you can handle 8 concurrent client
connections.
Threads are only create once and reused afterwards.
TNonblockingServer:
The number of possible client connections isn't limited anymore.
All threads of the pool are processing client request simultaneously.
On the client side requests sill seem to be blocking, but on the
server side they are handled non-blocking.
TNonblockingServer + AsyncClient:
Same behavior on the server side, but client request return
immediately and a given callback method is executed as soon as it is
processed.
Correct me if i am wrong... just wanted to help... :)
Regards,
Benjamin
Re: Documentation, differences multithreaded server and non-blocking
server
Posted by Benjamin Beier <be...@desaster-games.com>.
On 10/24/2013 10:36 AM, Lars Benner wrote:
> I have at the moment a simple, single threaded server running in C++ and I figured out, I can have only a single client connection at a time. Ok this did not really surprise me.
>
> Since I need to multiple client/server connections at the same time, I assume I have use either a multithreaded or a non-blocking server. Therefore, I would like to know, what the differences between a multithreaded server and a non-blocking server are. I have a general understanding of these concepts. But I do not know, how they are implemented in thrift and what for implications these different concepts have for my server functionality implementation and the client usage.
>
> So exist some documentation, which I couldn't find, describing this? Or can somebody give me an overview from 10,000 ft?
>
> Thanks a lot,
> - Lars
I am new to thrift myself, but from what i understand, it works as follows:
TThreadedServer:
Each client connection is handled by one thread, until all threads
are in use.
With 8 threads you can handle 8 concurrent client connections.
Every time a client connects to the server a new thread is created
and destroyed again at disconnection.
TThreadPoolServer:
Each client connection is handled by one thread, until all threads
of the pool are in use.
With a pool size of 8 threads you can handle 8 concurrent client
connections.
Threads are only create once and reused afterwards.
TNonblockingServer:
The number of possible client connections isn't limited anymore.
All threads of the pool are processing client request simultaneously.
On the client side requests sill seem to be blocking, but on the
server side they are handled non-blocking.
TNonblockingServer + AsyncClient:
Same behavior on the server side, but client request return
immediately and a given callback method is executed as soon as it is
processed.
Correct me if i am wrong... just wanted to help... :)
Regards,
Benjamin