Giter Club home page Giter Club logo

servkeeper's Introduction

servkeeper logo

Microservice Curator Server and Architecture

http://servkeeper.info

Servkeeper chosen as sustainable platform for the Kuaray Project!!

Kuaray Logo

Can you imagine how difficult it must be to efficiently deploy micro services with elastic scalability, continuous delivery and active monitoring?

  • How will you scale up, down?
  • How will you manage multiple instances?

ServKeeper is the answer to your problem!

Using the champion formula:

  • Apache ZooKeeper for coordinating distributed services;
  • Docker, to climb LXC containers on demand;
  • Apache Curator, to facilitate the use of ZooKeeper;
  • Jenkins, to deploy and verify instances.

What servkeeper do?

Well, I think the picture explains better:

Image of architecture

ServKeeper controls and coordinates micro services instances.

You configure ServKeeper to "watch" some micro service. It then takes care of scalling up (creating more instances, when needed), scalling down (remove some instances when needed), and check every instance.

It uses Zookeeper (via Apache Curator) to register instances. When a User needs an instance, he asks Zookeper (via Apache Curator) and get one address (it uses Round robin).

ServKeeper runs the instances on a Docker environment.

So many projects...

Ok, let me explain that:

  • servkeeper : The Micro services curator REST server;
  • ServiceClient : The API for micro services. They use it to increment the shared request counter;
  • signature : A micro service sample.

Using ServKeeper:

Build and run the server. It has some REST routes:

  • ../servkeeper/requests : Show the total requests received by all services instances;
  • ../servkeper/stopall : Stop all services instances, and removes them from Docker and Zookeeper;
  • ../servkeeper/stopserver : Stop the ServKeeper REST server;
  • ../servkeeper/supervise : Run a supervisation over all micro services instances. Deletes "trashed" instances, verifies the shared request counter, and scales up or down the number of instances. This must be invoked periodically;
  • ../servkeeper/getinstance : Return one of the instances, by making a request to Zookeeper. You don't need to use it from the server, and you can query zookeeper instead. It is just a convenience method;
  • ../servkeeper/setcounter?value= : Set the shared requests counter to the provided value. Default is zero;
  • ../servkeeper/instancescount : Return the number of micro services instances, in zookeeper and in docker. They may be different if the server is scalling down;
  • ../servkeeper/start : Starts the server, booting all minimum micro services instances and reseting the shared request counter;

Configuring ServKeeper

ServKeeper is a Dropwizard Server, so, we have a "servkeeper.yml" file, that controls it. When starting ServKeeper, the command line is:

java -jar <servkeeper.shaded.jar> server <path to servkeeper.yml file>

The YML file have this options:

# Docker host. If using boot2docker, this is the vm address:
dockerHost: "https://192.168.59.103:2376"
# Docker certificate path, to logon on docker:
dockerCertPath: "/Users/cleutonsampaio/.boot2docker/certs/boot2docker-vm"
# Zookeper host address and port:
zkHost: "localhost:2181"
# Path to where Jenkins deploy the compiled jars. This is the "appfolder", where Jenkins deploy the artifacts:
path:  "/Users/cleutonsampaio/Documents/projetos/dockertest"
# Docker image name. There must be a Dockerfile in the path, and this will be the generated image name:
imageName: "signatureimage"
# Docker container name. This is the service name, used to search for instances on Zookeeper:
containerBaseName: "signatureserver"
# Micro service source port. Must be exposed in the Docker file and will be mapped to a host port:
sourcePortNumber: 3000
# Minimum micro service instances when starting ServKeeper. They will be launched on startL
startServerInstances: 2
# Minimum micro service instances that must exist:
minServerInstances: 1
# Maximm server instances to scale up:
maxServerInstances: 5
# Maximum request limit before scalling up:
maxRequestLimit: 10
# Minimum request limit before scalling down:
minRequestLimit: 5
# Micro service test REST route:
serviceTestPah: "/signature/checkstatus"
# Array of micro service possible addresses and ports:
serverAddresses: 
  - host: "192.168.59.103"
    port: 3000
  - host: "192.168.59.103"
    port: 3001
  - host: "192.168.59.103"
    port: 3002
  - host: "192.168.59.103"
    port: 3003
  - host: "192.168.59.103"
    port: 3004
  - host: "192.168.59.103"
    port: 3005
# ServKeeper configuration:    
server:
  applicationConnectors:
  - type: http
    port: 3000
  adminConnectors:
  - type: http
    port: 3300

Jenkins Jobs:

Each project has a jenkins xml job file, at the root path. You can import this jobs to a Jenkins server using the Jenkins CLI command: java -jar jenkins-cli.jar -s http://localhost:8080/ create-job NAME (reads a xml from stin).

The Jobs are:

  • ServiceClient/serviceclient_build_install.xml : Build ServiceClient and install it on the Jenkins .m2 folder;
  • servkeeper/servkeeper_build.xml : Build ServKeeper and deploy it to the app folder.
  • servkeeper/servkeeper_run_and_start.xml : Run ServKeeper process and, after a while, send a "start" request;
  • servkeeper/servkeeper_stop_and_destroy.xml : Stop all micro services instances and stop ServKeeper process;
  • servkeeper/servkeeper_supervise.xml : Send a supervise request to ServKeeper. It must be schedulled;
  • signature/signaturejob.xml : Build and deploy the sample micro service to the app folder;

The micro service:

You can use SerKeeper to take care of any micro service, written on any language. I am using Java with Dropwizard. The ServiceClient project creates a JAR file with a class. This class can be used even in Node.js (using node-java).

If you want, you can use Apache Curator RPC Proxy, which is generated by Apache Thrift, and create a proxy for any language.

servkeeper's People

Contributors

cleuton avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.