Git Product home page Git Product logo

microservice's Introduction

see also the modular version of this project in perf.

Dummy microservice

A tiny golang application simulating a microservice. It

  • listens for HTTP POST inbound connections
  • connects to other named microservices specified on the command line
  • sends messages with size specified on the command line
  • maintains a user defined CPU and memory load
  • logs sent and received through Zipkin

Build

Using Go natively

go  get -u
make microservice

Usage

Usage of ./microservice:
  --name string
        service name
  --zipkin string
        zipkin address (addrs:port) -- default 0.0.0.0:9411
  --msg-size uint
        average size of all messages outgoing -- default:256
  --msg-time uint
        average time to process an incoming message -- default 10ms
  --{a-h} float64
        parameter {A-H} that affects CPU and memory usage -- default 0
  --x int
        parameter X that affects CPU and memory usage -- default 0
  --y int
        parameter Y that affects CPU and memory usage -- default 0

Example

The following example will start a microservice and attempt to connect to a different instance of micro-sock "test-host". In this case, zipkin is on host "zipkin"

./microservice -name=micro -zipkin=zipkin:9411 test-host

To test using docker-compose

docker-compose -f zipkin_docker-compose.yaml -f docker-compose.custom.yml up

In another bash or on browser

To exercise all endpoints:

curl -I -XPOST localhost:8080/

or to exercise few endpoints at random

curl -I -XPOST localhost:8080/random

Exercising URL-based predefined paths

After running uApp-generator.py, the file routeMap.go will be created. This file defines all the uniques paths through the given microservice graph from the start node to a terminal node. In order to exercise one of the paths, use any of the 4 commands below.

curl -I -XPOST localhost:8080/0
curl -I -XPOST localhost:8080/1
curl -I -XPOST localhost:8080/2
curl -I -XPOST localhost:8080/3

If there are more than 4 paths through the graph that you wish to exercise, you can easily add more endpoints (/4, /5, ...) in main() of router.go and everything should work accordingly. No other changes are nessecary to support more paths.

If there are less than 4 paths through the graph, only use the endpoints less than the number of paths.

Deep Dive

Valid parameter values

All parameters are continuous unless otherwise specified.

-4 <= a <= 4
-250 <= b <= 250
-10 <= c <= 10
1E-5 <= d <= 1E-1 (continuous), 10 <= d <= 1E5 | Step: 10, not continuous
-2.5 <= e <= 2.5
5 <= f <= 10, -10 <= f <= -5
-3 <= g <= 3
-25 <= h < 25
-3 <= x, y <= 3 | Step: 1, not continuous

All parameters are independent of each other.

Functions used to determine CPU and load

Functions

Raw functions

If the image ever breaks, here are the raw functions (as LaTeX):

Beale: \textrm{CPU} = \frac{(1.5-x+xy)^2 + (2.25-x+xy^2)^2 + (2.625-x+xy^3)^2}{890000} + 0.2

Himmelblau: \textrm{Memory} =  \frac{(x^2 + y - 11)^2 + (x + y^2 - 7)^2}{890} * 1024

x_{1}: \frac{a^2 + bc}{500*\log{d}} * 1024

x_{2} = \log{d} - \frac{e*h}{32}

y_{1} = \sin{\frac{a}{c} \pi } * cos(f*g \pi) - 2e

y_{2} =  \frac{\sqrt{be}}{f}

microservice's People

Contributors

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