Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy and Serve a Thrift Service [closed]

Tags:

java

thrift

I have built a service discovery layer on top of Zookeeper for finding Thrift services in a distributed environment. I'm looking for the best way to run those services in a production environment now.

Currently, it's done by packaging a war that gets deployed to Tomcat. During the servlet instantiation, the Spring ApplicationContext is created, which creates a TThreadPoolServer inside of Tomcat.

I don't like this for a couple of reasons:

  • It makes Tomcat sort of useless, and it feels like a hack to facilitate easy deployment
  • It avoids the Tomcat thread pooling and all of the logic that has gone into figuring out the best way to distribute requests

In the process of trying to find the best strategy to handle this, I have come up with a couple of alternatives:

  • Launch thrift services as a standalone JAR (I don't like this, mainly because I now need to reinvent the logic that app container developers have spent a lot of time working out
  • Host thrift over HTTP, thus utilizing the Tomcat thread pool and logic for service requests (iffy about this one due to the - albeit minor - performance hit this will incur)
  • Use a different type of application container for hosting these services

Does anyone have suggestions on how they may have handled hosting distributed servers before. Am I better off just using HTTP inside of Tomcat?

like image 393
Colin M Avatar asked Jul 14 '13 12:07

Colin M


1 Answers

I've tried using Tomcat as a host for Thrift server and found out that it doesn't bring any additional value: all the features of servlet container (request routing, etc) aren't necessary in this scenario. On the other hand, Tomcat adds complexity and moving parts (i.e., it brings hard to resolve PermGen issues).

Using Thrift over HTTP causes significant performance impact, especially in high-load scenarios with a lot of client connections.

So I ended up with standalone Thrift services running under Supervisor Daemon (http://supervisord.org/). It makes management of distributed deployment really convenient. When it's necessary to expose Thrift API over HTTP (for example, for JS clients), we use thin async proxy implemented in vert.x (http://vertx.io/).

like image 85
Wildfire Avatar answered Sep 22 '22 13:09

Wildfire