Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Microservices késako

410e3353165c33043ab69be7fc366428?s=47 Boris Feld
October 17, 2015

Microservices késako

What is a microservices? A tale of computer company. A presentation of micro-services and how to create them with ZeroServices, a python micro-services framework.

410e3353165c33043ab69be7fc366428?s=128

Boris Feld

October 17, 2015
Tweet

Transcript

  1. MICROSERVICE KÉSAKO BORIS FELD - PYCONFR 2015

  2. Once upon a time A computer tale

  3. - Disclaimer « Any resemblance to actual events, to persons

    living or dead, is not the result of chance. It is DELIBERATE »
  4. In a little company…

  5. A developer

  6. A tester

  7. A DevOps

  8. A product owner

  9. Worked together in harmony

  10. Little project grew up

  11. And each change became more urgent than the precedent

  12. If I have to change anything on this project I

    will kill myself
  13. If I have to play the whole test suite once

    again, I’m good for another therapy
  14. If I have to deploy this project and maintain it,

    I will be able to buy a new car with the on-cull duty
  15. Conflicts emerged

  16. Resulting in a mess

  17. As the fear grew, the release rhythm slowed down

  18. Which only made the fear of change grew stronger

  19. We’re all humans

  20. -Tony Robbins « By changing nothing, nothing changes. »

  21. WHY? • Monolith • Hard to change • Inertia for

    refactoring / improvement • « Container carrier » size
  22. FROM MONOLITH…

  23. TO MICROSERVICES

  24. MICROSERVICES • Small isolated cooperative units • Aim to reduce:

    • FEAR OF CHANGE • Complexity • Inertia
  25. EXAMPLE User management service

  26. SMALL Simple composant Easy to understand Easy to maintain Fit

    in the head
  27. SINGLE RESPONSIBILITY Do one thing Do it well Single source

    of truth Unix way
  28. BLACK-BOX Expose a contract What it does What it returns

    And the format
  29. ISOLATION Communicate over
 Network No data leak through layers

  30. SCALING Easier to scale IF STATELESS

  31. BEST LANGUAGE Choose the best tool And change it later

  32. BEST DATASTORE Polyglot persistence Easier to change

  33. MORE DETAILED PRESENTATION ABOUT MICRO SERVICES • https://speakerdeck.com/lothiraldan/ microservices-introduction

  34. DESIGN Communication

  35. DISCOVERY Discovery Communication

  36. DATA-BACKEND Discovery Data-backend Communication

  37. INTERFACES HTTP Interface Websocket Interface Other interface Discovery Data-backend Communication

  38. INTERFACES µService HTTP Interface Websocket Interface Other interface Discovery Data-backend

    Communication
  39. ZEROSERVICES • A framework for all theses bricks • And

    a reference implementation for all of them • Python 3.4 • Asynchronous / Asyncio • Changes are broadcasted as events
  40. RESOURCE-ORIENTED • REST without HTTP • One and unique way

    to do CRUD operation • Valuable when combined with broadcasted changes
  41. REST API • Bind your endpoints to your code •

    What about websocket API? • Or IRC?
  42. WHAT IT LOOKS LIKE? RESOURCE SERVICE loop = asyncio.get_event_loop() medium

    = ZeroMQMedium(loop, UdpDiscoveryMedium) service = ResourceService('power_service', medium) service.register_resource(MongoDBCollection("power", "db")) loop.run_until_complete(todo.start()) loop.run_forever()
  43. REAL-TIME REST API loop = asyncio.get_event_loop() medium = ZeroMQMedium(loop, UdpDiscoveryMedium)

    service = ResourceService('rest_api', medium) application = get_http_interface(service, loop, port=5001, allowed_origins="*") application = loop.run_until_complete(application) loop.run_until_complete(service.start()) loop.run_forever()
  44. DEMO TIME!

  45. PROBLEMS WITH MICRO- SERVICES • Micro-service needs to know where

    are the others. • Made testing difficult. • Framework should abstract that. • Start without DevOps burdens.
  46. COMBINED loop = asyncio.get_event_loop() medium = ZeroMQMedium(loop, UdpDiscoveryMedium) service =

    ResourceService('power_service', medium) service.register_resource(MongoDBCollection("power", "db")) application = get_http_interface(service, loop, port=5001, allowed_origins="*") application = loop.run_until_complete(application) loop.run_until_complete(todo.start()) loop.run_forever()
  47. RESULT

  48. EXPOSED VIA WEBSOCKET • Changes exposed via real-time endpoint (websocket,

    etc…) • Easy to consume as REST-oriented • Works great with React / Flux
  49. CONCLUSION • Give it a try! • https://github.com/Lothiraldan/ZeroServices • Let’s

    sprint on it!