Table of Contents....5
About the Author....10
About the Technical Reviewer....11
Acknowledgments....12
Introduction....13
Foreword....16
Chapter 1: The Ticket Sales Problem....18
Background....19
Requirements....20
Options....21
Manual Process....21
Existing System....23
Existing System Considerations....24
Minimum Viable Product....25
Target Architecture....25
How to Deal with High Throughput....26
Widening the Funnel....27
Server....27
Service....27
Multiple Funnels....28
Message Queues....30
Message Brokers....31
Separation of Concerns....33
Target Architecture Diagram....34
Proxy....35
A Note on Cloud Vendors....36
Why Cloud?....37
Examples....38
External APIs....38
Getting Ticket Availability....38
Ordering a Ticket....42
Adding a Message to a Queue....42
Getting a Response from the Queue....43
Summary....46
Chapter 2: The Cash Desk Problem....47
Background....48
Requirements....48
Options....48
Manual Process....49
Target Architecture....52
Audit....52
Event Sourcing....56
Immutable Events....58
How to Change Immutable Events....59
Projections and Snapshots....60
Aggregates....62
CQRS....62
Target Architecture Diagram....63
Examples....65
Persisting Events to Memory....65
Persisting Events to Disk....68
Save....69
Load....71
Writing to Files....76
Summary....77
Chapter 3: The Travel Agent Problem....79
Background....80
Requirements....81
Options....82
Manual Process....82
Transactions....83
ACID....83
Atomic....84
Consistent....84
Isolation....84
Durable....86
Distributed Transactions....87
Possible Scenarios....89
The hospital has no available appointments on that day....89
The space flight provider’s system crashes after receiving a prepare message but before responding....89
The hotel’s system crashes after receiving a commit message and committing the transaction but before acknowledging....89
The transaction coordinator crashes after sending all the prepare messages but before receiving any confirmations....90
Distributed Transaction with Timeout....90
Book and Cancel....91
Hold a Booking....92
Advanced Purchase....92
Business Decision....92
Target Architecture....93
Stateful Service....95
Distributed Service....95
Target Architecture Diagram....95
Examples....96
Project Structure....96
Service Bus Configuration....98
Coordinator....101
Summary....106
Chapter 4: The Social Media Problem....108
Background....109
Requirements....109
Options....110
Manual Process....111
CQRS....112
Benefits....112
Drawbacks....114
Consistency Models....115
Strong or Strict Consistency....116
Sequential or Causal Consistency....116
Weak or Eventual Consistency....117
Target Architecture....117
Examples....119
Schema Creation....119
Updating the Database....120
Update a Local Version of the Database Directly....120
Call a Web Service to Update the Database....121
Checking the Data....122
Web Service....122
Accessing MongoDB....125
The Client....129
Process Data Service....133
Summary....137
Chapter 5: The Admin Application Problem....139
Background....140
Requirements....140
Options....141
Manual Process....141
SOLID....143
Single Responsibility....144
Testability....145
Code Churn....145
Software Resilience....146
A Better Way....146
Open-Closed....147
Inheritance....148
Polymorphism....149
Liskov Substitution....150
Interface Segregation Principle....151
Dependency Inversion Principle....153
Inversion of Control....154
Methods of Extending Software....154
Hooks....155
Messages....156
Mediator....156
Injection....159
Security....159
Target Architecture....161
Examples....163
Basic Functionality....163
Extensibility....168
Custom Functionality....170
Summary....171
Chapter 6: The Travel Rep Problem....173
Background....174
Requirements....174
Options....175
Manual Process....175
Caching....176
Sidecar Pattern....177
Ambassador Pattern....178
Microservices and Containers....180
Target Architecture....180
Containers....181
Examples....182
Project Structure....183
TravelRep.CentralApi....184
Chaos Monkey....185
TravelRep.App....187
TravelRep.Ambassador....188
Hangfire....191
Enqueue and Schedule....193
Persistence and Configuration....193
Hangfire Dashboard....194
Containers....196
Docker Compose....196
Displaying a UI....198
Contacting the Host Machine from a Container....198
host.docker.internal....198
Configuring SSL/TLS....199
mkcert....203
Step 1. Install mkcert....203
Step 2. Install the Trusted Root Certificate....203
Step 3. Create a Certificate....204
Step 4. Copy the Certificate into the Central Service API....206
Step 5. Copy the Certificates to the Ambassador API....207
Durability....209
Summary....210
Appendix A: Technical Appendix....212
Chapter 1....212
Index....217
Design system solutions using modern architectural patterns and practices. This book discusses methods to keep a system responsive, even when it is being constantly updated, extending a system's functionality without changing the core code, methods of maintaining data history, and designing a distributed transactional system.This book will guide you in understanding how a software solution is designed using different architectural processes and scenarios. Each scenario explains if and why a software solution is required to resolve a given issue, and discusses possible architectural approaches to solve the problem. You will learn specific implementations of software architecture for each case along with different approaches to achieve the solutions. Each chapter is structured as a real-world requirement from a client and describes a process to meet that requirement.
After reading this book, you should have a high-level understanding of the architectural patterns used in the book, and you should have a methodology for approaching system design.
Developers who wish to move into architecture, and junior software architects also will find the book useful.