Search code examples
thrift

Can Apache Thrift use multiple transports for a single server?


I have a server with many lightweight methods and one heavyweight method. I can't seem to find evidence that Apache Thrift supports multiple transports for a server. What I'd like is shared memory for all but the heavyweight method and TCP/IP (distributed) for the heavyweight method. I could break it into two servers but that sort of breaks the goal of encapsulation (I think).


Solution

  • If you really mean transports - not directly. What is possible is to have the handler as a separate entity that can be re-used, e.g. with a different protocol/transport stack.

    As it sounds, the best solution in your case would indeed be to have two servers with two different protocol/transport stack, both using the same handler code, but implementing different Thrift services.

                                  +----------------+
           +----- uses ---------> | LWService      | <-------+
           |                      +----------------+         |
           |                                             implements
           |                                                 |
    +------+-----------+                               +-----+-----+
    |                  |                               |           |
    |                  |                               |           |
    |  Client          |                               | Handler   |
    |                  |                               |           |
    |                  |                               |           |
    |                  |                               |           |
    |                  |                               |           |
    |                  |                               +-----+-----+
    +------+-----------+                                     |
           |                                              implements
           |                      +----------------+         |
           +---- uses ----------> | HeavyService   | <-------+
                                  +----------------+