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

Rapid Development with Microservices

Noam Almog
November 10, 2017

Rapid Development with Microservices

Microservices is not a buzzword anymore, it influences our development process as well as our organizational structure. But still, when we start a new service, we want to move fast. Can we move fast while architecture our system correctly?

After developing a number of services in Wix, I want to share some of my experience with developing and architecting systems while keeping a high velocity.

Noam Almog

November 10, 2017
Tweet

More Decks by Noam Almog

Other Decks in Programming

Transcript

  1. Hi. I am Noam Almog Tech lead at Wix.com Lithuania

    Ukraine Vilnius Kiev Dnipro Wix Engineering Locations Israel Tel-Aviv Be’er Sheva
  2. My Project When our project is new and small, it’s

    easier to work with a Monolith. New
  3. My Project New stable Once it gets more stable, however,

    it’s easier to work with Microservices.
  4. 1. How to build a ‘detachable’ monolith 2. When and

    how to Split Today: How to develop with a ‘breakup’ in mind My Project New stable 3. What happens after we split
  5. What does our current server contains ? Web handlers (controllers)

    Business logic (services) Persistency (DAO’s) Domain objects Tests
  6. New feature request? Think where to add it Core service

    e.g., notifications (email, sms, push) System feature e.g., backoffice User feature e.g., landing pages stores
  7. Think what the new module will contain Web handlers (controllers)

    Business logic (services) Persistency (DAO’s) Domain objects Tests
  8. Put it all in a new, separate module stores-bo stores

    Web support (controllers) Business logic (services) Persistency (DAO’s) Domain objects Tests
  9. If it depends on something, it will never stand alone.

    backoffice class is using stores class stores bo
  10. server wiring ITs for the system stores stores-core stores-server business

    logic Step 1 Split your existing service to core & web
  11. Step 2 ‘Break’ the dependency core bo api server 1.

    Extract interface to api module 2. Wire them together on server module 3. Remove dependencies
  12. Yes! They’re APIs too. bo core api server User ▪

    Don’t overshare ▪ Share only what’s needed
  13. The problem with one big database is... 1. Dual read/writes

    to the same table 2. Developers encouraged to add joins between tables core bo
  14. Start with communicating indirectly core bo Core Client 1. Extract

    a client (API) 2. Move references from DB to client 3. Split to different DB’s
  15. What about performance ? ▪ Synchronous joins over IO -

    Pull ▪ Local Copy - Pull ▪ Event sourcing - Push
  16. Final tip Try to postpone persistency as much as possible.

    1. Write and test persistency in-memory 2. Load memory with some data 3. Persist to global location if needed 4. When domain is stable enough, create a DB
  17. Triggers for a Split Scale one service needs more resources

    Stability extract for stability for critical service Core external usages Reorganization move service responsibility
  18. Triggers for a Split Scale one service needs more resources

    Stability extract for stability for critical service Core external usages Reorganization move service responsibility Do we really need to? Not always...
  19. How to Split ? Step 1 Copy the module to

    another repository Wrap it with a new service backoffice-core backoffice-server (new server harness, IT’s) stores-bo
  20. How to Split ? Step 2 Make new service communicate

    with the remote one backoffice-core backoffice-remote-store backoffice-server stores-api stores-core stores-server (new server harness, IT’s)
  21. How to Split ? Step 3 Define I/O operations as

    functions. backoffice-remote-stores stores-api stores-core stores-server (new server harness, IT’s) backoffice-core backoffice-server
  22. You’re as fast as your slowest team... So make it

    easy for others to work with your service! New stable
  23. To do Make your service easy to work with ❏

    Provide some documentation: how to use your service ✔
  24. To do Make your service easy to work with ❏

    Provide some documentation: how to use your service ❏ List all tests for the contract that you provide ❏ Create a testkit for integrating with your service ✔ ✔ ✔
  25. To do Make your service easy to work with ❏

    Provide some documentation: how to use your service ❏ List all tests for the contract that you provide ❏ Create a testkit for integrating with your service ❏ Reduce your integration code ✔ ✔ ✔ ✔
  26. Final tip Notice common patterns ▪ Common patterns generate a

    viable framework ▪ Extract libraries and core services
  27. Takeaways New stable Build a ‘detachable’ monolith (beware dependency &

    persistency pitfalls) A split is triggered by a need (when it does, extract to a remote service) You are fast as your slowest team Common patterns are backbone