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

Scaling Software Architecture: 101 and Best Pra...

Scaling Software Architecture: 101 and Best Practices

Alex Xandra Albert Sim

May 12, 2018
Tweet

More Decks by Alex Xandra Albert Sim

Other Decks in Technology

Transcript

  1. Disclaimer Presentations are intended for educational purposes only and not

    to replace independent professional judgment. The views and opinions expressed in this presentation do not necessarily reflect the official policy or position of blibli.com. Audience discretion is advised.
  2. Who am I? • Alex Xandra Albert Sim • Principal

    Research and Development Engineer at blibli.com • [email protected] • bertzzie(.sim)
  3. Monolithic Architecture Pros • Cross cutting component integration is easy

    • Communication between layers / components are fast Cons • Long development cycle • Scaling problem • 1 problematic part == whole app down
  4. Microservices Architecture Pros • Fault tolerant • Service independence means

    fast and easy development / deployment • Easier to add / remove stuff Cons • Operational complexity is VERY high • Contracts between services are hard to maintain • Hard to get right. Lot of teams fall into “distributed monolith” rather than “microservice”
  5. Event-Driven Architecture – User Registration User API Gateway Membership System

    Event Broker Order System Payment System Messaging System 1 2 3 4
  6. Event-Driven Architecture - Purchase User API Gateway Event Broker Membership

    System Order System Messaging System Payment System 1 2 3 4 4 4
  7. Event-Driven Application Pros • Very low coupling • Simple to

    setup and scale Cons • Data consistency is hard. Eventually consistent instead of ACID • Complexity is through the roof • Flow of program is hard to trace / learn
  8. How to Scale: Vertical Scaling 2 CPU 4 GB RAM

    200 IOPS storage 100 Mb/s Network 8 CPU 16 GB RAM 400 IOPS storage 1000 Mb/s Network
  9. How to Scale: Horizontal Scaling 2 CPU 4 GB RAM

    200 IOPS storage 100 Mb/s Network 2 CPU 4 GB RAM 200 IOPS storage 100 Mb/s Network 2 CPU 4 GB RAM 200 IOPS storage 100 Mb/s Network 2 CPU 4 GB RAM 200 IOPS storage 100 Mb/s Network 2 CPU 4 GB RAM 200 IOPS storage 100 Mb/s Network
  10. Monolithic to Microservice: Step 1 Load Balancer Service A Service

    A Service A /cart /login /search Database
  11. Monolithic to Microservice: Step 2a Load Balancer Service B Service

    A Service A /cart /login /search Database Database
  12. Monolithic to Microservice: Step 2b Load Balancer Service B Service

    A Service C /cart /login /search Database Database Database
  13. How to Split Services? • From the least depended ones

    • By business function • Replace one by one • Potentially need to re-org too! • Test extensively per new service deployment!