Skip to content

Instantly share code, notes, and snippets.

@codecakes
Created April 5, 2024 15:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecakes/ecddc591852314eb04bedca289904218 to your computer and use it in GitHub Desktop.
Save codecakes/ecddc591852314eb04bedca289904218 to your computer and use it in GitHub Desktop.
How to design Horizontally scalable distributed systems?

HA principles: CAP done right

  • Design in isolation (Partition)
    • 2 business modules must communicate over message pattern. They are not considered business modules if one requires the other, in which case they don’t need to communicate over messages if a business process has to die, all interconnected business modules must die
    • process are stateless
    • fault tolerant implies scalability implies concurrency and concurrent business processes
  • Availability
    • its better to die on fault and restart, then drag and build up the pile of error
    • when a process dies, fault detection and communicating fault is important
    • spawning millions of instances is not availability. to be available, service Cannot go down.
    • any of the system should be able to become a leader
    • Have hot reloading
  • Consistency
    • having one concrete source of truth is not enough. the right leader election will guarantee how soon data is replicated.
    • Consistent replication using a consistent cord hashing is necessary
    • The right storage db will save you
    • Not defensive programming. use guards
    • use lightweight pre-emptive scheduling processes.
  • fast message passing
  • spawning millions of instances is not availability. to be available, any of the system should be able to become a leade
  • No shared states betwen processes
  • strictly functional
  • dynamically typed
  • No locks, Consider actor model for message passing
  • Rethink The General Problem: SLOC vs YAGNI
  • Data Structures behave differently in FP
  • When leveraging dynamism or meta-programming, consider trade-offs with readability, ease of maintainability and from point 2, efficiency
  • Domain driven logic
  • Include benchmarking in CI!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment