트위터는 2013년부터

루비온 레일즈의 모노리식 구조에서 SOA(service oriented architecture)로 점진적인 변화를 주고 있다.

현재는 99.9%로 레일즈를 걷어냈고 스칼라(finagle, finatra)를 사용해 개발하고 있다.

 

 

https://blog.twitter.com/engineering/en_us/a/2013/new-tweets-per-second-record-and-how.html

 

New Tweets per second record, and how!

New Tweets per second record, and how!

blog.twitter.com

https://blog.twitter.com/engineering/en_us/a/2011/finagle-a-protocol-agnostic-rpc-system.html

 

Finagle: A Protocol-Agnostic RPC System

Finagle: A Protocol-Agnostic RPC System

blog.twitter.com

 

 

thrift idl은 다음과 같다. scrooge를 사용해서 약간 특이하게 되어 있다. 

namespace java idl.thrift
#@namespace scala idl.thrift


service HelloService {
  string hi();
}

finangle server는 간단하게 아래와 같이 구현할 수 있다.

 

package example

import com.twitter.finagle.Thrift
import com.twitter.util.{Await, Future}
import idl.thrift.HelloService

object Server {

  class HelloImpl extends HelloService.MethodPerEndpoint {
    def hi(): Future[String] = Future.value("Hello World")
  }

  val server = Thrift.server.serveIface("localhost:8080", new HelloImpl)

  def main(args: Array[String]): Unit = {
    println("Starting thrift server(8080)...")
    Await.result(server)
  }
}

 

 

클라이언트는 다음과 같이 사용할 수 있다. 

package client

import com.twitter.finagle.Thrift
import com.twitter.util.Await
import idl.thrift.HelloService

object ScalaEchoClient {
  def main(args: Array[String]): Unit = {
    println("Starting Scala client...")

    val methodPerEndpoint: HelloService.MethodPerEndpoint =
      Thrift.client.build[HelloService.MethodPerEndpoint]("localhost:8080")

    val response = methodPerEndpoint.hi()
    response onSuccess {
      result: String => println(result)
    }

    Await.result(response)
  }

 

Posted by '김용환'
,