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

Becoming Ninja of Microservices

Shubham
November 26, 2018

Becoming Ninja of Microservices

Shubham

November 26, 2018
Tweet

More Decks by Shubham

Other Decks in Technology

Transcript

  1. Have you thought how world’s biggest on demand video streaming

    service works ? Or How does the food you order reaches you ? Hyderabad
  2. What might go wrong with Monoliths ? • Huge application

    size • Managing data becomes a challenge • Assurances of Reliability - Becomes harder as you grow, you have to solve dependency graphs and have proper testing frameworks in place • Continuous Deployment & Scalability becomes harder and harder • Different Computational Requirements • Stick to one single language, framework and Database
  3. “Service can be an independently existing logical part of the

    business domain you are working in” - Martin Fowler
  4. “People try to copy Netflix, but they can only copy

    what they see. They copy the results not the process” - Adrian Cockcroft, Ex-Cloud Architect Netflix
  5. “Microservices is all about optimising for speed and scale” -

    Christian Posta, Principal Architect RedHat
  6. Few more Services ... • Rider Management • Trip Management

    and Tracking • Hotel Reservation • Subscription service
  7. Microservices Key Concepts • How to model data, transactions and

    retrieval processes • How do different services communicate with each other • How to define services and make them discoverable for product development
  8. How to Model Data ? • Domain Driven Design •

    Be language and framework agnostic ◦ Can be records in functional programing ◦ Can be Document in NoSQL ◦ Tuple in RDBMs • Abstraction ◦ Earth is sphere • Data Selection ◦ Want to represent spherical coordinates of earth on piece of paper • Map real world to your world - Formulaism ◦ Convert spherical coordinates to flat coordinates • Assertion ◦ Preserve direction between points
  9. How to model transactions? • ACID ◦ Atomicity - All

    or none ◦ Consistent - A transaction cannot leave the database in an inconsistent state ◦ Isolated - No transaction interfere with each other ◦ Durable • Easy to say hard to implement in microservices • BASE ◦ Basic Availability ◦ Soft State ◦ Eventual Consistency
  10. “Immutable transactional history of every single state change of all

    records that has happened so far” - Phillipa Avery, Tech Lead Download Services, Netflix
  11. Event Driven Architecture • Commands - Create, Delete, Update •

    Events - Order Created, Amount Reserved, Transaction Completed, Order Confirmed, Rider Allocated …… • Event Bus or Message broker - All services push events here • Publisher of events - Each service will have one, pushes event to the event bus • Subscriber of events - Each service will have one, consumes the events from event bus • Event store - the time machine, stores the event with state - Published, Processed
  12. Key Concepts of Inter Process Communication One To One one

    request - one service One To Many One request multiple service Synchronous Timely response from service. Client may even block when it waits Request/Response Traditional HTTP APIs - Asynchronous Client doesn’t block itself waiting for the response. And the response if any is not necessarily sent immediately Notification No reply expected Publish/subscribe A service produces a message which can be consumed by many services (PubNub) Request/async Response Async reply expected Publish/async response Async response expected by the publisher
  13. Problems with being Direct • Client App may have to

    call multiple services to render a page. Ex: Amazon claims that 100 services are called to render a page • Handling different formats of communication with different services. Ex: One service might use GRPC, other might follow REST • Refactoring in a service might affect client app • Load balancing and throttling becomes really difficult • Less Secure
  14. API Gateway • Single Point authorized entry • Encapsulation fine

    grained APIs of each microservice into tailor made response structure for each client • Routing request to right service • Load balancing and throttling • Caching and Reliability