a microservice architecture based on golang

Download A microservice architecture based on golang

Post on 15-Jul-2015

1.429 views

Category:

Software

7 download

Embed Size (px)

TRANSCRIPT

  • A microservice architecturebased on Golang

    @giefferre

  • What is Qurami?

    Qurami is the free app that queues up for you

  • What is Qurami?

    Select the venue you are going to

    Choose from the

    venues in your area, or discover all the

    available venues

  • What is Qurami?

    A venue, at a glance

    Select the service of your interest, know the

    exact position of the venue, get its contacts

  • What is Qurami?

    Issue a ticket

    Qurami will inform you about the status of the

    queue, in real time!

  • Availability

  • Code facts

  • Code facts

    Backend: 1062287 Mobile: 600413

    lines of code

  • Code facts

    APIlibraries

    system configurationco

    ntin

    uous

    in

    tegr

    atio

    n

    web stuff

    services

    utili

    ties

    agent

  • Architecture evolution

  • Evolution

    Proof of Concept

    monolithic platform in Python

  • Evolution

    Minimum Viable Product

    backend in PHP agent in Java

  • Evolution

    Product

    a lot more!

  • Evolution

    The focus is moved from common technology to common interfaces, integration techniques, protocols for passing data around

  • Architecture

    APIs

    Business Domain Models Microservices

    Integration services,

    Databases

    3rd party services

  • Advantages

    No pain updates Hot swappable components Testable architecture Really scalable Performance statistics

  • Microservices

  • Business Domain Models Microservices

    Business Domain ModelsMicroservices

    ?

  • Business Domain Models Microservices

    APIoffice list? office list?

    complete domain model

    data

    data presentation elaboration

  • Low level software Not accessible from apps Single-model responsibility Written in Golang

    Business Domain Models Microservices

  • Business Domain Models Microservices

    API

    HTTP JSON-RPC server

    Interface

    Service core

    DB conn. 3rd p. int. Helpers

    ServiceName.MethodName(params)

  • Development process

  • The Deployer Microservice

  • Requirements

    We needed a micro serviceto automatically deploy some applications

    from a repository to a machine

  • Microservice structure

    . README.md interface.idl main main.go interfaces jsonrpc.go core deployer.go deployserver.go resources conf github.ini server_list.ini

  • Microservice specifications

    Interface Definition Language

  • Microservice implementation: main

    func main() { // parse some command-line parameters // such as service ID and environment ...

    deployer, err := servers.NewRPCServer( new(interfaces.JSONRPCInterface), Identifier, Environment, )

    if err != nil { log.Fatal(err) }

    deployer.ServeJSON()

    ...

    // wait until an exit command is given }

  • Microservice implementation: jsonrpc interface

    func (i *JSONRPCInterface) Enqueue( r *http.Request, args *EnqueueArgs, reply *string, ) error { result, err := core.Enqueue(*args)

    if err != nil { return err }

    *reply = result return nil }

  • Microservice implementation: core excerpt...

    func Enqueue(args *EnqueueArgs) QueuedCommandResult { var result QueuedCommandResult

    deployer, err := NewDeployer( args.Command, args.Repository, args.AppName, args.Branch, args.DestMachine, )

    if err != nil { result.Queued = false result.Message = err.Error() } else { result.Queued = true result.Message = "Started " + args.Command go deployer.SetAndExecute() }

    return result }

    ...

  • RESTed

  • Request body

    { "id": 1, "jsonrpc": "2.0", "method": "Deployer.Enqueue", "params": { "command": "DEPLOY", "repository": my-repository", "appName": my-application", "branch": "my-feature-branch", "destMachine": "test01" } }

  • Response body

    { "jsonrpc": "2.0", "result": { "queued": true, "message": "Started DEPLOY" }, "id": 1 }

  • Commands over HipChat

  • Performance improvements

  • Addendum

    from 60% to 20%

  • Addendum

    from 2% to 7%

  • Reference

  • Reference

    Microservice architecture

    http://bit.ly/1dI7ZJQ

  • Reference

    Microservices for dysfunctional teams

    http://bit.ly/1ICTyE9

  • Reference

    Golang

    http://golang.org

  • Thank You!

    /qurami www.qurami.cominfo@qurami.com@qurami