Rich user interac&on and state • Analogous to mobile or desktop applica&ons, but deployed over the web • Wikipedia is a website • Webapps: Online banking, Webmail, AWS console
client, server, and other services over a network, usually server-side web-apps • Tradi&onal synchronous HTTP request/response • User interac&on and state change oXen modeled through successive page loads • Each client session stored on a single server instance (many to 1 client->server rela&onship) • Usually li[le or no client-side state
extension of the server-side, not (logically) as a separate process • Stop the world state seman&cs • Inten&onally hides the distributed nature of the applica&on
execu&on • Easy (if not simple) • e.g., rails new is easy. Up and running in minutes! • Monoliths necessarily are opinionated about their components Illusion of simplicity
in the architecture of systems • Monolithic frameworks largely internalize the applica&on and deployment architecture • Failure is then the framework's fault • and, of course, you used the "industry standard" app framework, database, etc.
cycles put app responsiveness at the mercy of network latency and server load (e.g., other users) • What's the mean-&me to "user thinks it's broken"? • Monoliths oXen force tradeoffs between responsiveness and throughput* • Server-rendered UI less responsive (aXer ini&al load)
hundreds or thousands of request/response cycles. • Users no&ce that 1 slow request in 10 or 100 • 90-99th percen&le tail latency s&ll translates into a user experiencing frustra&ng levels of lag • Can you stay sub-100ms? User Experience
= client failure • Likewise for: • Authen&ca&on mechanism, database, etc failure • Failover/HA, scalability more complex • Poor resilience in the face of intermi[ent connec&vity, high load/thro[ling, etc
of complexity • Inherent complexity: inherent to the problem • Incidental complexity: accidental, arising from naive or subop&mal implementa&on (you can control this)
architectures, per se • It's easy to design a micro service architecture that has all of the shortcomings of a monolith • The tradeoffs are not zero-sum: • One, poten&ally, recognizes you're building a distributed system • The other a[empts to hide the fact
boundaries defined by the domain or user interac&ons (e.g., billing vs. shipping) • At best you're building several standalone monoliths. • At worst, you're duplica&ng sources of truth and needlessly separa&ng dependencies, over a network.
components and ac&ons • Ask how they affect scalability, resilience, etc. • Can they be decoupled by modifying the architecture? • Decomplec&ng reduces architectural constraints
one direc&on • The world exists as a series of discrete, ordered states • The past is immutable • You cannot know the state of another process/ system instantaneously
thing as sharing current data, only the possibility of sharing consistent data • Current only exists on a single machine, on a single core, within a single thread • Or, you stop the world to emulate this
as stale data if it is part of a historical state (e.g., versioned/ &mestamped). • If consistency is a requirement for some datasource, then you need: • A single Source of Truth • Linearized writes
State Render target (DOM) Engine Web Application Server Server process Demand API Demand query (e.g., GraphQL) Auth Session View Components Synchronous network Asynchronous network In-process Queue
(DOM) Engine Web Application Server Server process Demand API Demand query (e.g., GraphQL) Auth Session View Components Responsiveness • Moves presenta&on data and code closer to user • Immediate UI feedback • Decouples client UI responsiveness from server throughput • Op&mis&c client-side updates
(DOM) Engine Web Application Server Server process Demand API Demand query (e.g., GraphQL) Auth Session View Components Resilience • Resilience to server failure or intermi[ent connec&vity • Client-side data integrity • Retry (implicitly or explicitly with no loss of client-side data) • Stateless sessions • Reconnect to any server • Flexible load balancing • Transparent HA failover
(DOM) Engine Web Application Server Server process Demand API Demand query (e.g., GraphQL) Auth Session View Components Scalability • Horizontal client scalability at n = number of clients • Less server load • CDN-hosted client • Stateless sessions • Simplifies horizontal scaling • again, removing client/server affinity • Ephemeral webserver instances
(DOM) Engine Web Application Server Server process Demand API Demand query (e.g., GraphQL) Auth Session View Components Agility • Demand API allows client to define what they get (e.g., GraphQL) • Single query, many resources • Implicit consistency guarantee* • Each client can talk to poten&ally several services
Client Webapp Client Webapp Client Webapp App State Render target (DOM) Engine Web Application Server Server process Demand API View Components Session Get auth-token Other e.g., Analytics Demand query (e.g., GraphQL) w/ Auth token
Render target (DOM) Engine Web Application Server Server process Demand API View Components Session Get auth-token Other e.g., Analytics Demand query (e.g., GraphQL) w/ Auth token Decomplec&ng Auth • Token-based Auth service • If auth goes down, authen&cated users can con&nue using the system • Servers can independently verify a user's authen&ca&on • Stateless • Servers responsible for resource authoriza&on only
Render target (DOM) Engine Web Application Server Server process Demand API View Components Session Get auth-token Other e.g., Analytics Demand query (e.g., GraphQL) w/ Auth token Other services • Auth token can be used to authen&cate against other services, too • e.g., analy&cs service • Separa&ng services separates failure
Webapp Client Webapp Client Webapp App State Render target (DOM) Engine Web Application Server Server process View Components Session API Other e.g., Analytics Events REST API Server-sent event data sideloading Demand API Server-sent event registration
Render target (DOM) Engine Web Application Server Server process View Components Session API Other e.g., Analytics Events REST API Server-sent event data sideloading Demand API Server-sent event registration Propaga&ng change • Upda&ng clients • client -> server data changes pushed to other clients • can be versioned, &ed to a transac&on, etc. • Server Sent Events (SSE) • One-way • Loose coupling • automa&c reconnect to any server
Web Application Server Web Application Server Auth Service Client Webapp Client Webapp Client Webapp App State Render target (DOM) Engine Web Application Server Server process View Components Session API Other e.g., Analytics Events REST API Server-sent event data sideloading Demand API TX-stream Load balancer
Client Webapp Client Webapp Client Webapp App State Render target (DOM) Engine Web Application Server Server process View Components Session API Other e.g., Analytics Events REST API Server-sent event data sideloading Demand API TX-stream Load balancer Dataflow, scaled • Mul&ple webservers • Data server • Source of truth • Webservers have transac&on ledger streamed to them • Relevant clients, regardless of what server+SSE connec&on, get pushed updates
Client Webapp Client Webapp Client Webapp App State Render target (DOM) Engine Web Application Server Server process View Components Session API Other e.g., Analytics Events REST API Server-sent event data sideloading Demand API TX-stream Load balancer To infinity? • Dealing with database load • Is consistency important? ACID, in general? • (hint: yeah, probably) • Remember back to "Time and State" axioms • What can we decomplect? • First, what does a database server do?
I/O, and storage all colocated • Queries must be performed eagerly, for consistency • i.e., MVCC is transient historical state isola&on only during query • Updates performed in-place • Complects reads and writes
Trans- actions Data Segments Storage Server/Service Segment storage Standby Peer App Process Peer Lib Query Cache App Live Index Comm *cache cluster (optional) Data Segments
Storage Server/Service Segment storage Standby Peer App Process Peer Lib Query Cache App Live Index Comm *cache cluster (optional) Data Segments Database, reimagined • ACID seman&cs • Query scales with number of web servers • Choice of storage (e.g., AWS Dynamodb) • Lazy queries • Database as a value • Accumulates changes • Decomplects reads and writes