Pro Yearly is on sale from $80 to $50! »

Netty at Twitter with Finagle

Netty at Twitter with Finagle

A minimal set of slides used to present an overview of Finagle, an RPC library built atop Netty

2a8171b6c385b865e30bf070cf588329?s=128

Evan Meagher

July 29, 2014
Tweet

Transcript

  1. @TwitterAds | Confidential Evan Meagher (@evanm) 7/28/14 Netty at Twitter

    with Finagle
  2. @Twitter 2 Agenda Why and what is Finagle? What does

    it do? What are we working on now?
  3. @Twitter 3 What is Finagle?

  4. @Twitter 4 An open source, protocol-agnostic, asynchronous RPC library for

    the JVM
  5. @Twitter 5 Why did we build Finagle?

  6. @Twitter 6 In the beginning…

  7. @Twitter 7 Monolithic Rails app MySQL

  8. @Twitter 8 Monolithic Rails app MySQL Monolithic Rails app MySQL

    Monolithic Rails app MySQL … Monolithic Rails app MySQL … …
  9. @Twitter 9

  10. @Twitter 10

  11. @Twitter 11 What is Finagle?

  12. @Twitter 12 An open source, protocol-agnostic, asynchronous RPC library for

    the JVM
  13. @Twitter 13 An open source, protocol-agnostic, asynchronous RPC library for

    the JVM
  14. @Twitter 14 An open source, protocol-agnostic, asynchronous RPC library for

    the JVM
  15. @Twitter 15 An open source, protocol-agnostic, asynchronous RPC library for

    the JVM
  16. @Twitter 16 An open source, protocol-agnostic, asynchronous RPC library for

    the JVM
  17. @Twitter 17 What does Finagle do?

  18. @Twitter 18 Standardizes the edges in a “boxes and arrows”

    network diagram
  19. @Twitter 19 [1] http://monkey.org/~marius/funsrv.pdf

  20. @Twitter 20 type Service[Req, Rep] = Req => Future[Rep]

  21. @Twitter 21 type Service[Req, Rep] = Req => Future[Rep] Server

    Client Req Future[Rep]
  22. @Twitter 22 A contrived example

  23. @Twitter 23 val server = new Service[HttpReq, HttpRep] { def

    apply(req: HttpReq): Future[HttpRep] = Future.value(HttpRep(Status.OK, req.body)) } ! Http.serve(":80", server)
  24. @Twitter 24 val client: Service[HttpReq, HttpRep] = Http.newService(“twitter.com:80") ! val

    futureResponse: Future[HttpRep] = client(HttpReq(“/")) ! futureResponse map { response => println(response) }
  25. @Twitter 25 Now let’s say you need to authenticate requests

  26. @Twitter 26 type Service[Req, Rep] = Req => Future[Rep] !

    type Filter[Req, Rep] = (Req, Service[Req, Rep]) => Future[Rep]
  27. @Twitter 27 type Service[Req, Rep] = Req => Future[Rep] !

    type Filter[Req, Rep] = (Req, Service[Req, Rep]) => Future[Rep] Filter Filter Server Client
  28. @Twitter 28 def isAuthed(req: Req): Boolean val authFilter: Filter[HttpReq, HttpRes]

    = { (req, svc) => if (isAuthed(req)) svc(req) else Future.exception(new AccessDenied) } ! val authedServer: Service[HttpReq, HttpRes] = authFilter andThen server
  29. @Twitter 29 val instrumentedServer = authFilter andThen traceRequest andThen recordStats

    andThen server
  30. @Twitter 30 What are we working on now?

  31. @Twitter 31 Service discovery See the “Names” page on the

    Finagle user guide: http://twitter.github.io/finagle/guide/Names.html ! val client = Http.newService( “zk!myzkhost.mycompany.com:2181!/my/zk/path” )
  32. @Twitter 32 Load balancing

  33. @Twitter 33 Request multiplexing See the “Protocols” page on the

    Finagle user guide: http://twitter.github.io/finagle/guide/Protocols.html
  34. @Twitter 34 Tail-latency optimization

  35. @TwitterAds | Confidential Thanks! github.com/twitter/finagle @finagle @evanm