Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

A microservice architecture based on golang

14,151 views

Published on

A brief description of a software architecture based on golang micro services.

The keynote was shown during the Golangit meetup @ Codemotion Rome 2015 event on March 27th 2015.

Published in: Software

A microservice architecture based on golang

  1. 1. A microservice architecture
 based on Golang @giefferre
  2. 2. What is Qurami? Qurami is the free app that queues up for you
  3. 3. What is Qurami? Select the venue you are going to
 
 Choose from the venues in your area, or
 discover all the available venues
  4. 4. What is Qurami? A venue, at a glance
 
 Select the service of your interest, know the exact position of the venue, get its contacts
  5. 5. What is Qurami? Issue a ticket
 
 Qurami will inform you about the status of the queue, in real time!
  6. 6. Availability
  7. 7. Code facts
  8. 8. Code facts Backend: 1’062’287 Mobile: 600’413 lines of code
  9. 9. Code facts API libraries system
 configuration continuous integration web stuff services utilities agent
  10. 10. Architecture evolution
  11. 11. Evolution Proof of Concept • monolithic platform in Python
  12. 12. Evolution Minimum Viable Product • backend in PHP • agent in Java
  13. 13. Evolution Product a lot more!
  14. 14. Evolution “The focus is moved from common technology to common interfaces, integration techniques, protocols for passing data around”
  15. 15. Architecture APIs Business Domain Models Microservices Integration services, Databases 3rd party services
  16. 16. Advantages • “No pain” updates • Hot swappable components • Testable architecture • Really scalable • Performance statistics
  17. 17. Microservices
  18. 18. Business Domain Models Microservices Business Domain Models
 Microservices ?
  19. 19. Business Domain Models Microservices API office list? office list? complete
 domain model
 data data presentation elaboration
  20. 20. • Low level software • Not accessible from apps • Single-model responsibility • Written in Golang Business Domain Models Microservices
  21. 21. Business Domain Models Microservices API HTTP JSON-RPC server Interface Service core DB conn. 3rd p. int. Helpers ServiceName.MethodName(params)
  22. 22. Development process
  23. 23. The Deployer Microservice
  24. 24. Requirements We needed a micro service
 to automatically deploy some applications
 from a repository to a machine
  25. 25. Microservice structure . ├── README.md
 ├── interface.idl ├── main │   └── main.go ├── interfaces │   └── jsonrpc.go ├── core │   ├── deployer.go │   └── deployserver.go └── resources └── conf ├── github.ini └── server_list.ini
  26. 26. Microservice specifications Interface Definition Language
  27. 27. 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 }
  28. 28. 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 }
  29. 29. 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 } ...
  30. 30. RESTed
  31. 31. 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" } }
  32. 32. Response body { "jsonrpc": "2.0", "result": { "queued": true, "message": "Started DEPLOY" }, "id": 1 }
  33. 33. Commands over HipChat
  34. 34. Performance improvements
  35. 35. Addendum from 60% to 20%
  36. 36. Addendum from 2% to 7%
  37. 37. Reference
  38. 38. Reference Microservice architecture http://bit.ly/1dI7ZJQ
  39. 39. Reference Microservices for dysfunctional teams http://bit.ly/1ICTyE9
  40. 40. Reference Golang http://golang.org
  41. 41. Thank You! /qurami www.qurami.cominfo@qurami.com@qurami

×