Databases Reference
In-Depth Information
Figure 4-10. Cache sharding
Read your own writes
Occasionally we may need to read our own writes—typically when the application ap‐
plies an end-user change, and needs on the next request to reflect the effect of this change
back to the user. Whereas writes to the master are immediately consistent, the cluster
as a whole is eventually consistent. How can we ensure that a write directed to the master
is reflected in the next load-balanced read request? One solution is to use the same
consistent routing technique used in cache sharding to direct the write to the slave that
will be used to service the subsequent read. This assumes that the write and the read
can be consistently routed based on some domain criteria in each request.
This is one of the few occasions where it makes sense to write through a slave. But
remember: writing through a slave can be an order of magnitude slower than writing
directly to the master. We should use this technique sparingly. If a high proportion of
our writes require us to read our own write, this technique will significantly impact
throughput and latency.
Testing
Testing is a fundamental part of the application development process—not only as a
means of verifying that a query or application feature behaves correctly, but also as a
way of designing and documenting our application and its data model. Throughout this
section we emphasize that testing is an everyday activity; by developing our graph
 
Search WWH ::




Custom Search