You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Jeff Nelson <jt...@gmail.com> on 2015/04/02 18:02:18 UTC

TFramedTransport vs TIOStreamTransport

Can someone give me a quick primer on what advantages there are, if any, for using TFramedTransport over TIOStreamTransport in a Java server?

Sent from my iPhone

Re: TFramedTransport vs TIOStreamTransport

Posted by Jeff Nelson <jt...@gmail.com>.
Very helpful, thank you so much!

Sent from my iPhone




On Thu, Apr 2, 2015 at 10:57 AM -0700, "Randy Abernethy" <ra...@gmail.com> wrote:










Hi Jeff,

You are correct, in Java with TThreadPoolServer I would just use TSocket.
In Java TSocket extends TIOStream, so you would have to do surgery to
separate them. The TFramedTransport can be layered on top of a TSocket but
adds no value (only overhead) unless you are using a nonblocking server.

The distinction here is that some transports are end points, they write to
devices or external systems. Other transports are layered transports, they
write to other transports.

TSocket is an end point transport. It exposes the TTransport interface but
writes to a device (in the case of TSocket, the device is the socket and it
writes to it through the IOStream, which provides internal buffering).
There are pipe, file and memory end points as well. You can not layer end
points.

Layered transports like TFramedTransport sit on top of end points or other
layers to add some pre and/or post processing to the bytes written/read.

-Randy

On Thu, Apr 2, 2015 at 10:29 AM, Jeff Nelson  wrote:

> Thanks, this is very helpful. So, if you're using a blocking server
> (TThreadPoolServer) there is no performance benefit to using
> TFramedTransport vs TSocket (which uses TIOStream) or vice versa?
>
> Sent from my iPhone
>
>
>
>
> On Thu, Apr 2, 2015 at 10:25 AM -0700, "Randy Abernethy" <
> randy.abernethy@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
> Hi Jeff,
>
> The TFramedTransport adds a 4 byte frame size to the front of every RPC
> message. This is used by nonblocking servers to pass the messages to worker
> threads without deserializing them first. So if you are not using a
> nonblocking server you do not need framing and if you are using nonblocking
> servers you must use framing.
>
> TFramedTransport is a layered transport, it looks like a TTransport to
> clients but depends on another TTransport below it. TIOStream is an
> adapter. It takes Java I/O streams and makes them look like transports.
> Again if you don't need it you should not probably use it.
>
> The most common Java transport, I think, is TSocket. TSocket allows you to
> make a TCP connection and it uses TIOStream to implement the stream I/O.
> Because of this stream usage, TSocket does not need a buffer (some
> languages have a TBufferedTransport use to add buffering over a raw
> socket).
>
> Hope this helps,
> Randy
>
> On Thu, Apr 2, 2015 at 9:02 AM, Jeff Nelson  wrote:
>
> > Can someone give me a quick primer on what advantages there are, if any,
> > for using TFramedTransport over TIOStreamTransport in a Java server?
> >
> > Sent from my iPhone
>

Re: TFramedTransport vs TIOStreamTransport

Posted by Randy Abernethy <ra...@gmail.com>.
Hi Jeff,

You are correct, in Java with TThreadPoolServer I would just use TSocket.
In Java TSocket extends TIOStream, so you would have to do surgery to
separate them. The TFramedTransport can be layered on top of a TSocket but
adds no value (only overhead) unless you are using a nonblocking server.

The distinction here is that some transports are end points, they write to
devices or external systems. Other transports are layered transports, they
write to other transports.

TSocket is an end point transport. It exposes the TTransport interface but
writes to a device (in the case of TSocket, the device is the socket and it
writes to it through the IOStream, which provides internal buffering).
There are pipe, file and memory end points as well. You can not layer end
points.

Layered transports like TFramedTransport sit on top of end points or other
layers to add some pre and/or post processing to the bytes written/read.

-Randy

On Thu, Apr 2, 2015 at 10:29 AM, Jeff Nelson <jt...@gmail.com> wrote:

> Thanks, this is very helpful. So, if you're using a blocking server
> (TThreadPoolServer) there is no performance benefit to using
> TFramedTransport vs TSocket (which uses TIOStream) or vice versa?
>
> Sent from my iPhone
>
>
>
>
> On Thu, Apr 2, 2015 at 10:25 AM -0700, "Randy Abernethy" <
> randy.abernethy@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
> Hi Jeff,
>
> The TFramedTransport adds a 4 byte frame size to the front of every RPC
> message. This is used by nonblocking servers to pass the messages to worker
> threads without deserializing them first. So if you are not using a
> nonblocking server you do not need framing and if you are using nonblocking
> servers you must use framing.
>
> TFramedTransport is a layered transport, it looks like a TTransport to
> clients but depends on another TTransport below it. TIOStream is an
> adapter. It takes Java I/O streams and makes them look like transports.
> Again if you don't need it you should not probably use it.
>
> The most common Java transport, I think, is TSocket. TSocket allows you to
> make a TCP connection and it uses TIOStream to implement the stream I/O.
> Because of this stream usage, TSocket does not need a buffer (some
> languages have a TBufferedTransport use to add buffering over a raw
> socket).
>
> Hope this helps,
> Randy
>
> On Thu, Apr 2, 2015 at 9:02 AM, Jeff Nelson  wrote:
>
> > Can someone give me a quick primer on what advantages there are, if any,
> > for using TFramedTransport over TIOStreamTransport in a Java server?
> >
> > Sent from my iPhone
>

Re: TFramedTransport vs TIOStreamTransport

Posted by Jeff Nelson <jt...@gmail.com>.
Thanks, this is very helpful. So, if you're using a blocking server (TThreadPoolServer) there is no performance benefit to using TFramedTransport vs TSocket (which uses TIOStream) or vice versa?

Sent from my iPhone




On Thu, Apr 2, 2015 at 10:25 AM -0700, "Randy Abernethy" <ra...@gmail.com> wrote:










Hi Jeff,

The TFramedTransport adds a 4 byte frame size to the front of every RPC
message. This is used by nonblocking servers to pass the messages to worker
threads without deserializing them first. So if you are not using a
nonblocking server you do not need framing and if you are using nonblocking
servers you must use framing.

TFramedTransport is a layered transport, it looks like a TTransport to
clients but depends on another TTransport below it. TIOStream is an
adapter. It takes Java I/O streams and makes them look like transports.
Again if you don't need it you should not probably use it.

The most common Java transport, I think, is TSocket. TSocket allows you to
make a TCP connection and it uses TIOStream to implement the stream I/O.
Because of this stream usage, TSocket does not need a buffer (some
languages have a TBufferedTransport use to add buffering over a raw socket).

Hope this helps,
Randy

On Thu, Apr 2, 2015 at 9:02 AM, Jeff Nelson  wrote:

> Can someone give me a quick primer on what advantages there are, if any,
> for using TFramedTransport over TIOStreamTransport in a Java server?
>
> Sent from my iPhone

Re: TFramedTransport vs TIOStreamTransport

Posted by Randy Abernethy <ra...@gmail.com>.
Hi Jeff,

The TFramedTransport adds a 4 byte frame size to the front of every RPC
message. This is used by nonblocking servers to pass the messages to worker
threads without deserializing them first. So if you are not using a
nonblocking server you do not need framing and if you are using nonblocking
servers you must use framing.

TFramedTransport is a layered transport, it looks like a TTransport to
clients but depends on another TTransport below it. TIOStream is an
adapter. It takes Java I/O streams and makes them look like transports.
Again if you don't need it you should not probably use it.

The most common Java transport, I think, is TSocket. TSocket allows you to
make a TCP connection and it uses TIOStream to implement the stream I/O.
Because of this stream usage, TSocket does not need a buffer (some
languages have a TBufferedTransport use to add buffering over a raw socket).

Hope this helps,
Randy

On Thu, Apr 2, 2015 at 9:02 AM, Jeff Nelson <jt...@gmail.com> wrote:

> Can someone give me a quick primer on what advantages there are, if any,
> for using TFramedTransport over TIOStreamTransport in a Java server?
>
> Sent from my iPhone