Separating out the web layer from the application layer (also known as platform layer) allows you to scale and configure both layers independently. The single responsibility principle advocates for small and autonomous services that work together. Small teams with small services can plan more aggressively for rapid growth.
Asynchronous workflows help reduce request times for expensive operations. They can also help by doing time-consuming work in advance, such as periodic aggregation of data.
There are many caches some of which you may not expect:
- Client caching, e.g., browser often has its own cache
- Web server caching, e.g., Reverse proxies and caches such as Varnish can serve static and dynamic content directly.
- Database caching
- Application caching. In-memory caches such as Memcached and Redis are key-value stores between your application and your data storage.
Different components needs to communicate with each other. Here is a simple comparison of those protocols.
Latency numbers every programmer should know
``` Latency Comparison Numbers ————————– L1 cache reference 0.5 ns Branch mispredict 5 ns L2 cache reference 7 ns 14x L1 cache Mutex lock/unlock 25 ns Main memory reference 100 ns 20x L2 cache, 200x L1 cache Compress 1K bytes with Zippy 10,000 ns 10 us Send 1 KB bytes over 1 Gbps network 10,000 ns 10 us Read 4 KB randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD Read 1 MB sequentially from memory 250,000 ns 250 us Round trip within same datacenter 500,000 ns 500 us Read 1 MB sequentially from SSD* 1,000,000 ns 1,000 us 1 ms ~1GB/sec SSD, 4X memory Disk seek 10,000,000 ns 10,000 us 10 ms 20x datacenter roundtrip Read 1 MB sequentially from 1 Gbps 10,000,000 ns 10,000 us 10 ms 40x memory, 10X SSD Read 1 MB sequentially from disk 30,000,000 ns 30,000 us 30 ms 120x memory, 30X SSD Send packet CA->Netherlands->CA 150,000,000 ns 150,000 us 150 ms
Micro service architecture is an evolution of the SOA (Service Oriented Architecture) architecture, whereas SOA was focused on integration of various applications, Micro services architecture (MSA) aims to create small modular services which belong to a single application.
NoSQL is a collection of data items represented in a key-value store, document store, wide column store, or a graph database. Data is denormalized, and joins are generally done in the application code. Most NoSQL stores lack true ACID transactions and favor eventual consistency.
Relational database management system
A relational database like SQL is a collection of data items organized in tables.
A reverse proxy is a web server that centralizes internal services and provides unified interfaces to the public. Requests from clients are forwarded to a server that can fulfill it before the reverse proxy returns the server’s response to the client.
- Scalability Read More
Content delivery network
A content delivery network (CDN) is a globally distributed network of proxy servers, serving content from locations closer to the user. Generally, static files such as HTML/CSS/JS, photos, and videos are served from CDN, although some CDNs such as Amazon’s CloudFront support dynamic content. The site’s DNS resolution will tell clients which server to contact.
DNS is hierarchical, with a few authoritative servers at the top level. Lower level DNS servers cache mappings, which could become stale due to DNS propagation delays. DNS results can also be cached by your browser or OS for a certain period of time, determined by the time to live (TTL). Check following image as an example
Load balancers distribute incoming client requests to computing resources and returns the response from the computing resource to the appropriate client. Load balancers are effective at:
Memcache provides O(1) read and write operations. It has three core concepts.
There are three high level trade-offs: