SlideShare a Scribd company logo
Distributed & highly available server
applications in Java and Scala
Max Alexejev, Aleksei Kornev
JavaOne Moscow 2013
24 April 2013
What is talkbits?
Architecture
by Max Alexejev
Lightweight SOA
Key principles
•S1, S2 - edge services
•Each service is 0..1 servers and
0..N clients built together
•No special "broker" services
•All services are stateless
•All instances are equal
What about state?
State is kept is specialized
distributed systems and fronted
by specific services.
Example follows...
Case study: Talkbits backend
Recursive call
Requirements for a distrubuted RPC system
Must have and nice to have
•Elastic and reliable discovery - schould handle nodes brought up and
shut down transparently and not be a SPOF itself
•Support for N-N topology of client and server instances
•Disconnect detection and transparent reconnects
•Fault tolerance - for example, by retries to remaining instances where
called instance goes down
•Clients backoff built-in - i.e., clients should not overload servers when
load spikes - as far as possible
•Configurable load distribution - i.e., which server instance to call for
this specific request
•Configurable networking layer - keepalives & heartbeats, timeouts,
connection pools etc.)
•Distributed tracing facilities
•Portability among different platforms
•Distributed stack traces for exceptions
•Transactions
Key principles to be lightweight and get rid of architectural waste
•Java SE
•No containers. Even servlet containers are light and built-in
•Standalone applications: unified configuration, deployment, metrics,
logging, single development framework - more on this later
•All launched istances are equal and process requests - no "special"
nodes or "active-standby" patterns
•Minimal dependencies and JAR size
•Minimal memory footprint
•One service - one purpose
•Highly tuned for this one purpose (app, JVM, OS, HW)
•Isolated fault domains - i.e., single datasource or external service is
fronted by one service only
No bloatware in technology stack!
"Lean" services
Finagle library
(twitter.github.io/finagle) acts
as a distributed RPC
framework.
Services are written in Java
and Scala and use Thrift
communication protocol.
Talkbits implementation choices
Apache Zookeeper (zookeeper.apache.org)
Provides reliable service discovery mechanics. Finagle has a nice built-in
integration with Zookeeper.
Finagle server: networking
Finagle is built on top of Netty - asynchronous, non-blocking TCP server.
Finagle codec
trait Codec[Req, Rep]
class ThriftClientFramedCodec(...) extends Codec[ThriftClientRequest, Array[Byte]] {
pipeline.addLast("thriftFrameCodec", new ThriftFrameCodec)
pipeline.addLast("byteEncoder", new ThriftClientChannelBufferEncoder)
pipeline.addLast("byteDecoder", new ThriftChannelBufferDecoder)
...
}
Finagle comes with ready-made codecs for
Thrift, HTTP, Memcache, Kestrel, HTTP streaming.
Finagle services and filters
// Service is simply a function from request to a future of response.
trait Service[Req, Rep] extends (Req => Future[Rep])
// Filter[A, B, C, D] converts a Service[C, D] to a Service[A, B].
abstract class Filter[-ReqIn, +RepOut, +ReqOut, -RepIn]
extends ((ReqIn, Service[ReqOut, RepIn]) => Future[RepOut])
abstract class SimpleFilter[Req, Rep] extends Filter[Req, Rep, Req, Rep]
// Service transformation example
val serviceWithTimeout: Service[Req, Rep] =
new RetryFilter[Req, Rep](..) andThen
new TimeoutFilter[Req, Rep](..) andThen
service
Finagle comes with
rate limiting, retries,
statistics, tracing,
uncaught exceptions
handling, timeouts and
more.
Functional composition
Given Future[A]
Sequential composition
def map[B](f: A => B): Future[B]
def flatMap[B](f: A => Future[B]): Future[B]
def rescue[B >: A](rescueException: PartialFunction[Throwable, Future[B]]): Future[B]
Concurrent composition
def collect[A](fs: Seq[Future[A]]): Future[Seq[A]]
def select[A](fs: Seq[Future[A]]): Future[(Try[A], Seq[Future[A]])]
And more
Functional composition on RPC calls
Sequential composition
val nearestChannel: Future[Channel] =
metadataClient.getUserById(uuid) flatMap {
user => geolocationClient.getNearestChannelId( user.getLocation() )
} flatMap {
channelId => metadataClient.getChannelById( channelId )
}
Concurrent composition
val userA: Future[User] = metadataClient.getUserById(“a”)
val userB: Future[User] = metadataClient.getUserById(“b”)
val userC: Future[User] = metadataClient.getUserById(“c”)
val users = Future.collect(Seq(userA, userB, userC)).get()
*All this stuff works in Java just like in Scala, but does
not look as cool.
Finagle server: threading model
You should never block worker threads in order to achieve high
performance (throughput).
For blocking IO or long compuntations, delegate to FuturePool.
val diskIoFuturePool = FuturePool(Executors.newFixedThreadPool(4))
diskIoFuturePool( { scala.Source.fromFile(..) } )
Boss thread accepts new
client connections and
binds NIO Channel to a
specific worker thread.
Worker threads perform
all client IO.
More gifts and bonuses from Finagle
In addition to all said before, Finagle has
•Load-distribution in N-N topos - HeapBalancer ("least active
connections") by default
•Client backoff strategies - comes with TruncatedBinaryBackoff
implementation
•Failure detection
•Failover/Retry
•Connection Pooling
•Distributed Tracing (Zipkin project based on Google Dapper paper)
Finagle, Thrift & Java: lessons learned
Pros
•Gives a lot out of the box
•Production-proven and stable
•Active development community
•Lots of extension points in the library
Cons
•Good for Scala, usable with Java
•Works well with Thrift and HTTP (plus trivial protocols), but lacks
support for Protobuf and other stuff
•Poor exceptions handling experience with Java (no Scala match-es)
and ugly code
•finagle-thrift is a pain (old libthrift version lock-in, Cassandra
dependencies clash, cannot return nulls, and more). All problems
avoidable thought.
•Cluster scatters and never gathers when whole Zookeeper ensemble is
Finagle: competitors & alternatives
Trending
•Akka 2.0 (Scala, OpenSource) by Typesafe
•ZeroRPC (Python & Node.js, OpenSource) by DotCloud
•RxJava (Java, OpenSource) by Netflix
Old
•JGroups (Java, OpenSource)
•JBOSS Remoting (Java, OpenSource) by JBOSS
•Spread Toolkit (C/C++, Commercial & OpenSource)
Configuration, deployment,
monitoring and logging
by Aleksei Kornev
Get stuff done...
Typical application
Architecture of talkbits service
One way to configure service, logs, metrics.
One way to package and deploy service.
One way to lunch service.
Bundled in one-jar.
One delivery unit. Contains:
Java service
In a single executable fat-jar.
Installation script
[Re]installs service on the machine,
registers it in /etc/init.d
Init.d script
Contains instructions to start, stop,
Delivery
Logging
Confuguration
•SLF4J as an API, all other libraries redirected
•Logback as a logging implementation
•Each service logs to /var/log/talkbits/... (application logs, GC logs)
•Daily rotation policy applied
•Also sent to loggly.com for aggregation, grouping etc.
Aggregation
•loggly.com
•sshfs for analyzing logs by means of linux tools such as grep, tail, less,
etc.
Aggregation alternatives
Splunk.com, Flume, Scribe, etc...
Metrics
Application metrics and health checks are implemented with CodaHale lib
(metrics.codahale.com). Codahale reports metrics via JMX.
Jolokia JVM agent (www.jolokia.org/agent/jvm.html) exposes JMX beans
via REST (JSON / HTTP), using JVMs internal HTTP server.
Monitoring agent use jolokia REST interface to fetch metrics and send
them to monitoring system.
All metrics are divided into common metrics (HW, JVM, etc) and service-
specific metrics.
Deployment
Fabric (http://fabfile.org) used for
environments provisioning and
services deployment.
Process
•Fabric script provisions new env (or
uses existing) by cluster scheme
•Amazon instances are automatically
tagged with services list (i.e.,
instance roles)
•Fabric script reads instance roles
and deploys (redeploys) appropriate
components.
Monitoring
As monitoring platform we chose Datadoghq.com. Datadog is a SaaS
which is easy to integrate into your infrastucture. Datadog agent is
opensourced and implemented in Python. There are many predefined
checksets (plugins, or integrations) for popular products out of the box -
including JVM, Cassandra, Zookeeper and ElasticSearch.
Datadog provides REST API.
Alternatives
•Nagios, Zabbix - need to have bearded admin in team. We wanted to go
SaaS and outsource infrastructure as far as possible.
•Amazon CloudWatch, LogicMonitor, ManageEngine, etc.
Process
Each service has own monitoring agent instance on a single machine. If
node has 'monitoring-agent' role in the roles tag of EC2 instance,
monitoring agent will be installed for each service on this node.
Talkbits cluster structure
QA
Max Alexejev
http://ru.linkedin.com/pub/max-alexejev/51/820/ab9
http://www.slideshare.net/MaxAlexejev/
malexejev@gmail.com
Aleksei Kornev
aleksei.kornev@gmail.com

More Related Content

What's hot (18)

PDF
Apache Kafka Architecture & Fundamentals Explained
confluent
 
PDF
Pulsar - flexible pub-sub for internet scale
Matteo Merli
 
PDF
Kafka Overview
iamtodor
 
PDF
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Chen-en Lu
 
PDF
Apache Kafka - Free Friday
Otávio Carvalho
 
PDF
October 2016 HUG: Pulsar,  a highly scalable, low latency pub-sub messaging s...
Yahoo Developer Network
 
PPTX
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
StreamNative
 
PDF
High performance messaging with Apache Pulsar
Matteo Merli
 
PPTX
Pub/Sub Messaging
Peter Hanzlik
 
PDF
Messaging With ActiveMQ
Bruce Snyder
 
PDF
Effectively-once semantics in Apache Pulsar
Matteo Merli
 
PPTX
Picking a message queue
Vladislav Kirshtein
 
PDF
Apache Kafka Introduction
Amita Mirajkar
 
PPTX
Comparing CoAP vs MQTT
kellogh
 
PPSX
Apache kafka introduction
Mohammad Mazharuddin
 
PDF
Wso2 esb 5.0.0 product release webinar
Chanaka Fernando
 
Apache Kafka Architecture & Fundamentals Explained
confluent
 
Pulsar - flexible pub-sub for internet scale
Matteo Merli
 
Kafka Overview
iamtodor
 
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Chen-en Lu
 
Apache Kafka - Free Friday
Otávio Carvalho
 
October 2016 HUG: Pulsar,  a highly scalable, low latency pub-sub messaging s...
Yahoo Developer Network
 
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
StreamNative
 
High performance messaging with Apache Pulsar
Matteo Merli
 
Pub/Sub Messaging
Peter Hanzlik
 
Messaging With ActiveMQ
Bruce Snyder
 
Effectively-once semantics in Apache Pulsar
Matteo Merli
 
Picking a message queue
Vladislav Kirshtein
 
Apache Kafka Introduction
Amita Mirajkar
 
Comparing CoAP vs MQTT
kellogh
 
Apache kafka introduction
Mohammad Mazharuddin
 
Wso2 esb 5.0.0 product release webinar
Chanaka Fernando
 

Viewers also liked (8)

PDF
Scala.io
Steve Gury
 
PDF
A sane approach to microservices
Toby Matejovsky
 
PDF
Numba Overview
stan_seibert
 
PDF
Finagle-Based Microservices at SoundCloud
Phil Calçado
 
PDF
Async Microservices with Twitter's Finagle
Vladimir Kostyukov
 
PPTX
Cyansible
Alan Norton
 
PPTX
ELK at LinkedIn - Kafka, scaling, lessons learned
Tin Le
 
PDF
Functional Programming Patterns (BuildStuff '14)
Scott Wlaschin
 
Scala.io
Steve Gury
 
A sane approach to microservices
Toby Matejovsky
 
Numba Overview
stan_seibert
 
Finagle-Based Microservices at SoundCloud
Phil Calçado
 
Async Microservices with Twitter's Finagle
Vladimir Kostyukov
 
Cyansible
Alan Norton
 
ELK at LinkedIn - Kafka, scaling, lessons learned
Tin Le
 
Functional Programming Patterns (BuildStuff '14)
Scott Wlaschin
 
Ad

Similar to Distributed & Highly Available server applications in Java and Scala (20)

PDF
Java one2013
Aleksei Kornev
 
PPTX
Exploring Twitter's Finagle technology stack for microservices
💡 Tomasz Kogut
 
KEY
Building Distributed Systems in Scala
Alex Payne
 
PDF
Talkbits service architecture and deployment
Open-IT
 
PDF
SOA with Thrift and Finagle
Luka Zakrajšek
 
PDF
Twitter Finagle
Knoldus Inc.
 
PPTX
Performance of Microservice Frameworks on different JVMs
Maarten Smeets
 
PPTX
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
Javier García Magna
 
PDF
Microservices - opportunities, dilemmas and problems
Łukasz Sowa
 
PPTX
Tef con2016 (1)
ggarber
 
PPTX
High Performance RPC with Finagle
Samir Bessalah
 
PPT
Farms, Fabrics and Clouds
Steve Loughran
 
PDF
"JBoss clustering solutions Mission Critical Enterprise" by Mircea Markus @ e...
eLiberatica
 
PPTX
Scalable game-servers-tgc
Ashkan Saeedi Mazdeh
 
PDF
Architecting for failure - Why are distributed systems hard?
Markus Eisele
 
PDF
Voldemort Nosql
elliando dias
 
ODP
An introduction to Apache Thrift
Mike Frampton
 
PDF
NetflixOSS Open House Lightning talks
Ruslan Meshenberg
 
PPTX
Designing Fault Tolerant Microservices
Orkhan Gasimov
 
PPTX
Performance of Microservice frameworks on different JVMs
Maarten Smeets
 
Java one2013
Aleksei Kornev
 
Exploring Twitter's Finagle technology stack for microservices
💡 Tomasz Kogut
 
Building Distributed Systems in Scala
Alex Payne
 
Talkbits service architecture and deployment
Open-IT
 
SOA with Thrift and Finagle
Luka Zakrajšek
 
Twitter Finagle
Knoldus Inc.
 
Performance of Microservice Frameworks on different JVMs
Maarten Smeets
 
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
Javier García Magna
 
Microservices - opportunities, dilemmas and problems
Łukasz Sowa
 
Tef con2016 (1)
ggarber
 
High Performance RPC with Finagle
Samir Bessalah
 
Farms, Fabrics and Clouds
Steve Loughran
 
"JBoss clustering solutions Mission Critical Enterprise" by Mircea Markus @ e...
eLiberatica
 
Scalable game-servers-tgc
Ashkan Saeedi Mazdeh
 
Architecting for failure - Why are distributed systems hard?
Markus Eisele
 
Voldemort Nosql
elliando dias
 
An introduction to Apache Thrift
Mike Frampton
 
NetflixOSS Open House Lightning talks
Ruslan Meshenberg
 
Designing Fault Tolerant Microservices
Orkhan Gasimov
 
Performance of Microservice frameworks on different JVMs
Maarten Smeets
 
Ad

Recently uploaded (20)

PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 

Distributed & Highly Available server applications in Java and Scala

  • 1. Distributed & highly available server applications in Java and Scala Max Alexejev, Aleksei Kornev JavaOne Moscow 2013 24 April 2013
  • 4. Lightweight SOA Key principles •S1, S2 - edge services •Each service is 0..1 servers and 0..N clients built together •No special "broker" services •All services are stateless •All instances are equal What about state? State is kept is specialized distributed systems and fronted by specific services. Example follows...
  • 5. Case study: Talkbits backend Recursive call
  • 6. Requirements for a distrubuted RPC system Must have and nice to have •Elastic and reliable discovery - schould handle nodes brought up and shut down transparently and not be a SPOF itself •Support for N-N topology of client and server instances •Disconnect detection and transparent reconnects •Fault tolerance - for example, by retries to remaining instances where called instance goes down •Clients backoff built-in - i.e., clients should not overload servers when load spikes - as far as possible •Configurable load distribution - i.e., which server instance to call for this specific request •Configurable networking layer - keepalives & heartbeats, timeouts, connection pools etc.) •Distributed tracing facilities •Portability among different platforms •Distributed stack traces for exceptions •Transactions
  • 7. Key principles to be lightweight and get rid of architectural waste •Java SE •No containers. Even servlet containers are light and built-in •Standalone applications: unified configuration, deployment, metrics, logging, single development framework - more on this later •All launched istances are equal and process requests - no "special" nodes or "active-standby" patterns •Minimal dependencies and JAR size •Minimal memory footprint •One service - one purpose •Highly tuned for this one purpose (app, JVM, OS, HW) •Isolated fault domains - i.e., single datasource or external service is fronted by one service only No bloatware in technology stack! "Lean" services
  • 8. Finagle library (twitter.github.io/finagle) acts as a distributed RPC framework. Services are written in Java and Scala and use Thrift communication protocol. Talkbits implementation choices Apache Zookeeper (zookeeper.apache.org) Provides reliable service discovery mechanics. Finagle has a nice built-in integration with Zookeeper.
  • 9. Finagle server: networking Finagle is built on top of Netty - asynchronous, non-blocking TCP server. Finagle codec trait Codec[Req, Rep] class ThriftClientFramedCodec(...) extends Codec[ThriftClientRequest, Array[Byte]] { pipeline.addLast("thriftFrameCodec", new ThriftFrameCodec) pipeline.addLast("byteEncoder", new ThriftClientChannelBufferEncoder) pipeline.addLast("byteDecoder", new ThriftChannelBufferDecoder) ... } Finagle comes with ready-made codecs for Thrift, HTTP, Memcache, Kestrel, HTTP streaming.
  • 10. Finagle services and filters // Service is simply a function from request to a future of response. trait Service[Req, Rep] extends (Req => Future[Rep]) // Filter[A, B, C, D] converts a Service[C, D] to a Service[A, B]. abstract class Filter[-ReqIn, +RepOut, +ReqOut, -RepIn] extends ((ReqIn, Service[ReqOut, RepIn]) => Future[RepOut]) abstract class SimpleFilter[Req, Rep] extends Filter[Req, Rep, Req, Rep] // Service transformation example val serviceWithTimeout: Service[Req, Rep] = new RetryFilter[Req, Rep](..) andThen new TimeoutFilter[Req, Rep](..) andThen service Finagle comes with rate limiting, retries, statistics, tracing, uncaught exceptions handling, timeouts and more.
  • 11. Functional composition Given Future[A] Sequential composition def map[B](f: A => B): Future[B] def flatMap[B](f: A => Future[B]): Future[B] def rescue[B >: A](rescueException: PartialFunction[Throwable, Future[B]]): Future[B] Concurrent composition def collect[A](fs: Seq[Future[A]]): Future[Seq[A]] def select[A](fs: Seq[Future[A]]): Future[(Try[A], Seq[Future[A]])] And more
  • 12. Functional composition on RPC calls Sequential composition val nearestChannel: Future[Channel] = metadataClient.getUserById(uuid) flatMap { user => geolocationClient.getNearestChannelId( user.getLocation() ) } flatMap { channelId => metadataClient.getChannelById( channelId ) } Concurrent composition val userA: Future[User] = metadataClient.getUserById(“a”) val userB: Future[User] = metadataClient.getUserById(“b”) val userC: Future[User] = metadataClient.getUserById(“c”) val users = Future.collect(Seq(userA, userB, userC)).get() *All this stuff works in Java just like in Scala, but does not look as cool.
  • 13. Finagle server: threading model You should never block worker threads in order to achieve high performance (throughput). For blocking IO or long compuntations, delegate to FuturePool. val diskIoFuturePool = FuturePool(Executors.newFixedThreadPool(4)) diskIoFuturePool( { scala.Source.fromFile(..) } ) Boss thread accepts new client connections and binds NIO Channel to a specific worker thread. Worker threads perform all client IO.
  • 14. More gifts and bonuses from Finagle In addition to all said before, Finagle has •Load-distribution in N-N topos - HeapBalancer ("least active connections") by default •Client backoff strategies - comes with TruncatedBinaryBackoff implementation •Failure detection •Failover/Retry •Connection Pooling •Distributed Tracing (Zipkin project based on Google Dapper paper)
  • 15. Finagle, Thrift & Java: lessons learned Pros •Gives a lot out of the box •Production-proven and stable •Active development community •Lots of extension points in the library Cons •Good for Scala, usable with Java •Works well with Thrift and HTTP (plus trivial protocols), but lacks support for Protobuf and other stuff •Poor exceptions handling experience with Java (no Scala match-es) and ugly code •finagle-thrift is a pain (old libthrift version lock-in, Cassandra dependencies clash, cannot return nulls, and more). All problems avoidable thought. •Cluster scatters and never gathers when whole Zookeeper ensemble is
  • 16. Finagle: competitors & alternatives Trending •Akka 2.0 (Scala, OpenSource) by Typesafe •ZeroRPC (Python & Node.js, OpenSource) by DotCloud •RxJava (Java, OpenSource) by Netflix Old •JGroups (Java, OpenSource) •JBOSS Remoting (Java, OpenSource) by JBOSS •Spread Toolkit (C/C++, Commercial & OpenSource)
  • 17. Configuration, deployment, monitoring and logging by Aleksei Kornev
  • 20. Architecture of talkbits service One way to configure service, logs, metrics. One way to package and deploy service. One way to lunch service. Bundled in one-jar.
  • 21. One delivery unit. Contains: Java service In a single executable fat-jar. Installation script [Re]installs service on the machine, registers it in /etc/init.d Init.d script Contains instructions to start, stop, Delivery
  • 22. Logging Confuguration •SLF4J as an API, all other libraries redirected •Logback as a logging implementation •Each service logs to /var/log/talkbits/... (application logs, GC logs) •Daily rotation policy applied •Also sent to loggly.com for aggregation, grouping etc. Aggregation •loggly.com •sshfs for analyzing logs by means of linux tools such as grep, tail, less, etc. Aggregation alternatives Splunk.com, Flume, Scribe, etc...
  • 23. Metrics Application metrics and health checks are implemented with CodaHale lib (metrics.codahale.com). Codahale reports metrics via JMX. Jolokia JVM agent (www.jolokia.org/agent/jvm.html) exposes JMX beans via REST (JSON / HTTP), using JVMs internal HTTP server. Monitoring agent use jolokia REST interface to fetch metrics and send them to monitoring system. All metrics are divided into common metrics (HW, JVM, etc) and service- specific metrics.
  • 24. Deployment Fabric (http://fabfile.org) used for environments provisioning and services deployment. Process •Fabric script provisions new env (or uses existing) by cluster scheme •Amazon instances are automatically tagged with services list (i.e., instance roles) •Fabric script reads instance roles and deploys (redeploys) appropriate components.
  • 25. Monitoring As monitoring platform we chose Datadoghq.com. Datadog is a SaaS which is easy to integrate into your infrastucture. Datadog agent is opensourced and implemented in Python. There are many predefined checksets (plugins, or integrations) for popular products out of the box - including JVM, Cassandra, Zookeeper and ElasticSearch. Datadog provides REST API. Alternatives •Nagios, Zabbix - need to have bearded admin in team. We wanted to go SaaS and outsource infrastructure as far as possible. •Amazon CloudWatch, LogicMonitor, ManageEngine, etc. Process Each service has own monitoring agent instance on a single machine. If node has 'monitoring-agent' role in the roles tag of EC2 instance, monitoring agent will be installed for each service on this node.

Editor's Notes

  • #5: Service is 0..1 RPC server and 0..N RPC clients built together No special "broker" nodes Services are all stateless. +Write something about state
  • #12: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm
  • #13: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm
  • #14: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm
  • #15: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm
  • #16: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm
  • #17: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm
  • #20: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm
  • #21: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text (left) Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 12cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) 3. Picture (right) Size: 12,96cm x 12cm, no outer line Position: horizontal 13cm / vertical 4,04cm LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm
  • #22: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text (left) Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 12cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) 3. Picture (right) Size: 12,96cm x 12cm, no outer line Position: horizontal 13cm / vertical 4,04cm LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm
  • #23: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm
  • #24: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm
  • #25: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm
  • #26: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm
  • #27: Title (max. 1 lines) Shape Size: 2,7cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 1cm Alignment: top left corner Text Font: Helvetica Neue Bold, 40pt, single spacing RGB: 255 / 153 / 51 Alignment: left No autofit (text-form) 2. Text Shape (don ’ t meet the white space of the logo at the bottom of the slide!) Size: 13cm x 23,5cm / no outer line Position: horizontal 0,6cm / vertical 4,04cm Alignment: top left corner Font (regular) Font: Helvetica Neue Regular, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (bold) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 53 / 53 / 53 Alignment: left Paragraph spacing: after 4,8pt / 12pt Font (highlight) Font: Helvetica Neue Bold, 20pt, single spacing RGB: 0 / 153 / 153 Alignment: left Paragraph spacing: after 4,8pt / 12pt No autofit (text-form) LOGO (make sure that no text meets the white space on the left side of the logo!) Size: 1cm x 4cm Position: horizontal: 21,06cm / vertical: 17,3cm