Software Architecture Books Summary And Highlights -- Part 6 Reliability
Reliability
Highlights
Distributed Database eventual consistency pattern
- Background sync process to sync different service’s databases.
- Cons: break bounded context among dbs. Because background process also has access to many dbs
- Suitable when there is no other communication among related services
- orchestration
- Pros: Atomic business request
- Cons: Slower responsiveness
- event based: Sync through events
- pros: Fast responsiveness
- Cons: Complex error handling
SAH Ch 9 Data Ownership and Distributed Transactions
Distributed Transactions
the various patterns used to implement distributed transactionality (such as compensating transactions) succumb to a wide variety of failure modes and boundary conditions, along with adding inherent complexity via undo operations. Distributed transactions present a host of difficulties and thus are best avoided if possible.
SAH Ch 12 Transactional Sagas
Transaction
distributed transactions are hard to get right and can actually inhibit scaling.
Systems that eventually converge through compensating retry logic can be harder to reason about, and may need other compensating behavior to fix up inconsistencies in data.
So first think hard about if your business operation could accept eventual consistency. If it really needs strong consistency, think hard if you really need to break the related services apart.
MSV Ch 5 Splitting the monolith
Synthetic Monitoring
Create a fake event input for the system to test production system. We used this synthetic transaction to ensure the system was behaving semantically, which is why this technique is often called semantic monitoring.
MSV Ch 8 Monitoring
Global ID tracking
Use a global id to track all related service logs. Populate the global id using a thin client lib so that it is easy to integrate into every service.
MSV Ch 8 Monitoring
Cascade failures: Each service instance should track and expose the health of its downstream dependencies, from the database to other collaborating services
MSV Ch 8 Monitoring
Standardized Monitoring
You should standardize your monitoring implementation across all your services.
- for each service
- track response time, error rate, downstream api response time, standardize log collection, log location, monitoring operating system
- for the system
- aggregation, tool capability , correlation ids, when to fire alert, what is needed in dashboard, if to use existing tool
MSV Ch 8 Monitoring
Security measure: CIA
- Confidentiality is the property that data or services are protected from unauthorized access.
- Integrity is the property that data or services are not subject to unauthorized manipulation.
- Availability is the property that the system will be available for legitimate use.
SAP Ch 11 Security
Signon approach
single signon (SSO) solution:
- SAML (SOAP based)
- OpenId connect (from Google) Rest based
A directory service could be something like the Lightweight Directory Access Protocol (LDAP) or Active Directory. These systems allow you to store information about principals, such as what roles they play in the organization.
use a gateway to centralize the behavior for redirecting the user and perform the handshake in only one place.
Gateway downside:
- Downstream service still need to handle principals correctly
- hard to provide production like auth environment for one service’s developer to test
- developer may rely too much on gateway and neglect their own responsibility for security feature
MSV Ch 9 Security
Favor fine grained authorization with multiple roles. Control each role’s access in each service instead of in gateway
MSV Ch 9 Security
Service to Service Authentication and Authorization
- Allow Everything Inside the Perimeter
- Cons: if an attacker penetrates your network, then he can do anything
- HTTP(S) Basic Authentication: client send user name and password over HTTPS
- cons:
- Hard to manage SSL issuing process and revoking process
- HTTPS traffic cannot be cached by reverse proxies
- cons:
- Use SAML or OpenID Connect, but client talk to identity server directly
- cons: where do we store credentials
- Use client certificate such as TLS to verify a client server is valid
- Difficult to debug TLS verification issue
- HMAC Over HTTP
- hash-based messaging code (HMAC)
- client and server shares same private key
- request body is hashed by private key and the hash is sent along with the request body
- so that if middle man messes the request, the hash won’t match the body
- lower overhead than https
- cons:
- need to send private key to client in a secure way
- hard to invalidate private key
- this is a pattern, not a standard, and thus there are divergent ways of implementing it.
- It can only guarantee no one else manipulated the request. the body is still visible to others
- API keys
- public api offers client user to use specials keys to authorize them and allow public api server to put limit on them
- can be implemented in multiple ways, e.g. public key, private key
- easy to use
MSV Ch 9 Security
Related Chapters
SAP Ch 10 Safety
SAP Ch 11 Security
SAH Ch 9 Data Ownership and Distributed Transactions
SAH Ch 12 Transactional Sagas
MSV Ch 5 Splitting the monolith
MSV Ch 8 Monitoring
MSV Ch 9 Security