the java microservice library

Download The Java Microservice Library

Post on 15-Jul-2015

822 views

Category:

Technology

1 download

Embed Size (px)

TRANSCRIPT

  • Java microservice development for high-speed services

    Java Microservice lib

    QBit high-speed, in-memory, services for REST, WebSocket and JSON

  • Java microservice development for high-speed services

    What is QBit? Fast queue based service engine! Services sit behind high-speed queues! Uses micro-batching and mechanical sympathy to create high speed REST

    and WebSocket microservice! Programming model looks like Spring MVC, but enables high-speed async

    model like Akka, Vertx, Reactor, but easier to program! Uses Consul or Etcd for clustering, health, cloud config, elasticity ! Has event bus that can use Kafka, 0Q, etc.! Uses JSON for wire protocol, works easily with any language over HTTP or

    WebSocket

  • Java microservice development for high-speed services

    Why QBit? Just a lib, does not take over the world! Works with Guice or Spring! Just POJOs written like Java developers write POJOs no steep

    learning curve! FAST!! Easier than reactive, worker pools, sharded services and queued

    services! Uses Consul for service discovery, WebSocket for high-speed

    messaging and REST

  • Java microservice development for high-speed services

    Architects / Developers of QBit Wrote high throughput global services for large high-traffic clients!

    F5 crushing load!! Implemented systems that took other systems 10x to 100x as many servers and 20x

    #of developers that could handle only 1/10th of the traffic ! Wrote JSON parser that is 4x faster than mainstream JSON parsers! Been there, done that for 20+ years. 100+ years building high-speed, reliable systems

    combined! Consulting with airlines, plane manufacturers, banks, commodity trading, electronic

    manufacturing, and other trading systems! Wrote services that powers some of the busiest sites on the Internet! Wrote fastest disk batcher for JVM, high-speed, distributed k/v store, in-memory db

  • Java microservice development for high-speed services

    QBit Speed - FAST! 200 M in-proc messages a second! 10M to 100M in-proc events per second! 700K to 1,000,000 RPC calls!

    Equates to 1.4M to 2M messages TPS! Using JSON! One Service Thread! One WebSocket!!

    Not uncommon to use a fraction of CPU for 2x to 10x to 100x the same performance as a traditional microservice

  • Java microservice development for high-speed services

    It all starts with a fast queue

  • Java microservice development for high-speed services

    Speed First

  • Java microservice development for high-speed services

    Service Discovery / Health Integration with Consul for

    health and event bus wiring of peers! Cloud config! Peer discovery! Health Checks! Serf/Dead mans switch,

    gossip, custom

  • Java microservice development for high-speed services

    Ease of use and simplicity too

  • Java microservice development for high-speed services

    What is QBit again? Java microservice development for high-speed services! JSON! REST! WebSocket! Services look like Spring MVC REST / JAX-RS !

    look like Spring Boot, Drop-wizard but work like Spring reactor, Akka, Go, ErLang, etc. !

    Embraces microservices! Clients can be Web, Mobile, any language that has JSON lib, HTTP lib can use

    QBit services

  • Java microservice development for high-speed services

    QBit Services WebSocket RPC, HTTP REST, and in-proc messaging! In-proc, sits behind an actor style queue, gets notified of

    queue empty, queue limit, queue init, queue start batch, etc.! Allows reduction of sending IO or calls to CPU

    intensive services in batches based on queue events! Batching calls increases system throughput through

    the system 10x, 100x, 1000x.

  • Java microservice development for high-speed services

    Key Concepts `! Queue !

    A thread managing a queue. ! supports batching. ! queue callbacks for empty, reachedLimit,

    startedBatch, idle, etc.! ServiceQueue!

    POJO (plain old Java object) behind a queue!

    receive method calls and events ! thread safe! queue callback methods! Java idioms looks like Spring MVC REST,

    JAX-RS! ServiceBundle !

    Many POJOs behind one response queue and many receive queues.

    ServiceServer ! Exposes services to REST/JSON and

    WebSocket/JSON communication! EventBus !

    send a lot of messages to services ! may be loosely coupled,! integration with others event buses

    (Kafka, STOMP, etc.)! Metrics/Stats: track in-flow, and outflow

    of messages, other metrics for performance, high-speed time-series database with REST interface!

    Meta-Data-Service: Publish track all REST JSON schemas for easy integration and use by third parties

  • Java microservice development for high-speed services

    Principles of QBit Web first (JSON, HTTP, WebSocket)! Integration via high-speed event bus (Kafka, STOMP,

    0MQ, ActiveMQ, etc.)! Embrace Mechanical Sympathy and Queue Theory to

    optimize thread hand-off, IO, and core cross talk! Less is more (be the 95% solution leave the long tail

    alone)! Fun and easy to use!

  • Java microservice development for high-speed services

    QBit Service Example Domain Object

    Service

    WebSocket HTTP support

  • Java microservice development for high-speed services

    QBit ExampleCURL-ABLE

    JSON Output

  • Java microservice development for high-speed services

    Service REST support

    Supports Request params, URI params, JSON POST, HTTP GET, etc.!

    Customize URIs using annotation! Reasonable Defaults (annotations not needed)! Methods available via annotations

  • Java microservice development for high-speed services

    QBit versus.

  • Java microservice development for high-speed services

    QBit versus Spring XXX Spring what? DI? MVC? Boot?! QBit Works easily with DI and Spring Boot! Competes against Spring MVC but has better thread

    model for high-speed services, but not all the features.! Spring MVC does a lot. QBit only does Microservices

    only! So only JSON, REST, and WebSocket! QBit Enable writing in-memory, high-speed services that

    can handle 200K TPS to 2M TPS per second single node

  • Java microservice development for high-speed services

    Akka vs. QBit Akka uses actor model! QBit uses queuing actor-like model + active objects model! Akka focuses on Queue handlers! QBit focuses on Services that look / act like Java services in

    Spring REST, JAX-RS, Java EE, and other frameworks! QBit is a Java centric model, Akka programming model is similar

    but foreign to most Java developers! QBit center of gravity is Microservices = REST, JSON, WebSocket

  • Java microservice development for high-speed services

    Akka and QBit similarities/differences Akka Typed Actor a lot like QBit Service!

    QBit Services can be exposed via REST/JSON or WebSocket/JSON!

    Both use queue events (empty, init, limit, etc.) to optimize output to IO!

    Both are fast! QBit is library and you can use / compose queues,

    services as you see fit (you could use QBit in a Spring app)

  • Java microservice development for high-speed services

    Node.js, Vertx Node.js and Vertx both use a Reactor style design pattern based on event bus.

    (QBit is reactive but using active objects not reactor.)! At first glance looks a lot like Akka or QBit! Less granularity on bus, QBit bus speed is a lot faster! Less control of when queue is idle, empty, etc. QBit has Akka like tuning which is

    critical to optimize around back pressure.! Vertx/Node.js are harder to optimize. Harder to compose other handlers. ! Great for IO and Vertx can be combined with QBit to provide missing pieces for

    Speed! Not bad. Not even close to what QBit can do! QBit works well with Vertx

  • Java microservice development for high-speed services

    How does it do?

    Faster! Easier to use! Focuses just on Micorservices! Tolerant reader, promiscuous writers! Uses RAFT and Consul for service discovery

  • Java microservice development for high-speed services

    Event Bus Overview

  • Java microservice development for high-speed services

    Event Bus QBit has a high-speed event bus modeled loosely on Vertx style

    event bus! Very fast. ! In-proc but can be integrated with others! Service methods can be invoked by calls (remote and local behind a

    queue) ! Service methods can be invoked by listening to a event bus

    channels! You can subscribe to channels or you can consume channels or both

  • Java microservice development for high-speed services

    Composable Event Bus EventBus can be composed! You can use the system event bus for in-proc service to service

    messaging! You can remote replicate events to other servers! You can tap into an event bus, and/or post events to a service

    directly for integration with 3rd party systems like Kafka, 0MQ, etc.!

    You can use Consul integration to find service peers and compose event bus that allows peers to communicate

  • Java microservice development for high-speed services

    Event Bus is an Integration point

    Event bus is an integration point! Can be easily integrated with Camel, ActiveMQ, JMS,

    Kafka, etc.! Events come in on same queue as method call! Event Bus can do remote broadcast and can discover

    peers via Consul or Etcd

  • Java microservice development for high-speed services

    QBit Event Bus

  • Java microservice development for high-speed services

    Private event bus versus System event bus Private event bus!

    https://github.com/advantageous/qbit/wiki/%5BRough-Cu