title: Apache Thrift: Server with sync and async methods, it is possible?
body: <p>I am trying to implement a twitter like service with client using java. I am using Apache thrift for RPC calls. The service uses a key-value store. I am trying to make the service fault-tolerant along with consistency and data-replication in the key-value store.</p>
  
  <blockquote>
    <p>For eg: suppose at a time, there are 10 servers running with id
    S1,S2,S3 etc. and one client calls put(key,value) on S1, now S1 saves
    this value and calls a RPC put(key,value) on all the remaining servers
    for data-replication. I want the server method to save and return
    success to client and also  start a thread with async calls on the
    remaining 9 servers so that the client is not blocked during
    replication.</p>
  </blockquote>
  
  <p>The auto generated code has Iface and AsyncIface and I have currently implemented the Iface in a ServerHandler class. </p>
  
  <p>My goal is to expose a backend server to the client and have normal (blocking) calls between a client and a server and async calls between servers. There will be multiple client-server pairs running at a time.</p>
  
  <p>I understand, the data-replication model is crude but I am trying to learn distributed systems.</p>
  
  <p>Can someone please help me with an example on how I can achieve this.</p>
  
  <blockquote>
    <p>Also, if you think my design is flawed and there are better ways in
    which I can achieve data-replication using Apache Thrift please do
    point out.</p>
  </blockquote>
  
  <p>Thank You.</p>