Coder Social home page Coder Social logo

mudigal-technologies / microservices-sample Goto Github PK

View Code? Open in Web Editor NEW
361.0 14.0 335.0 12.88 MB

Sample project to create an application using microservices architecture

Home Page: http://mudigal-technologies.github.io/microservices-sample/

Java 39.10% Shell 0.52% JavaScript 14.08% HTML 25.60% CSS 1.86% TypeScript 15.73% Dockerfile 3.12%
zuul consul java dockerfile docker-compose microservices-architecture api-gateway elasticsearch logstash kibana

microservices-sample's Introduction

Microservices Sample

Build Status Docker Repository on Quay Docker Repository on Quay Docker Repository on Quay Docker Repository on Quay

Microservices Sample

What is it?

"Microservices", a trending buzz word nowadays. What problems does it solve?

Many organizations nowadays are driving the technology migrations and one of the biggest challenges is to migrate from monolithic application to micro-services based application.

This microservices-sample project demonstrates how multiple services run independently leveraging on the best microservices patterns to enable scale, performance and resilience.

https://www.youtube.com/watch?v=AYcsnuIOW2M

Use case

The sample application has two services namely service-one and service-two. Each of the service has its own database service-one-db and service-two-db respectively. During the startup of the services, it persists the service name and an auto generated UUID in its perspective database and sends the data to the RabbitMQ exchange which then broadcasts the data to all the queues based on the routing key. Every microservices listens to its own RabbitMQ queue and keeps updating the database as and when it receives the data.

Below are the screens of the application.

alt tag

Clicking on the tab's one or two the data that you see on the screen is based on the data fetched by the respective service by calling its database.

alt tag

Notice that the UUID generated for service-one which lies in service-one-db is in sync with service-two tab which is achieved by RabbitMQ (asychronous communication between microservices).

alt tag

Service Registration

During the initialization of a service, it would get registered to the discovery and registration server (which in our example is Hashicorp's Consul).

alt tag

Service Discovery

When one service (say api-gateway) needs to access a resource from another service (say service-one), all it has to do is ask discovery and registration server (Consul) to give one of the service-one's instance information.

alt tag

Architecture

Below is the architectural diagram for microservices sample project.

alt tag

Components Integrated & Tools Usage

API Gateway

Netflix Zuul is a the reverse proxy server which acts as the API Gateway for accessing the micro services behind the gateway which routes the request to the respective service. Microservice’s stay behind reverse proxy server and needs to be consumed via api gateway. The api-gateway micro service with docker profile runs on port 8080 and can be accessed by http://localhost:8080 .

Configuration done in API Gateway for Routing:

zuul:
  ignoredServices: '*'
  routes:
    one:
      path: /service-one/**
      serviceId: Service-One
    two:
      path: /service-two/**
      serviceId: Service-Two
Service registration and discovery

Registration and discovery is taken care by the HashiCorp’s Consul. During the startup of the individual services, they register with service registration service those details such as host name, port etc. by which the services can be accessed. Once the service is registered to the consul, consul checks for the health of the service by sending a heartbeat for the health check path and health check interval that has been registered with Consul. Requests to the micro-services has to be routed through api-gateway during with the api-gateway contacts discovery service to get the information required to send the request to the intended microservice.

Configuration done in micro services to register to Consul:

management:
  contextPath: /actuator

spring:
  application.name: service-one
  cloud:
    consul:
      host: consul
      port: 8500
      discovery:
        hostName: service-one
        instanceId:${spring.application.name}:${spring.application.instance_id:${random.value}}
        healthCheckPath: ${management.contextPath}/health
        healthCheckInterval: 15s

Consul management console can be accessed at http://localhost:8500/ui/

alt tag

Monitoring and vizualization

Monitoring, visualisation & management of the container in docker is done by weave scope.

Weavescope management console can be accessed at http://localhost:4040/

alt tag

Centralized logging using ELK

Logback integrated with every microservices creates application logs and send the log data to the logging server (Logstash). Logstash formats the data and send it to the indexing server (Elasticsearch). The data stored in elasticsearch server can be beautifully visualized using Kibana.

Accessing tools:

Elasticsearch: http://localhost:9200/_search?pretty

Kibana: http://localhost:5601/app/kibana

alt tag

alt tag

alt tag

alt tag

alt tag

alt tag

alt tag

alt tag

alt tag

Asynchronous microservices communication

Intercommunication between microservices happens asynchronously with the help of RabbitMQ.

RabbitMQ console can be accessed at http://localhost:15672/

alt tag

alt tag

alt tag

Technology

Microservices sample project uses a number of open source projects to work properly:

Tools

Development

Below are the steps to bring up the development environment and get started.

  1. Install Git, Java, Maven and Docker
  2. For the project using https://github.com/mudigal-technologies/microservices-sample.git
  3. Clone the fork using https://github.com/{YOUR_GIT_ID}/microservices-sample.git
  4. Execute "cd /microservices-sample/build/docker/scripts/"
  5. To deploy docker please run "./deploy.sh docker".
  6. Access the Application at http://localhost/

Extras

Mysql on service-two-db:

$ docker exec -it service-two-db mysql -u service-two -p
Enter password: service-two

mysql> USE service-two;
Database changed

mysql> SELECT * FROM name_value;

Help

Feel free to reach "MUDIGAL TECHNOLOGIES LLP" at "[email protected]" incase of any concerns.

microservices-sample's People

Contributors

vmudigal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.