<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abhijit Bhatnagar on Medium]]></title>
        <description><![CDATA[Stories by Abhijit Bhatnagar on Medium]]></description>
        <link>https://medium.com/@abhijitbhatnagar?source=rss-731f3b69d9ae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PoK2A8WndI-Be-zN.</url>
            <title>Stories by Abhijit Bhatnagar on Medium</title>
            <link>https://medium.com/@abhijitbhatnagar?source=rss-731f3b69d9ae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 11:30:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhijitbhatnagar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Designing Data Intensive Applications]]></title>
            <link>https://medium.com/@abhijitbhatnagar/designing-data-intensive-applications-8f5122b5b031?source=rss-731f3b69d9ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f5122b5b031</guid>
            <dc:creator><![CDATA[Abhijit Bhatnagar]]></dc:creator>
            <pubDate>Thu, 21 Jul 2022 03:56:47 GMT</pubDate>
            <atom:updated>2022-07-21T03:56:47.515Z</atom:updated>
            <content:encoded><![CDATA[<h3>Part 1: Foundations of Data Systems</h3><ul><li>Terminology: reliability, scalability, maintainability</li><li>data models and query languages</li><li>storage engines</li><li>data encoding and serialization.</li></ul><h3>Chapter 1: Reliable, Scalable and Maintainable Applications</h3><p>Common needs to data-intensive application:</p><ol><li>Store data (databases)</li><li>Remember the results of an expensive operation (caches)</li><li>Allow users to search data (search indexes)</li><li>Send a message to another proces, async (stream processing and queues)</li><li>Periodically crunch large amount of accumulated data (batch processing)</li></ol><p><strong>Reliability</strong><br>The system should continue to work correctly(performing the correct function at the desired level of performance) even in the face of adversity</p><p><strong>Scalability</strong><br>As the system grows (in data volume, traffic volume, or complexity) there should be reasonable ways of dealing with that growth.</p><p><strong>Maintainability</strong><br>Over time, many different people will work on the system (engineering, operations, both maintaining current behavior and adapting the system to new use cases), and they should be able to work on it productively.</p><h3>Reliability</h3><p>Roughly, it means that systems continue to work correctly even if things go wrong. Typical expectations include:</p><ol><li>The application performs the function that the user expected</li><li>It can tolerate the user making mistakes or using the software in unexpected ways.</li><li>Its performance is good enough for the required use case, under the expected load and data volume.</li><li>The system prevents any unauthorized access and abuse.</li></ol><p>Systems that anticipate faults and can cope with them are called fault tolerant or resilient. A fault is not the same as a failure. A fault is usually defined as one component of the system deviating from its spec, whereas a failure is when the system as a whole stops providing the required service to the user.</p><p><strong>Hardware Faults</strong></p><ul><li>Hard disks have Mean Time to Failure (MTTF) of about 10 to 50 years. Storage cluster with 10,000 disks will have one 1 disk dying everyday.</li><li>Using software fault-tolerance in addition to hardware fault-tolerance improves reliability by reducing risk of failure.</li><li>Highly unlikely that a large number of hardware components will fail at the same time.</li></ul><p><strong>Software Errors</strong></p><ul><li>Systematic errors — harder to anticipate because they are correlated across nodes.</li><li>Software bugs</li><li>Runaway processes — that use up shared resources</li><li>Slow upstream/Downstream services.</li><li>Cascading failures.</li></ul><p><strong>Human Errors</strong></p><ul><li>configuration errors by operators can be leading cause of outages, much more than hardware or software errors.</li><li>Design systems in a way that minimize human interventions.</li><li>Decouple the places where people make the most mistakes from places they can cause failures</li><li>Sandbox environments</li><li>Test thoroughly at all levels.</li><li>Allow quick and easy recovery from human errors, to minimize the impact in the case of a failure.</li><li>Fast rollback configuration changes</li><li>Roll out new code gradually</li><li>provide tools to recompute data</li><li>Detailed and clear monitoring</li><li>Performance metrics</li><li>error rates</li><li>telemetry</li><li>Good management practices and training.</li></ul><p><strong>How Important is Reliability?</strong></p><ul><li>Be very conscious of when we are cutting corners.</li></ul><h3>Scalability</h3><ul><li>increased load it one common reason of reduced reliability and increasing degradation of a system.</li><li>Scalability is used to describe a system’s ability to cope with increased load.</li><li>If the system grows in a particular way, what our options for coping with additional demand ?</li><li>How can we add computing resources to handle the additional load ?</li></ul><p><strong>Describing Load</strong></p><p><strong><em>Load is described using parameters (input to the system, something you dial up or down) while performance using metrics (something you observe).</em></strong></p><ul><li>First describe the load on the system, only then we can discuss growth.</li><li>“Load parameters” are used to describe the load on a system</li><li>requests per second</li><li>read to write ratio</li><li>simultaneous active users</li><li>hit rate on a cache</li><li>Example Twitter — fan out case : when a user is followed by many users, and each have their own wall of tweets to scroll:</li></ul><ol><li>Approach 1: use a sql database, and when a user posts a tweet, add that tweet to a global table of all tweets. Scan the entire table when reading the tweets for a user. Unscalable.</li><li>Approach 2: Maintain a cache for each user’s home timeline — whenever a user posts a tweet, look up all the followers of that user and insert the tweet into each of the follower’s home timeline cache. The request to read home timeline is cheap because it has been precomputed. However, this is an expensive approach. Posting one tweet means making 1 write request per follower.</li></ol><ul><li>In twitter example, the key scalability parameter then becomes the fan out load.</li></ul><p><strong>Describing Performance</strong></p><ol><li>When you increase the load on the system while keeping the resources constance, how is the performance affected ?</li><li>When you increase the load on the system, how much additional resources do you require to keep the performance unaffected ?</li></ol><p><strong>Example performance metrics:</strong></p><ol><li>Throughput</li><li>Latency</li></ol><p>Latency vs response time:</p><ul><li>response time is what the client sees: besides the actual time to process a request. It includes network delays and queuing delays.</li><li>Latency is the duration that a request is waiting to be handled — the latent period when it is waiting to be serviced.</li></ul><p>Latency/response time is usually measured in percentile rather than averages. Percentiles are more representative of the end user experience.</p><p>Tail latencies or high percentiles of response times are important because they directly affect user’s experience of the service. Customers with the slowest responses are often those with the most data because they have made many purchases — thus they are the most valuable. Important to keep them happy.</p><p>Optimizing the p99.99 latency was deemed too expensive and to not yield enough benefits for Amazon purposes. Percentiles are often used in Service Level Objectives and service level agreements contracts that define the expected performance and availability of a service.</p><p>Head-of-the-line blocking: the front of the queue becomes chocked so messages in the queue stop processing.</p><p><strong>Approaches for coping with Load</strong></p><ul><li>An architecture that is appropriate for one level of load is unlikely to cope with 10 times that load. If you are working on a fast-growing service, it is therefore likely that you will need to rethink your architecture on ever order of magnitude load increase.</li><li>Distributing load across multiple machines is also called a shared-nothing architecture. A system that can run on a single machine is often simpler, but high-end machines can become very expensive, os very intensive workloads often cant avoid scaling out.</li><li>Elastic systems can automatically add computing resources when they detect a load increase, whereas other systems are scaled manually. These are useful if loads are highly unpredictable.</li></ul><h3>Maintainability</h3><ul><li>majority of the cost of a system is not in its initial development but in its ongoing maintainence.</li><li>fixing bugs</li><li>keeping systems operational</li><li>investigating failures</li><li>adapting to new platforms,</li><li>modifying it for new use cases,</li><li>repaying tech debt,</li><li>adding new features.</li><li>Every legacy system becomes unpleasant in its own way.</li><li>Should design systems in such a way that it will hopefully minimize pain during maintainence.</li><li>Operability: Make it easy for operations team to keep the system running smoothly.</li><li>Simplicity: Make it easy for new engineers to understand the system, by removing as much complexity as possible from the system</li><li>Evolvability/Extensibility/Modifiability/Platicity: Make it easy for engineers to make changes to the system in the future, adapting it for unanticipated use cases as requirements change.</li></ul><p><strong>Operability: Making life easier for operations</strong></p><ul><li>good operations can often work around the limitations of bad( or incomplete) software, but good siftware cannot run reliably with bad operations.</li><li>Responsibilities of operations teams:</li><li>Good operability means making routine tasks easy, allowing the operations team to focus their efforts on high-value activities. Data systems can do various things to make routing tasks easy:</li><li>Provide visibility into the runtime behavior and internal of the system, with good monitoring.</li><li>Provide good support for automation and integration with standard tools</li><li>Avoiding dependency on individual machines</li><li>Providing good documentation and an easy-to-understand operational model.</li><li>Providing good default behavior, but also giving administrators the freedom to override defaults when needed.</li><li>Self-healing where appropriate, but also giving administrators manual controls over the system state when needed.</li><li>Exhibiting predictable behavior, minimizing surprises.</li></ul><p><strong>Simplicity: Managing Complexity</strong></p><ul><li>A software project mired in complexity is sometimes described as a big ball of mud.</li></ul><p>Symptoms of complexity:</p><ul><li>Explosion of the state space</li><li>Tight coupling of modules</li><li>Tangled dependencies</li><li>Inconsistent naming and terminology</li><li>hacks aimed at solving performance problems,</li><li>Special casing to work around issues</li></ul><p>Use abstractions to remove accidental complexity</p><ul><li>good abstractions hide great deal of implementation detail behind a clean, simple to understand facade.</li><li>A good abstraction can also be used for a wide range of different applications.</li></ul><h3>Evolvability: Making Change Easy</h3><ul><li>requirements will likely always be in a constant flux.</li><li>The ease with which you can modify a data system, and adapt it to changing requirements is closely linked to its simplicity and its abstractions: simple and easy-to-understand systems are usually easier to modify than complex ones.</li></ul><h3>Chapter 2: Data Models and Query Languages</h3><ol><li>Application Developers look at real world and model it in terms of objects or data structures and APIs that manipulate those data structures</li><li>These data structures are stored using a general purpose data model — JSON/XML documents, tables or a graph model</li><li>Database store those data models in some other form on disk/memory</li><li>At even lower levels, HW engineers figure out how to represent bytes in terms of electrical currents etc.</li></ol><p>Basic Idea: Each Layer hides the complexity of the layers below it by providing a clean data model.</p><h3>Relational Model vs Document Model</h3><ul><li>data is organized into relations where each relation is an unordered collection of tuples</li></ul><p><strong>Birth of NoSQL</strong></p><ul><li>Latest attempt to overthrow relational model’s dominance.</li><li>Driving forces:</li><li>greater scalability than relational databases can easily achieve, including very large datasets or very high write throughput</li><li>widespread preference for free and open source software over commercial database products</li><li>Specialized query operations that are not well supported by the relational model</li><li>Frustrations with restrictiveness of relational schemas, and desire for more dynamic and expressive data model.</li></ul><p><strong>Object Relation Mismatch/ Impedence Mismatch</strong></p><ul><li>Database have a relational model with data spread across many different tables. Application needs a translation layer between the database and its own Object oriented interfaces. APplication may use Object relation mapping (ORM) software such as hibernate or Active Records.</li><li>JSON model reduces impedence mismatch between the application code and the storage layer.</li><li>JSON representation has better locality that a multi-table schema. All relevant information lives together in one place, and one query is sufficient.</li></ul><p><strong>Many-to-one and Many-to-many relationships</strong></p><ul><li>Many-to-one and Many-to-many relationships do not fit nicely into the document model.</li><li>If databases itself does not support joins, application needs to emulate a join in application code by making multiple queries to the database.</li></ul><p><strong>Relational Data Model vs Document Data Model</strong></p><p>It is not trivial to say which data model results in simpler application code. It depends on kings of relationships that exist between the data, and how those relationships will be used.</p><ul><li>Relational Data Model</li><li>(+) Better support for joins</li><li>(+) many to one and many to many relationships are better supported</li><li>(-) complex application code due to shredding of documents into many tables.</li><li>Document Data Model</li><li>(+) schema flexibility (schema-on-read)</li><li>(+) better performance due to locality of information — only if the entire document needs to be read. Best practice is to keep documents small.</li><li>(+) Simpler application code because data model is closer to what is used by the application’s object model.</li><li>(-) Cannot refer directly to nested components within a document without reading read the entire document.</li><li>(-) Poor support for joins — results in very high duplication of data. In case joins are required, application code becomes more complicated because application now needs to make multiple reads.</li></ul><h3>Query Languages for Data</h3><p><strong>Imperative:</strong> Ordered Sequences of Code<br><strong>Declarative:</strong> Relational Algebra like specification of requirements.</p><p><strong>MapReduce Querying</strong></p><ul><li>lies in between imperative and declarative languages.</li></ul><h3>Graph Like Data Models</h3><ul><li>if no relationships or mostly one-to-many, then document data model</li><li>if many-to-many, then graph data models.</li></ul><p>Graphs:</p><ul><li>Two kind of objects</li></ul><ol><li>vertices/nodes/entities</li><li>edges/relationships/arcs</li></ol><ul><li>models:</li><li>Property Graphs</li><li>Triple Store Models</li><li>Languages:</li><li>Cypher</li><li>SparQL</li><li>Datalog</li><li>Gremlin</li></ul><p><strong>Property Graph model</strong></p><ul><li>each vertex has:</li><li>unique identifier</li><li>set of outgoing edges</li><li>set of incoming edges</li><li>collection of properties: key-value pairs</li><li>each edge has:</li><li>unique identifier</li><li>vertex at which edge starts (tail vertex)</li><li>vertex at which edge ends (head vertex)</li><li>label to describe the kind of relationship</li><li>collection of properties or key-value pairs</li></ul><p>Important Aspects:</p><ul><li>Any vertex can have an edge connecting it with any other vertex. No schema that restricts which kind of things can or cannot be associated.</li><li>Traversal: Given any vertex, you can efficiently find both its incoming and its outgoing edges.</li><li>Different labels for different kind of relationships allow storing several kind of information in a single graph, while still maintaining a clean data model.</li></ul><p><strong>Cypher Query Language</strong></p><ul><li>Declarative query language for property graphs.</li><li>No need to specify execution details (how) when writing the query. The query optimizer automatically chooses a strategy that is predicted to be most efficient, so you can get on with writing the rest of your application.</li></ul><p><strong>Graph Queries in SQL</strong></p><ul><li>possible using “With Recursive“ statements.</li><li>Clumsy and difficult to read.</li></ul><p><strong>Triple Stores and SparQL</strong></p><ul><li>All information is stored using 3 part statements: (subject, predicate, object)</li><li>Subject : vertex in a graph</li><li>Object could be one of the following:</li><li>If it is a value in a primitive datatype, then the predicate and object are equivalent to the key and value of a property on the subject</li><li>If it is another vertex in the graph, then predicate is an edge, the subject is the tail vertex (from — outgoing end) and object is the head vertex (to — incoming end).</li></ul><p><strong>The Semantic Web</strong><br>Websites already publish information as text and pictures for humans, so why dont they also publish information as machine readable data for computers to read? The Resource Description Framework (RDF) allows websites to publish data in a consistent format.</p><p><strong>The RDF Data Model</strong></p><ul><li>closer to the Turtle model</li><li>XML</li></ul><p><strong>The SparkQL Query Language</strong></p><ul><li>Query language for Triple stores</li><li>uses RDF Data Model</li><li>Unlike the Cypher query language, SparQL does not distinguish between properties and edges and just uses predicates for both. Dont need to specify the edges in the query itself.</li></ul><h3>Graph Model Versus Network Model (Codasyl)</h3><p>Differences:</p><ul><li>Codasyl databases have a schema that specified which record type could be nested within which other record type. In graph database, there is no such restriction: any vertex can have an edge to any other vertex. Greater flexibility for applications to adapt to changing requirements.</li><li>Codasyl only had a single way to reach a record : traversal. Graph databases can refer directly to any vertex by its unique ID, or can use an index to find vertices with a given value.</li><li>In Codasyl, the children of a node formed an ordered set — database had to maintain ordering information. In GraphDB, vertices and edges are unordered.</li><li>In Codasyl, all queries are imperative, difficult to write and easily broken by changes to the schema. In GraphDB, you can write your traversal in imperative code if needed, but most DB support declarative queries.</li></ul><h3>DataLog</h3><ul><li>Querying language for Datomic and Cascalaog databases.</li><li>Similar to triple-store models but more generalized.</li><li>Instead of a triplet (subject, predicate, object), we write predicate(subject, object)</li><li>Powerful approach because rules can be combined and reused in different queries.</li><li>Less convenient for one-off queries, but useful if data is complex.</li></ul><h3>Summary</h3><ul><li>Document databases target usecases where data comes in self-contained documents and relationships between one document and another are rare.</li><li>Graph Databases go in opposite direction, targetting use cases where anything is potentially related to everything.</li></ul><h3>Chapter 3: Storage and Retrieval</h3><p>Indexes: Well chosen indexes speed up read queries, but every index slows down writes. <br>Log: an append only sequence of records.</p><h3>Hash Indexes</h3><ul><li>Indexes for key-value data</li><li>Compaction: throw away duplicate keys in the log, keep only the most recent update for each key.</li><li>Merging: When compaction makes each data segment smaller and smaller, segments can be merged together to save space.</li><li>Segments are never modified after they are written.</li><li>Merging and compaction are done in a background thread.</li><li>Read requests served using old segment files, and write requests to latest segment file. After merging process is complete we switch read requests to using the new merged segment instead of the old segments — and then the old segment files can be deleted.</li></ul><h3>SSTables and LSM-Trees</h3><ul><li>Sequence of key-value pairs are sorted by keys.</li><li>Sorted String Table — SSTable</li><li>Log Structured Merge Trees — LSM Trees</li><li>New key value pairs are appended to the segment immediately.</li></ul><p>Advantages over log segments and hash indexes:</p><ol><li>Merging segments is simple and efficient — uses an approach similar to the merge sort algorithm. When multiple segment contain values for the same key we can disregard all values for that key from all but one segment. Only one segment is used because each segment contains values from one time period, therefore only one segment contains the latest values for a key.</li><li>Sparse offsets — Dont need to keep an index for all keys in memory. Because all keys are sorted, we just need to keep indexes to some keys and calculate offsets.</li><li>Compression — blocks of records are compressed and stored in once place.</li></ol><p><strong>Constructing and maintaining SSTables</strong></p><ul><li>AVL Trees, Red/Black Trees, B Trees</li></ul><p><strong>LSM Trees</strong></p><ul><li>Keep a cascade of SSTables that are merged in the background.</li><li>Even if data is much bigger than the available memory, it continues to work well.</li><li>Because data is stored in sorted order, you can efficiently perform range queries.</li><li>Because disk writes are sequential, the LSM trees can support remarkably high throughput.</li></ul><p>Algorithm:</p><ol><li>When a write comes in, add it to an in-memory balanced tree (memtable)</li><li>When memtable gets bigger than some threshold, write it to the disk as an SSTable file. Efficient because tree already maintains the key-value pair sorted by keys. New SSTables become the latest segment of the database. When new SSTable is being written to the disk, writes continue on a new memtable instance.</li><li>To serve a read request, first try finding the key in the memtable, then the most recent SSTable and then older ones.</li><li>Periodically in background run merging and compaction process to combine older segments and to discard overwritten and deleted values.</li></ol><p><strong>Performance optimizations</strong></p><ul><li>LSM-Tree can be slow when looking up keys that do not exist in the database</li><li>Need to use Bloom Filters — check existence of keys.</li></ul><p>Strategies to order and time of SSTable merge and compaction</p><ul><li>Size Tiered compaction — newer and smaller SSTables are successively merged into older and larger SSTables</li><li>Leveled compaction — key range is split up into smaller SSTables and older data is moved into separate levels — allows compaction to proceed more incrementally and use less disk space.</li></ul><h3>B-Trees</h3><ul><li>key-value pairs are sorted by keys</li><li>break DB into fixed sized blocks or pages.</li><li>variable pages of fixed size</li><li>Each level may have a different branch factor.</li><li>Balanced: a B-Tree with n keys always has a depth of O(log n).</li><li>Most databases can fit into a B tree with 3 or 4 levels — a 4 level tree of 4 KB pages and branching factor of 500 can store 256 GB.</li></ul><p><strong>Algorithm:</strong></p><ul><li>To update value, search for the leaf page containing that key, change the value and write the page back to disk. All references remain valid</li><li>To add a new key, find the page whose range encompasses. the new key and add it to that page. Free up space in the page if required by splitting up the page into 2 half full pages.</li></ul><p><strong>Reliability</strong></p><ul><li>overwriting data to disk does not change the location of the page</li><li>Use Write-ahead logs to increase resiliency to crashes — append only file to which every BTree modification must be rewritten before it is applied to the pages of the trees.</li><li>Use Write ahead logs to restore B Tree after crashes.</li></ul><p><strong>Optimizations</strong></p><ul><li>Instead of Write Ahead Logs, use Copy on Write scheme for concurrency control, snapshot isolation and repeatable reads.</li><li>abbreviate keys because the entire string information is not needed.</li><li>Leaf pages mah have pointers to the left and right children as a scanning optimization</li></ul><h3>Comparing BTrees and LSM Trees</h3><ul><li>LSM Trees are typically faster for writes, where as B Trees are faster for reads.</li><li>Write amplification — data must be written multiple times — cause a direct performance cost — high IO bandwidth.</li><li>BTrees — data is written first to the Write ahead log and then to the leaf page</li><li>LSMTrees — data is written to the latest segment/SSTable, but multiple times again in the compaction and merge process.</li><li>LSMTrees can be compressed better compared to BTrees.</li><li>Compaction process on LSM trees can interfere with the performance of ongoing read and writes. At high write throughput, the disk’s finite write bandwidth need to be shared between initial write and the compaction thread running in the background.</li><li>Compaction may get starved — not able to keep up with rate of incoming write requests.</li><li>BTrees — all data is in one place, therefore they are more attractive for strong transactional semantics.</li></ul><p><strong>Values in the index</strong></p><ul><li>Could store either the entire row in the DB, or a reference to a row stored somewhere else.</li><li>A clustered index is when the row is stored directly within the index. Secondary indexes refer to the primary keys.</li><li>If storing a reference to a row, the place where it is actually stored is called a heap file. A heap files stores data in no particular order. Heap file approach is common because then there can be multiple indexes to the same heap file.</li><li>Covering indexes or indexes with included columns are a compromise between clustered index or a non-clustered (heap file) index. Some queries are faster than the rest.</li></ul><p><strong>Multi-column indexes</strong></p><ul><li>concatenated index: combine several fields into one key by appending one column to another.</li><li>Geospatial data : query latitude and longitude information.</li><li>Space-filling curves</li><li>R trees (specialized spatial index)</li></ul><p><strong>Full Text Search and Fuzzy Indexes</strong></p><ul><li>How to search for similar keys, misspelled words ?</li><li>Lucene</li><li>Levenshtein automation to find words within given edit distance.</li></ul><p><strong>In-Memory Databases</strong></p><ul><li>Memcached</li><li>Faster not just because of memory paging, but also because they avoid the need to encode information when writing/reading from disk.</li></ul><h3>Transaction Processing or Analytics</h3><ul><li>OLTP: Online transaction Processing</li><li>OLAP: Online Analytics Processing</li></ul><p>PropertyOLTPOLAPMain Read PatternSmall number of records per query, fetched by keyAggregate over large number of recordsMain Write PatternRandom Access, low latency writes from user inputBulk import (ETL) or StreamPrimarily UserEnd user/customer via web applicationInternal Analyst, for decision supportDataLatest state of data, current point in time.History of events that happened over timeData SizeGigabytes to terabytesTerabytes to petabytes</p><h3>Data Warehousing</h3><ul><li>Separate database that analysts can query without affecting OLTP.</li></ul><h3>Stars and Snowflakes</h3><ul><li>Star Schema</li><li>Fact table — individual events, extreamely large</li><li>Dimension tables — who, what, where, when, how and why.</li><li>Snowflake Schema</li><li>dimensions are broken down into sub-dimensions.</li><li>more normalized than start schemas.</li></ul><h3>Column Oriented Storage</h3><ul><li>stores all values from the same column together.</li><li>if each column is a separate file, then a query only needs to read 1 file.</li><li>Relies on all files containing rows in the same order.</li></ul><p><strong>Column Compression</strong></p><ul><li>bitmap encoding : Limited number of distinct values within a column.</li><li>create n separate n bitmaps representing individual values.</li><li>if n is very large, additional compression using run-length encoding.</li></ul><h3>Chapter 4: Encoding and Evolution</h3><h3>Evolvability</h3><ul><li>Server side applications need rolling upgrades, deploying new versions to a few nodes at a time.</li><li>Client side applications are usually at the mercy of the user who may not install the updates for some time.</li></ul><p><strong>Backward Compatibility</strong></p><ul><li>Newer code can read data that was written by old code.</li></ul><p><strong>Forward Compatibility</strong></p><ul><li>Older code can read data that was written by newer code.</li></ul><h3>Formats for Data Encoding</h3><p>2 different representations:</p><ol><li>In Memory — data is kept in objects, structs, lists, arrays, etc. Optimized for efficient access by CPU.</li><li>On disk or network — Data is encoded in some self-contained sequence of bytes.</li></ol><p>A translation is required between these 2 representations. <br>In Memory → Byte Sequence : Encoding/serialization/marshalling<br>Byte Sequence → In Memory : Decoding/parsing/deserialization/unmarshalling</p><h3>Language Specific Formats</h3><ol><li>Limited Cross language support</li><li>Decoding process needs to be able to instantiate arbitrary classes — security problems.</li><li>Versioning data is often an afterthought.</li><li>Efficiency is also usually an afterthought.</li></ol><h3>JSON/XML/Binary Variants</h3><ul><li>Standardized encoding formats, cross compatible.</li><li>XML — too verbose</li><li>JSON — too simple compared to XML</li><li>CSV — less powerful</li></ul><p>Problems:</p><ol><li>Ambiguity in encoding: eg, XML and CSV cannot distinguish between string and number datatypes. JSON cannot does distinguish integers and floating point numbers, no precision.</li><li>large numbers not supported</li><li>JSON/XML support Unicode, but not binary.</li><li>Optional schema support for XML/JSON. No support for CSV.</li></ol><p><strong>Binary Encoding</strong></p><ul><li>Save space.</li><li>Sacrifice readability</li><li>Example: MessagePack</li></ul><p><strong>Thrift and Protocol Buffers</strong></p><ul><li>Binary encoding libraries that require a schema for any data that is encoded.</li><li>Thrift Binary Protocol and Thrift Compact Protocol.</li></ul><p><strong>Avro</strong></p><ul><li>Binary encoding format</li><li>Uses schema to specify the structures of the data being encoded.</li><li>Binary data can only be decoded correctly if the code reading the data is using the exact same schema as the code that wrote the data. Any mismatch would result in incorrectly decoded data.</li><li>It uses 2 schemas — writer schema and reader schema — to support schema evolution.</li><li>The 2 schemas dont have to be the same, just compatible.</li><li>Avro library knows both the schema versions used and is responsible for translation.</li><li>Explicit nulls — prevent bugs.</li></ul><p><strong>Dynamically generated schemas</strong></p><ul><li>no tag numbers in Avro schema means that Avro is friendlier to dynamically generated schemas.</li></ul><h3>The Merits of Schemas</h3><ol><li>Binary schemas are much more compact than the various text based variants since they can omit field names from the encoded data.</li><li>Schema is a valuable form of documentation, and because it is required for decoding, it is guaranteed to be always up-to-date.</li><li>Keeping a database of schemas allows you to check forward and backward compatibility of schema changes, before anything is deployed.</li><li>Users of statically typed languages can use the ability to generate code from the schemas automatically — type checking at compile time.</li></ol><h3>Modes of Dataflow</h3><ul><li>Dataflow through databases</li><li>Dataflow through service calls — REST/RPC</li><li>Dataflow through asynchronous messaging — Queues.</li></ul><p><strong>Dataflow through databases</strong></p><ul><li>forward and backward compatibility is often required for databases.</li></ul><p><strong>Different values written at different times</strong></p><ul><li>data outlives code.</li><li>rewriting/migrating data into a new schema</li></ul><p><strong>Archival Storage</strong></p><ul><li>Data dumps will typically be encoded with latest schema at that point in time.</li><li>Avro is a good fit because most data is immutable in the warehouse once it is written.</li></ul><p><strong>Dataflow through services</strong></p><ul><li>processes communicate over a network</li><li>Service Oriented Architecture/microservices architecture</li><li>Application specific APIs that only allow inputs and outputs predetermined by the business logic.</li><li>Key design goal it to make the application easier to change and maintain by making services independently deployable and evolvable.</li><li>each service is owned by one team, and that team should be able to release new versions of the service frequently, without having to coordinate with other teams.</li></ul><p><strong>WebServices</strong></p><ul><li>REST and SOAP</li><li>REST — not a protocol, but a design philosophy that builds upon principles of HTTP. It emphasized simple data formates using URLs for identifying resources and using HTTP features for cache control, authentication and content type negotiation. More popular compared to SOAP.</li><li>Favors simpler approaches</li><li>less code generation</li><li>SOAP — XML based protocol for making network API requests. Although, most commonly used over HTTP, it aims to be independent of HTTP, and avoids most HTTP features. Instead it comes with sprawling and complex multitude of related standards — The web service framework add various features.</li><li>WSDL — Web service description language describes the API of a SOAP Web Service. It enables code generation so that a client can access a remote service using local classes and method calls.</li><li>WSDL is not human readable, and SOAP messages are often too complex to construct manually.</li><li>Integration is difficult.</li><li>Inter operability between different service vendors is difficult</li></ul><p><strong>Remote Procedure Calls</strong></p><ul><li>Location Transparency: This model tries to make a request to a remote service look the same as calling a function or method in your programming language, within the same process.</li><li>However, this model is fundamentally flawed:</li><li>Local function call is predictable, either succeeds or fails. Network call is unpredictable.</li><li>Local function call either returns a result, or throws an exception, or never returns. A network call has another possible outcome: it may return without a result, due to a timeout.</li><li>If you retry a failed network request, it could happen that the previous request actually got through, and only the response was lost. Retrying could cause action to be performed multiple times, unless there is a deduplication/idempotence process.</li><li>Timing of a local call is predictable. Network call latency is wildly variable.</li><li>Local calls need only references to objects, where as network calls need encoding/decoding.</li><li>client/server may be in different languages, so RPC framework must translate datatypes from one language into another.</li><li>Current direction for RPC</li><li>New protocols : gRPC, Finagle, Rest.li</li><li>More explicit that remote request is not a local request.</li><li>They use futures, and promises to encapsulate async systems that may fail.</li><li>gRPC uses streams.</li><li>Service discovery: allowing a client to find out which IP address and port number it can find a particular service.</li><li>Data encoding and evolution</li><li>reasonable assumption is that servers are updated first, and then the clients. Therefore only need backward compatibility on requests, and forward compatibility on responses.</li></ul><p><strong>Dataflow through Messages</strong></p><ul><li>Lie between RPC and Databases.</li><li>Messages go via an intermediary — message broker.</li><li>Message brokers:</li><li>Act as buffers if the recipient is unavailable or overloaded, and thus improve reliability</li><li>It can automatically redeliver messages to a process that has crashed, this preventing loss.</li><li>It avoids the sender needing to know the IP address and port number of the recipient.</li><li>It allows one message to be sent to multiple recipients.</li><li>It logically decouples the sender from the recipient.</li><li>It is usually one-way. A sender does not expect a response or reply to the message.</li></ul><p><strong>Message Brokers</strong></p><ul><li>do not enforce any data model — message is just a sequence of bytes with some metadata.</li></ul><p><strong>Distributed Actor Frameworks</strong></p><ul><li>Actor model is a programming model for concurrency in a single process.</li><li>Logic is encapsulated within actors.</li><li>Each actor typically represents one client or entity, it will have a local state and it communicates with other actors by sending and receiving async messages.</li><li>Message delivery is not guaranteed.</li><li>Distributed actor frameworks:</li><li>actor model is scaled to application across multiple nodes.</li><li>uses a message -passing mechanism</li><li>Location transparency works better in actor model than in RPC, because the actor model already assumes that message may be lost, even within a single process.</li><li>essentially integrates a message broker and the actor programming model into a single framework.</li><li>still have to worry about forward and backward compatibility.</li><li>Example actor models:</li><li>Akka — uses java serialization by default.</li><li>Orleans — rolling upgrades using its own versioning mechanisms.</li><li>Erlang OTOP — surprisingly hard to make changes to record schemas.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f5122b5b031" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Does IT matter — Nicholas G Carr]]></title>
            <link>https://medium.com/@abhijitbhatnagar/does-it-matter-nicholas-g-carr-333aad5a2bcd?source=rss-731f3b69d9ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/333aad5a2bcd</guid>
            <category><![CDATA[business-strategy]]></category>
            <dc:creator><![CDATA[Abhijit Bhatnagar]]></dc:creator>
            <pubDate>Sun, 03 Jul 2022 06:02:03 GMT</pubDate>
            <atom:updated>2022-07-03T06:02:03.626Z</atom:updated>
            <content:encoded><![CDATA[<h3>Does IT matter — Nicholas G Carr</h3><p>Recommended by: Amol Rao</p><p>Infrastructure technologies give an early strategic advantage. If they are successful, they are rapidly standardized and commoditized and ultimately become ubiquitous that they are no longer visible to the end customer. In the long run, adoption of infrastructural technologies become a necessity for competitive parity, but do not provide any competitive advantage.</p><p>My learning from this book is that to create a successful infrastructure technology, I need to focus on building services that give a single customer initial strategic advantage in the short run. By building in best practices and processes into the system, the infrastructure technology will, in the long run, becomes a competitive parity for all customers. The infrastructure technology should be (1) rapidly commoditized — I should focus on finding customers I can serve first, (2) it should have a high technological replication cycle so that my customers get a sustainable advantage and build leverageable advantages by enabling customers to step into new business domains. I should be frugal with designs so that my infrastructure technology does not overshoot my customer’s requirements and becomes stale in the long run.</p><h3>Notes:</h3><p>I agree with the ideas presented in this book because I can relate some of the analogies presented in this book with some of my own observations in the software industry.</p><ul><li>Software Industry at Amazon is similar to the small shops at Nehru Place.</li><li>Competition is for losers — there is something about software that lends itself to rapid commoditization even with low initial investment. — Peter Thiel`</li><li>For an infrastructure technology company like Amazon, eCF and Traffic Engineering, our focus should be on building technologies that can help provide a competitive advantage to other organizations today, and in the future build competitive parity for every other organization.</li><li>Amazon prototypes by keeping a customer in mind. American airlines gained a competitive advantage by working with IBM to develop Sabre — an automated reservation system. IBM then helped the airline industry be developing a generic system — PARS that IBM peddled to other airlines with considerable success. However, it did not matter that United’s apollo was superior to American’s Sabre because American had already made Sabre the dominant reservation system used by travel agents.</li><li>Building in best practices into the infrastructure technology helps with standardization and rapid commoditization.</li></ul><h3>Ideas that were new to me:</h3><ul><li>Overshooting — This idea while not new, is definitely something I had not thought about before</li><li>Success of the IT industry is defined by its innovations in the past — that most A-list organizations have all the basic technologies they need to succeed right now. I think the key here is the term right now. Maybe we should ponder on what these organizations need to succeed in the future ?</li><li>Characteristics of Hardware and Software tend to push them towards rapid standardization and commoditization, much like previous infrastructure technologies — railroads and telegraphs.</li><li>Infrastructure technologies give an early strategic advantage. If they are successful, they are rapidly standardized and commoditized and ultimately become ubiquitous that they are no longer visible to the end customer. They are a necessity for competitive parity, but do not provide any competitive advantage.</li><li>Technology replication cycle: The time it takes for competitors to copy a new technology is a crucial variable in gauging the strategic power of an IT investment. The technology replication cycle gets shorter and shorter with time. The likelihood of an early investment in a new technology paying off gets slimmer as time goes by. Today, most IT-based competitive advantages simply vanish too quickly to be meaningful.</li></ul><h3>Concepts:</h3><ol><li>Vendorization? Vendorization is the process for identification, selection, and utilization of service providers based on the qualifications and other requirements necessary in order to provide the services</li><li>Commodity ? A raw material or primary agricultural product that can be bought and sold, such as copper or coffee.</li><li>Competitive parity: Competitive parity is <strong>a budgeting method in which a company spends the same amount of money on advertising and marketing as its competitors</strong>. As a business strategy, competitive parity is designed to defend a competitive position by not overspending on promotion and marketing budgets</li><li>Competitive advantage: Competitive advantage refers to factors that allow a company to produce goods or services better or more cheaply than its rivals. These factors allow the productive entity to generate more sales or superior margins compared to its market rivals. Competitive advantages are attributed to a variety of factors including cost structure, <a href="https://www.investopedia.com/articles/financial-theory/11/branding-ultimate-economic-moat.asp">branding</a>, the quality of product offerings, the <a href="https://www.investopedia.com/terms/d/distribution-network.asp">distribution network</a>, intellectual property, and customer service.</li></ol><h3>Vanishing Advantage</h3><p>Insights: Profitability results suggest that, on average, firms are making the IT investments necessary to maintain competitive parity but are not able to gain competitive advantage.</p><ul><li>IT is a competitive necessity for banks, but do not provide any competitive advantages.</li></ul><p>Locking in Advantage:</p><ul><li>Strategy should lock in advantage early on with tech investments.</li></ul><p>Locking out competitors:</p><ul><li>Although American Hospital Supply successfully locked out competitors by using proprietary software -ASAP, within a decade their barriers to competition crumbled with the arrival of personal computers, packaged software and network standards. Proprietary software was now unattractive to users and uneconomic to owners because of its closed nature.</li><li>Abhijit : I think AHS failed because they did not standardize and commoditize their software.</li></ul><p>Technology Replication Cycle:</p><ul><li>Late movers are sometimes able to match a pioneers/early mover’s competitive advantage if the technology replication cycle is low.</li></ul><p>Homogenization of processes:</p><ul><li>With enterprise systems, businesses must often be modified to fit into systems. The good news is that the generic processes imposed by enterprise systems often reflect state of the art and have inbuilt best practices. Replicating these best processes is crucial to a vendor’s success. The bad news is that generic processes that standardize the use of technology provide little room for a company to distinguish itself.</li><li>While most companies once thought that their business processes were too unique to use configurable software, transportation managers are quickly realizing that leveraging industry best practices far outweigh the benefits of perpetuating a unique process.</li><li>However, smart companies know that distinctive processes lie at the heart of competitive advantage.</li></ul><p>Emergence of dominant designs:</p><ul><li>Having insights into how IT might transform or give rise to entire industries.</li><li>It doesnt take long for dominant designs — the optimal way of doing business that incorporates the new technology — to emerge in an industry and for all companies to adopt it.</li><li>IT buildout is much closer to its end than its beginning:</li><li>power of IT is outstripping most of the business needs it fulfills (already overshooting)</li><li>price of essential IT functionality has dropped to the point where it is more or less affordable to all</li><li>capacity of universal distribution network has caught up with demand.</li><li>leading IT vendors are rushing to position themselves as suppliers of “on-demand” infrastructure services — as utilities.</li><li>an enormous investment bubble has expanded and burst — historically indicated that an infrastructure technology is reaching the end of its buildout.</li><li>Period of adoption of a new and broadly used technology is divided into two phases:</li></ul><ol><li>installation period: technology advances like a bulldozer disrupting the established fabric and articulating new industrial networks, setting up new infrastructures and spreading new and superior ways of doing things.</li><li>deployment period: when the focus of innovation and adaptation shifts from the technology itself to the surrounding institutional framework and capital markets and regulatory regimes are reshaped to fit the new infrastructure.</li><li>Between the above two phases, there comes a turning point: which is usually an economic recession following a period of frantic investment in the new industry and the infrastructure, stimulated by a stock market boom that usually becomes a bubble. The collapse of the bubble signals that a new infrastructure is un place, and that the new ways of doing things with the new technologies has become common sense.</li></ol><h3>The universal strategy solvent</h3><ul><li>Solvent as in dilution. IT is able to blur/dissolve competitive advantages businesses previously held.</li></ul><p>Infrastructural technologies lose much of their power to provide a competitive advantage as they mature, but they dont lose their power to destroy traditional competitive advantage.</p><p>Sustainable advantage and Leverageable Advantage:</p><ul><li>Single-mindedness in establishing and defending their privileged industry positions set Dell and Walmart apart.</li><li>Strategy today therefore requires a broader and more nuanced definition of competitive advantage, one that encompasses traditional sustainable advantages, but also includes more transient leverageable advantages. A leverageable advantage can be defined as a privileged market position that, however fleeting, provides a stepping stone to another privileged position. Unlike a sustainable advantage, a leverageable advantage is a way station, not a destination. But like a sustainable advantage, a leverageable advantage is a manifestation of deep and disciplined strategic thinking. It’s more than just a reaction to current events; its a deliberate move that builds on the past and prepares for the future.</li><li>The shared IT infrastructure will continue to dissolve operating advantages, particularly those based on the superior execution of an isolated, transaction-intensive process or activity. But more complex positioning advantages — those derived from broad and tightly integrated combinations of processes, capabilities and technologies will continue to resist rapid emulation. Successful companies will therefore work to establish and protect distinctive strategic positions even as they use more temporary competitive advantages as stepping stones to new advantages.</li></ul><p>In praise of walls</p><ul><li>One of the central strategic challenges now facing managers is figuring out how to defend their companies’ competitive advantages — many of which are built on the proprietary control or distinctive use of information, while at the same time allowing information to flow freely in and out of their organizations through the general IT infrastructure.</li><li>Companies will tend to get bigger as external transactions cost increase and to shrink as the costs decrease.</li></ul><p>Bifocal Views:</p><ol><li>Industry based view: successful strategy hinges upon a clear understanding of an industry’s economic and competitive structure. The challenge for a company’s leader is to figure out how to position their firm in such a way that it is able to capture the largest possible share of industry profits. They begin by looking outside.</li><li>Resource-based view: strategy lies within a company’s distinctive resources or capabilities. The challenge for a company’s executive is to figure out what the company does best and then turn that core competency into an advantage over the competition. Strategy making begins by looking inside.</li></ol><h3>Managing the Money Pit</h3><p>When a resource becomes essential to competition but inconsequential to strategy,the risks it creates become more important th an the advantages it creates.<br>Early in their progress, Particularly during and after their build out, infrastructural technologies Present grave risks.<br>Many failures are in evitable, a natural consequence of the Process of trial and errol that goes On as new technology is adopted by a business.<br>As intrastructure matures, the companies that succeed will not be those that reflexively pursue innovation, that seek to push the proverbial envelope, but rather those that are pragmatic in planning and competent in execution.</p><p>Spend Less</p><ul><li>overspending is the greatest risk.</li><li>Separate essential investments and activities from ones that are discretionary,unnecessary or Counterproductive.</li><li>Companies need to make sure that they get value out of Past investment before making new ones.</li></ul><p>Follow, Dont Lead:</p><ul><li>Spend more slowly.</li><li>small delay in Purchases can dramatically reduce the cost of achieving a given level of IT functionality.</li><li>smartest users of technology stay well back from the cutting edge, waiting to make their purchases until standards And best Practices Solidify and Prices fall. They let their more impatient competitors Sholder the high cost of experimentation.</li><li>By Pushing Costs to the suppliers, walmart gained the advantage of being a first mover without incurring the risk. It used its enormous market power to put itself in a no- lose situation.</li><li>Companies can Also reduce the risk by pursuing innovations that competitors would have a hard time adopting.</li></ul><p>Innovate when risks are low<br>Focus more on Vulnerabilities than opportunities</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=333aad5a2bcd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>