pvillega / finch-example

Finch API Server Example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Finch API Server Example

POC for REST API using Finch and friends.

API Framework

finagle/finch is a pure functional REST API framework based on Twitter's Finagle.

Finagle is an extensible RPC system for the JVM, used to construct high-concurrency servers. Finagle implements uniform client and server APIs for several protocols, and is designed for high performance and concurrency. Most of Finagle’s code is protocol agnostic, simplifying the implementation of new protocols.

Twitter use Finagle in their production and is actively developed.

Monitoring

Finagle comes with twitter/twitter-server.

TwitterServer defines a template from which servers at Twitter are built. It provides common application components such as an administrative HTTP server, tracing, stats, etc. These features are wired in correctly for use in production at Twitter.

Also check the finagle-stats subproject.

Need to implement our own tool to check logs and generate alerts.

Configuration

typesafehub/config

Logging

Finagle use twitter/util for logging, however it has some serious performance problem (Or we just dont understand it enough to tune it correctly). Since log4j with logback is industry default so we use log4j instead of twitter.util.logging.

Might want to use Scribe or Apache Flume.

Profiling

Server Process

kubernetes/heapster works great with twitter-server.

The profile can be analysised using gperftools. Just brew install gperftools if using osx.

Distributed Tracing

Zipkin

Zipkin is a distributed tracing system. It helps gather timing data needed to troubleshoot latency problems in microservice architectures. It manages both the collection and lookup of this data. Zipkin’s design is based on the Google Dapper paper.

Check the following gist for finch integration.

Currently finagle-zipkin requires Scribe and zipkin itself requires Cassandra, ElasticSearch. or at least MySQL as backend.

Process Management

Twitter server can integrate nicely with Apache Mesos.

/admin/health is still useful. By default, respond with content-body “OK”. This endpoint can be managed manually by mixing in the Lifecycle.Warmup trait with your server.

Testing

Unit Test / Integration Test

Finch/Fiangle come with a simple test framework works great with ScalaTest. However, we might need to setup DI to mock external services for unit test.

For DI solution, adamw/macwire is probably a better light-weight solution than google/guice or Spring.

Stress Test / Regression Test / Acceptance Test

API Documentation

Swagger.io would be great. However, there is currently no way to generate swagger.io documentation from Finagle. Probably need to implement our own or hand-write YAML.

About

Finch API Server Example


Languages

Language:Scala 100.0%