<?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 Alexis McKenzie on Medium]]></title>
        <description><![CDATA[Stories by Alexis McKenzie on Medium]]></description>
        <link>https://medium.com/@lexmckenz?source=rss-cebaae6b1b67------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fp5x5Cmd1sfi1GMPUBz9KQ.jpeg</url>
            <title>Stories by Alexis McKenzie on Medium</title>
            <link>https://medium.com/@lexmckenz?source=rss-cebaae6b1b67------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 12:13:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lexmckenz/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[Demystifying Azure Structure and Permissions Fundamentals]]></title>
            <link>https://blog.newmathdata.com/demystifying-azure-structure-and-permissions-fundamentals-05f37b1d85f5?source=rss-cebaae6b1b67------2</link>
            <guid isPermaLink="false">https://medium.com/p/05f37b1d85f5</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[azure-active-directory]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[microsoft-entra-id]]></category>
            <dc:creator><![CDATA[Alexis McKenzie]]></dc:creator>
            <pubDate>Thu, 17 Sep 2026 15:01:08 GMT</pubDate>
            <atom:updated>2026-09-17T15:13:39.729Z</atom:updated>
            <content:encoded><![CDATA[<h4>A look at some core Azure concepts, how they work, fit together, and relate to AWS concepts</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_QNL3SWyzoqwG8aq2Bk_EQ.png" /><figcaption>ChatGPT made this where the “decoder wheel represents Azure’s overlapping terminology”. It’s cute, so we’ll go with it.</figcaption></figure><p>It is true that at <a href="https://newmathdata.com/">NMD</a>, we largely operate in the <a href="https://aws.amazon.com/">AWS</a> ecosystem, but sometimes our customers operate in a multicloud setup, and occasionally we work on <a href="https://azure.microsoft.com/en-us">Azure</a>-native projects. As a result, I have been working a decent amount in Azure lately. While the agents have helped me set up my Terraform and operate effectively with proper prompting, I found the permission structure to be confusing, and perhaps needlessly so. I think Microsoft could do a better job demystifying their structural and permissions concepts, which may endear more engineers to them and Azure. Until that happens, in this article I am hoping to clear up the core concepts and how they relate to each other, while throwing in some tidbits about how an Azure concept translates to an AWS one.</p><h3>Core Structural Concepts (in order of scope)</h3><p>These concepts are listed in the order of bucket size, i.e., from broadest scope to most specific.</p><p>Generally speaking, <strong>tenant IDs, subscription IDs, resource groups, and resources describe where things live in Azure</strong>, while <strong>client IDs and secrets describe the identity an application uses to sign in</strong>.</p><p>The general structural flow is: <strong><br>Tenant →(Management Group)-&gt;Subscription → Resource Group → Resource</strong></p><h4><em>Tenant ID</em></h4><p>This is the highest level of access, the organizational layer. Many companies would just have one of these. This is where your organization and Entra (formerly Azure Active Directory) permissions are configured at the user, group, application identity, and directory level. Application identities live in the tenant and can be granted permission to access a subscription, resource group, or individual resource.</p><p>It is important to understand that belonging to a tenant does not automatically give you access to its subscriptions or management groups. This is why the Azure CLI can recognize your account in a tenant while also reporting that the tenant does not contain any subscriptions you can access.</p><p>When you run an az login command, you will be prompted to include a tenant ID if you have access to multiple organizations, which establishes the scope of your CLI interactions.</p><pre>az login --tenant 41c96d6c-abcd-1234-abcd-1234567890ab</pre><h4>Management Group</h4><p>Management groups are optional containers used to organize multiple subscriptions. Large organizations use them to apply policies, access controls, and governance requirements across groups of subscriptions. For a small Azure environment, you may not need to interact with them directly.</p><p>Management groups are not required and you may very well have subscripions under a management group. This concept is most similar to an organizational unit (OU) in AWS as it is a grouping of accounts that can share the same policies and Entra access.</p><h4>Subscription ID</h4><p>This part was the most confusing to me at first. I was puzzled by questions like: How do I decide what should go into the same subscription? Is a subscription an application boundary, a billing boundary, or an access boundary?</p><p>The answer is that it can be all three. And my understanding was also somewhat improved by understanding Management Groups better.</p><p>A subscription is a container for Azure resources and serves as a billing, governance, access-control, and quota boundary. Every subscription has a unique subscription ID and is associated with one Microsoft Entra tenant.</p><p>Resources might be placed in separate subscriptions when they have different:</p><ul><li>Billing owners or budgets</li><li>Security or compliance requirements</li><li>Administrative teams</li><li>Environments, such as development and production</li><li>Policies or resource quotas</li></ul><p>However, not every application needs its own subscription. Smaller organizations might keep several applications in one subscription and separate them using resource groups. Larger organizations often use different subscriptions to create stronger boundaries between teams, workloads, or environments.</p><p>The concept of subscriptions is most similar to using different accounts in AWS. You may have a subscription for your dev environment for a particular product and another for your production environment, for example.</p><h4><strong>Resource Group</strong></h4><p>A resource group is a logical container inside a subscription. It holds related Azure resources, such as an application’s web service, database, storage account, and monitoring resources.</p><p>Resource groups are often based on a workload, application, environment, or lifecycle. If several resources are deployed, managed, and removed together, placing them in the same resource group usually makes sense.</p><h4><strong>Resource</strong></h4><p>A resource is an individual configurable Azure service instance, such as a virtual machine, storage account, virtual network, Azure Function, Key Vault, or database.</p><p>This is the most specific level of the Azure resource hierarchy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vi0aRy8eUTiCUPEk9rwHiQ.png" /><figcaption>How the Tenant, Management Group, Subscription, Resource group, and Resources might fit together</figcaption></figure><h3>Application Identity and Authentication</h3><p>The remaining terms do not represent progressively smaller resource containers. Instead, they describe how an application identifies and authenticates itself to Azure.</p><h4><strong>App Registration</strong></h4><p>An app registration creates an identity configuration for an application in Microsoft Entra ID. This allows Entra to recognize the application and control what it is permitted to access.</p><p>When an app is registered, Azure creates an application object and, in its home tenant, a corresponding service principal. The application object describes the application, while the service principal represents that application’s identity and permissions within a particular tenant.</p><h4><strong>Application ID / App ID</strong></h4><p>The application ID uniquely identifies the registered application. Azure CLI output frequently labels this value appId.</p><p><strong>Client ID</strong> — The client ID is generally another name for the application ID, which confused me for more time than I am proud. It is <em>not</em> a separate credential or a lower level in the hierarchy.</p><p>For example, an authentication configuration might contain:</p><pre>Tenant ID:       Which Entra directory should authenticate me?<br>Subscription ID: Which Azure subscription am I trying to access?<br>Client ID:       Which application identity am I using?<br>Client Secret:   How does that application prove its identity?</pre><p>The client ID is an identifier, not a secret. It can usually appear safely in configuration, although there is rarely a reason to publish it unnecessarily.</p><h4><strong>Client Secret</strong></h4><p>A client secret is a credential created for an app registration. The application supplies its client ID and client secret to authenticate with Microsoft Entra ID.</p><p>Unlike the client ID, the <em>client secret must be protected</em>. It should be stored in a secure location such as Azure Key Vault or a CI/CD secret store and should <em>never</em> be committed to source control.</p><p>Client secrets also expire. The application will no longer be able to authenticate after expiration unless the secret is rotated or replaced.</p><p>When possible, Microsoft recommends using a<a href="https://learn.microsoft.com/en-us/security/zero-trust/develop/identity-non-user-applications"> managed identity instead of a client secret for applications running in Azure</a>. A managed identity allows Azure to manage the application’s credentials so that you do not have to store or rotate a secret yourself.</p><h4><strong>Password</strong></h4><p>With respect to app identity and authentication, password may simply be the name Azure CLI uses for the value of a newly created client secret. It is not necessarily your personal Microsoft or Azure password.</p><p>For example, service-principal creation might return values resembling:</p><pre>{<br>  &quot;appId&quot;: &quot;application-or-client-id&quot;,<br>  &quot;password&quot;: &quot;client-secret-value&quot;,<br>  &quot;tenant&quot;: &quot;tenant-id&quot;<br>}</pre><p>In that output:</p><ul><li>appId is the application ID, also called the client ID.</li><li>password is the client secret value.</li><li>tenant is the tenant ID.</li></ul><p>The terminology is unnecessarily inconsistent, but the most important relationship to remember is:</p><ul><li>App ID = Application ID = Client ID</li><li>Password, in service-principal CLI output = Client Secret</li></ul><p>A client secret should not be confused with a human user’s password. Applications should use managed identities, workload identity federation, certificates, or client secrets rather than storing someone’s personal Azure credentials.</p><p>Azure is a perfectly great cloud provider, and the resources are easily managed through Terraform much like they are in AWS, as long as you can understand the fundamentals. Hope this helps demystify the structural and authentication lingo and hierarchy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05f37b1d85f5" width="1" height="1" alt=""><hr><p><a href="https://blog.newmathdata.com/demystifying-azure-structure-and-permissions-fundamentals-05f37b1d85f5">Demystifying Azure Structure and Permissions Fundamentals</a> was originally published in <a href="https://blog.newmathdata.com/">newmathdata</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Electrical Grid Fundamentals]]></title>
            <link>https://blog.newmathdata.com/electrical-grid-fundamentals-150a82cd780f?source=rss-cebaae6b1b67------2</link>
            <guid isPermaLink="false">https://medium.com/p/150a82cd780f</guid>
            <category><![CDATA[energy]]></category>
            <category><![CDATA[utilities]]></category>
            <category><![CDATA[power-grid]]></category>
            <category><![CDATA[electrical-engineering]]></category>
            <category><![CDATA[power]]></category>
            <dc:creator><![CDATA[Alexis McKenzie]]></dc:creator>
            <pubDate>Thu, 14 May 2026 15:01:01 GMT</pubDate>
            <atom:updated>2026-05-18T17:35:52.526Z</atom:updated>
            <content:encoded><![CDATA[<h4>An ELI5 Explanation of Electricity and the Power Grid</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*07I4XfAIpOOC-ZfmDb0wOQ.png" /><figcaption>Yup, ChatGPT made this image with direction</figcaption></figure><p>The electrical grid is an amazing system wherein power is used almost exactly when it is generated. I love learning more about it, and I am blessed to work with and lead some amazing teams in the electrical grid planning space. It has taken me a fair bit of effort, a few electrical engineering classes I was fortunate enough to meet the prerequisites for*, much bugging of some of my favorite electrical engineers, getting things wrong and being corrected, and <em>a lot</em> of YouTube (shoutout to <a href="https://www.youtube.com/@PracticalEngineeringChannel">Practical Engineering</a>) to feel like I actually understood the fundamentals of the electrical grid. And there is loads I <em>still</em> don’t know. So, my objective in this article is to explain the fundamental pieces at a level more people can understand!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wVTZcZVdmkzxPAm_" /><figcaption>*I know, silly me. I didn’t just learn electrical engineering concepts from <a href="https://claude.ai/new">Claude</a>, though he did help along the way and continues to. Photo by <a href="https://unsplash.com/@silverkblack?utm_source=medium&amp;utm_medium=referral">Vitaly Gariev</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>So, what is electricity?</h4><p>Electrons moving through a conductor creates an electrical current that results in electricity. But electrons don’t really flow in the way most people imagine. The wires already contain electrons, so it&#39;s more like marbles in a tube: when you push a new marble in the negative side (voltage), an electron is pushed out the other end, the positive end, thus creating a current. This results in electricity created virtually instantaneously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yCaQcf0aOmalgjTlj-zF7A.png" /><figcaption>Electrons like marbles in a tube</figcaption></figure><h4>Where does power come from?</h4><p>There are three core parts to the electrical grid: generation, transmission, and distribution. These core pieces also define the main business<br>structure within the electric power industry and markets.</p><p><strong><em>Generation</em></strong><em><br></em>Electric generation converts mechanical energy into electrical energy using generators driven by turbines powered by steam, water, wind, gas, or diesel engines. Common generator types include synchronous generators, induction generators, and permanent-magnet generators. A<a href="https://www.allaboutcircuits.com/textbook/alternating-current/"> step-up transformer</a> is often required to facilitate the transition from generation to transmission to bring the voltage to the correct (high) value.</p><p>By raising the voltage, step-up transformers allow power to travel long distances more efficiently and with lower energy losses. Sending the same power at a lower voltage would require higher current, thicker conductors,<br>and much more expensive infrastructure to build and maintain. Beyond the technical problem, power grids are always trying to keep the construction and operational costs as low as possible.</p><p><strong><em>Transmission<br></em></strong>Transmission systems are a great big synchronized machine. AC transmission grids are a network of generators locked together by electromagnetic coupling, wherein any new generator must match various characteristics of the whole system:</p><ul><li>frequency</li><li>voltage magnitude</li><li>phase angle</li><li>phase sequence</li><li>grid inertia</li></ul><p>And if new generators don&#39;t match these characteristics, the equipment trying to connect is damaged. Fortunately, <a href="https://selinc.com/engineering-services/synchronization/">autosynchroscopes</a> make this connection and disconnection process easier, and many generators have mechanisms that allow repairs to be made while the equipment is still “on”. As a result, everything in an <a href="https://www.energy.gov/oe/learn-more-about-interconnections">interconnection</a> operates at the same frequency. To me, this is mind-bogglingly beautiful: imagining generators at the <a href="https://en.wikipedia.org/wiki/Callaway_Nuclear_Generating_Station">Callaway Plant</a> having the same frequency, which is standardized to 60 Hz (cycles per minute), as the <a href="https://illumination.duke-energy.com/articles/historic-hydro-power-station-on-the-catawba-wateree-river-turns-100">Wateree Hydro Station</a>. 60 Hz is the standard in the US, but other countries might have different standards. 50 Hz, for example, is a common standard in large parts of Europe, Asia, and South America. Because power systems in different countries may operate at different nominal frequencies, cross-border energy exchange often relies on <a href="https://www.energy.gov/oe/articles/connecting-country-hvdc">HVDC links</a> for conversion.</p><p>The grid has a natural tendency to resist sudden changes in frequency and other metrics, <em>a la</em> grid inertia. This concept is fundamental because it helps explain the mechanical behavior that enables large generators to synchronize with the grid. It also explains why power engineers are concerned with connecting inverter-based energy resources, which do not naturally provide inertia and therefore complicate interconnection. As more inverter-based resources like solar PV and battery systems connect to the grid, system inertia can decrease because they do not naturally provide large rotating mass like traditional synchronous generators. To address this, many inverter-based resources now use controls that simulate inertia during grid connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3n0x7B4A89dvmYEcTeF6gA.png" /><figcaption>Generated by ChatGPT with some guidance</figcaption></figure><p>These transmission systems are a <em>meshed network</em> with many interconnected paths, which promotes redundancy and therefore reliability and stability. N-1 Security is built into the system, largely organically, which means that a line, a transformer, or a generator can be lost without power failure. This allows power markets to function so that, for example, <a href="https://cleanview.co/wind-farms/missouri">wind in Missouri</a> can serve New York City.</p><p>Transmission systems have high reactance compared to resistance because at high voltage, conductors are large, which yields low resistance.</p><p>X/R = reactance/resistance</p><p>Lines are long and widely spaced, which results in higher inductance but generally low line losses; inductance is a property of conductors where they tend to oppose changes in electrical current by storing energy in a magnetic field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*EwypPnktScPzK8e8.jpg" /><figcaption>Capacitor image from <a href="https://www.build-electronic-circuits.com/capacitor-values/">https://www.build-electronic-circuits.com/capacitor-values/</a></figcaption></figure><p>Capacitive reactance is another important consideration in transmission systems, which is the reason lines are typically so high above the ground; here, there is an electrical field between the earth and the ground. This can result in overvoltage during periods of low load demand. In general, capacitors are temporary batteries that charge and discharge rapidly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*Rie8RaQs9ecSAv75HoboKQ.png" /><figcaption>Generated by ChatGPT with some guidance</figcaption></figure><p>Transmission systems are also typically assumed to be <a href="https://www.actionpowertest.com/glossary/three-phase-power-system">balanced three-phase</a> (A, B, and C), even though they reach those peak values at different times.</p><p><strong><em>Distribution<br></em></strong>While transmission systems form a <em>meshed</em> network, distribution systems, which start at the substation between high-voltage transmission systems and lower-voltage distribution systems, are either <em>radial</em> or <em>looped.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VY7t-tRH_gs0puucCEPjSg.png" /><figcaption>Generated by ChatGPT with some guidance</figcaption></figure><p>As hinted at in the above image, radial systems are a bit less reliable because if there is an outage, everyone downstream is impacted. These types of systems are typically found in rural or older neighborhoods. Depending on where the fault occurs, it could impact the whole neighborhood or perhaps just those with the same service drop, which could possibly be only a few service points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AmmAym2ZPxfpN-wNT_gBeA.png" /><figcaption>Generated by ChatGPT with much guidance</figcaption></figure><p>The voltage in the distribution system is significantly reduced from the voltage of a transmission system. While transmission systems may see voltages up to about 765 kV, they&#39;re usually about 230 kV at the substation, and about 240 V at an individual service point. This reduction happens through a series of <a href="https://taishantransformer.com/step-up-vs-step-down-transformer/">step-down transformers</a>.</p><p>Whereas transmission systems have high X/R ratios, distribution systems have low X/R ratios. Lines are thinner and less conductive, the lines are shorter and closer together, and they operate at a lower voltage. All this results in a reduction in reactance, which makes resistance more prominent.</p><h4>Does all the power generated get used up?</h4><p>Well, not exactly. There are different sources of loss along the way.</p><p><strong><em>Generation Losses<br></em></strong>Different generation technologies have different dominant losses, though some of the losses found in transmission systems also apply here. So, losses are not as streamlined as they are in transmission and distribution parts. Generation losses could be:</p><ul><li><strong>Steam plant losses</strong> → Steam plants lose large amounts of energy as waste heat because thermal energy cannot be perfectly converted into mechanical and electrical energy due to limits described by the Second Law of Thermodynamics. Heat is commonly lost through cooling towers, condensers, exhaust gases, and auxiliary equipment like pumps and fans.</li><li><strong>Wind turbine losses</strong> → Wind turbines experience aerodynamic losses because blades cannot capture all of the wind’s energy. Turbulence, wake effects, blade-tip vortices, and imperfect blade angles reduce efficiency. Additional losses occur from friction and vibration in gearboxes, bearings, and generators.</li><li><strong>Solar PV losses</strong> → Solar panels lose energy when sunlight becomes heat instead of electricity. Reflection losses, inverter losses, wiring resistance, and semiconductor inefficiencies all reduce output. High temperatures further decrease panel efficiency by lowering voltage production.</li><li><strong>Hydroelectric losses</strong> → Hydroelectric systems are highly efficient because they directly convert moving water into rotational energy with few conversion steps. Losses mainly come from turbulence, friction in turbines and penstocks, cavitation, and electrical losses in generators and transformers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CbGWMzf6529Bw1YCLZDTpQ.png" /><figcaption>Generated by ChatGPT with some guidance</figcaption></figure><p><strong><em>Transmission Losses<br></em></strong>Transmission systems</p><ul><li><strong>Copper losses</strong> → These are also called I²R losses, where I is current, and R is resistance. Colloquially, they are called “copper losses”, though all wire materials may experience this power lost to heat, and this type of loss is most common in high-voltage/low-current systems. If the lines are hotter due to high ambient temperature, that can result in somewhat increased copper losses.</li><li><strong>Corona losses</strong> → Power will dissipate when an electromagnetic field ionizes around air molecules. This can result in a whirring noise you hear around transmission lines. It can also sometimes cause radio interference. Weather can have a big impact on corona losses; sandstorms, rain, fog, snow, and really any increase in moisture around the lines, as well as ionization in the air, can all impact the amount of corona loss.</li><li><strong>Dielectric losses</strong> → Energy can be dissipated in any insulating materials used on the transmission lines.</li><li><strong>Charging losses</strong> → Losses due to capacitive reactance (mentioned above) can result in some energy lost to the earth itself.</li></ul><p><strong><em>Distribution Losses<br></em></strong>Distribution system losses generally fall into one of two categories:</p><ul><li><strong>Technical losses</strong> → These are natural energy losses that occur as electricity moves through the physical power system. Examples include copper (I²R) losses in wires, transformer losses, reactive power effects, and small amounts of heat dissipated by equipment. Utilities reduce technical losses through better conductor sizing, higher voltages, efficient transformers, capacitor banks, automation, and grid modernization.</li><li><strong>Non-technical losses</strong> → These are losses not caused by physics, but by operational or human factors. Examples include inaccurate metering, billing errors, and electricity theft. Utilities reduce non-technical losses using smart meters, analytics, inspections, and improved operational processes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*InP_Qw3ZuVoN_0Fhs_TcOw.png" /><figcaption>Generated by ChatGPT with some guidance</figcaption></figure><h4>Conclusion</h4><p>I hope this article helped you learn about the pieces of the electrical grid (generation, transmission, and distribution) and how they fit together in an approachable way! At <a href="https://newmathdata.com/">New Math Data</a>, we have many customers in the electric utility and power space, and it is not only immensely topical for the future of humanity but deeply interesting. Please reach out or comment below if you have any related ideas you would like to discuss with us!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=150a82cd780f" width="1" height="1" alt=""><hr><p><a href="https://blog.newmathdata.com/electrical-grid-fundamentals-150a82cd780f">Electrical Grid Fundamentals</a> was originally published in <a href="https://blog.newmathdata.com/">newmathdata</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Vision for Application Observability]]></title>
            <link>https://blog.newmathdata.com/a-vision-for-application-observability-b5661c3e8ff0?source=rss-cebaae6b1b67------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5661c3e8ff0</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[performance-testing]]></category>
            <category><![CDATA[observability]]></category>
            <dc:creator><![CDATA[Alexis McKenzie]]></dc:creator>
            <pubDate>Thu, 23 Oct 2025 15:02:26 GMT</pubDate>
            <atom:updated>2025-10-23T15:02:26.039Z</atom:updated>
            <content:encoded><![CDATA[<h4>Contextualizing Your Application Logs and Metrics to Understand Your Applications Better</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4AXj60uNypxxOKhyGcO-gw.png" /><figcaption>A ChatGPT-genarated image of a man observing an application</figcaption></figure><p>There are many platforms for logging, like <a href="https://www.splunk.com/">Splunk</a>, <a href="https://www.dynatrace.com/">Dynatrace</a>, and <a href="https://prometheus.io/">Prometheus</a>, among others. But what do we <em>really</em> need to understand if our application is performing as we need it to? This depends on where the application lives and runs, though there is some similarity across architectures. This article presents a vision for making applications observable in ways that matter, are maximally useful for developers, and efficiently serve business needs. Full application observability promotes deeper knowledge of the application design and data flow across the team.</p><p>So, what do you need to know to determine if your application is working right for your users and is displaying the most up-to-date information? Here, I argue for 4 key pieces that get us there:</p><ul><li>Documentation and demonstration of microservice flow</li><li>Co-location of logs connected to pieces of the microservice flow</li><li>Application, normally UI plus API, response metrics to capture uptime and latency</li><li>Contextual cost tracking</li></ul><p>Cost tracking is included in the above list, but cost tracking and anomaly detection find themselves more situated on top of the other parts since they utilize observability data to draw more directed insights. For example, maybe you have had more runs of certain processes lately due to an increased user base. This cost data requires context to understand if it&#39;s appropriately correlated with usage or other things going on in your business and application.</p><p>Can we build a system that demonstrates application functionality in its observability platform?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XK_gwKko7raVyKZM_OLieQ.png" /><figcaption>Figure 1: Application observability components</figcaption></figure><h3>1. Have all your backend processes succeeded? If not, where did they fail within the context of that microservice flow?</h3><p>Generally, we think of this backend process observability through <em>traces. </em>Still, I believe this end-to-end nature and services like <a href="https://docs.aws.amazon.com/xray/latest/devguide/xray-console-traces.html">AWS X-Ray</a> overcomplicate or obfuscate a much simpler need most applications have, which is to understand if the core pieces of transformation, business logic, etc, that make up your application have succeeded and when they last ran.</p><p>A simpler event-based approach that runs when processes complete should suffice in most cases. An event structure I’ve used before that will hopefully help you is:</p><blockquote>{“process-name”: “&lt;name of process&gt;”,<br>“service”: “&lt;cloud or other service this is running on&gt;”,<br>“account”: “&lt;account number, etc&gt;”,<br>“grain”: “&lt;granularity of the process(es) running such as <br>“success-count”: “&lt;count of successes&gt;”, <br>“input-details”: “&lt;json object of input details with dates, run-ids or other context&gt;”,<br>“failure-count”: “&lt;count of failure&gt;”,<br>“timestamp”: “&lt;timestamp&gt;”}</blockquote><p>The key to defining this structure for yourself is that you want to <em>both</em> make it easy to identify where issues exist and co-locate your logs in one place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XFiFfKBfsc3ZU3BybWDhBA.png" /><figcaption>Figure 2: An Abstracted Microservice Flow where step 3 has failed</figcaption></figure><p>As shown in Figure 2, you want to know what all your microservices are, how the pieces flow together, and where the failure occurred. If you receive an event that 3 failed, the context of 1 and 2 succeeding and a timestamp representing when is critical to troubleshooting.</p><p>And, while many applications can help with bubbling up errors, they often do not provide sufficient value to justify the costs because a big part of the value comes from understanding where in the flow the issues exist. Shipping everything to a centralized <a href="https://www.solarwinds.com/blog/to-saas-or-not-to-saas">SaaS can add latency, cost egress, or simply be impossible in regulated, air-gapped, or edge setups</a>. But ultimately, context is everything. Whether or not these tools work for you is deeply business-dependent. Anecdotally, I’ve seen third-party observability tools work well when using many <a href="https://aws.amazon.com/what-is/distributed-computing/">distributed servers</a> or <a href="https://aws.amazon.com/pm/ec2">EC2 instances</a> or many high traffic customer sites. But, many applications just aren’t that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*PboJXaXqiCRSHiiXYw-nwQ.png" /><figcaption>Figure 3: Writing to a common event bus when processes complete</figcaption></figure><p>This image shows an example of how you might send events that are generated from distinct microservices (of which Figure 2 shows one) to a common event bus. An event bus might have too much overhead, so it could instead make sense to use a <a href="https://docs.aws.amazon.com/decision-guides/latest/sns-or-sqs-or-eventbridge/sns-or-sqs-or-eventbridge.html">messaging queue or pub/sub system</a>.</p><h4>Do all your processes have compatible data?</h4><p>Is the data that feeds your application as up-to-date as possible? Or do you know when it isn’t and why? Many systems rely on a mix of data velocities and veracities (<a href="https://www.ibm.com/think/topics/big-data">as well as variety and volume</a>), and sometimes the veracity, which is deeply tied to the value, leaves something to be desired due to time alignment issues. If some data is updated monthly and another set is updated hourly, you need to know that and clearly communicate it for system validity, synchronization, and fast troubleshooting; accounting for and recording these details in your json structure can help you track your data over time. And, this sort of record-keeping can be a great foundation for justifications to improve your larger organization’s application landscape when there are dramatic synchronization issues between systems.</p><p>For example, imagine we get weekly sales data, but real-time production data. Aside from handling any granularity differences, you should take special care to ensure your data products or systems don’t have any funky downstream effects based on how data is used. Logging granularity and data inputs can help you efficiently troubleshoot data issues; granularity might be “job” or “event”, or it might be much more specific to your application.</p><h3>2. What is happening in your logs?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x4gkzxlFxOTJPyqqihwoHA.png" /><figcaption>FIgure 4: Sample log output with timestamps</figcaption></figure><p>Can events be drawn back to log traces? Do you see what the traceback is in the application in context? Logs should be immutable, timestamped records of discrete events in the flow. Once again, context is everything. Tieing logs to the specific step in the flow that failed will enable speedy recovery and root cause analysis.</p><h3>3. How are the pieces of your application that others interact with performing?</h3><p>API and Application uptime and latency let you know how your processes that impact users or other applications are performing over time. Your goal is to provide quantifiable trends that show system health and performance. Once baselines are established, you can enable alerting on thresholds or anomalies and systematically work to lower that latency. Knowing these details is useful for capacity planning and detecting performance regressions.</p><h3>4. How do you determine if your costs are reasonable, at least relatively so?</h3><p>To determine whether your cloud computing costs are reasonable, start by knowing what your costs are relative to each other each month, <em>and then</em> proceed with correlating spending with usage metrics. A healthy cost profile shows proportional growth; when utilization, like compute hours, data transfers, or active users, increases, costs rise accordingly, and when usage dips, costs follow suit. This correlation helps flag anomalies such as idle resources, poor lifecycle policies, misconfigured autoscaling, or unoptimized storage tiers. Over time, using dashboards that split up resource costs by teams, environments, or workloads allows you to refine budgets, detect drift, and ensure that spending remains both justifiable and efficient. It lets teams learn from each other on cost-efficient application design by showing what they spend relative to each other; it opens the door to data-driven efficiency conversations between and among teams.</p><h3>Conclusion and Considerations</h3><p>What are the core processes in your application? If it&#39;s a complicated application, this might seem tedious, but it is worth it and much less tedious when done at project inception or when new microservices are added.</p><p>What are the pieces of information you need to genericize the events from each process? This is likely domain-specific. I hope the event structure I shared above can be a good starting point, but it is unlikely to be sufficient for your domain.</p><p>When your application fails, can you connect that failure in your observability platform to the logs and troubleshoot the stack trace efficiently?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IZkW2w44tTLGCjScASSgmQ.png" /><figcaption>Figure 5: A Sankey Chart of Process A’s Flow</figcaption></figure><p>A very smart person I work with discusses this vision as the “pizza tracker approach” to application observability. Can we use Sankey diagrams or other visuals to show the application flow? Figure 5 shows what that might look like. Can you link the overall failure easily to specific log errors from the observability tool or dashboard? That might be done using process IDs or just thoughtful JSON logging structures.</p><p>Can we build a system that demonstrates application functionality in its observability platform? I have been thinking about what underlies good application observability, and the conclusion I have come to is that it should be self-documenting. I should see the flow in Figure 5 and know that Process A has 4 pieces, 1 and 2 must run first, they have x and y purposes, then 3 runs by using data from 1 and 2. Finally, 4 should run after that. These pieces might not all run back-to-back. There might be no trigger explicitly between them, but the results of 3 depend on 1 and 2, and 4 depends on 3.</p><p>Do you have any thoughts on application observability as a concept? Please reach out to us at <a href="https://newmathdata.com/">New Math Data</a> or comment below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5661c3e8ff0" width="1" height="1" alt=""><hr><p><a href="https://blog.newmathdata.com/a-vision-for-application-observability-b5661c3e8ff0">A Vision for Application Observability</a> was originally published in <a href="https://blog.newmathdata.com/">newmathdata</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Core Concepts of Computational Linguistics with RAG]]></title>
            <link>https://blog.newmathdata.com/using-core-concepts-of-computational-linguistics-with-rag-f8767fa7066b?source=rss-cebaae6b1b67------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8767fa7066b</guid>
            <category><![CDATA[computational-linguistics]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[natural-language-process]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Alexis McKenzie]]></dc:creator>
            <pubDate>Thu, 17 Jul 2025 15:01:55 GMT</pubDate>
            <atom:updated>2025-07-17T15:04:32.775Z</atom:updated>
            <content:encoded><![CDATA[<h4>How linguistic fundamentals shape the design and performance of retrieval-augmented generation systems</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*56J1k48CeDR-2Lp1" /><figcaption>A super colorful infographic ChatGPT created for this article</figcaption></figure><p>In a <a href="https://medium.com/newmathdata/core-concepts-for-small-language-models-0ea6b7d922fc">previous article</a>, I discussed the core concepts of computational linguistics that every language model, big and small, needs to have. This article will discuss the core components of retrieval-augmented generation (RAG) models, show how the concepts of computational linguistics are related to RAG, and illustrate how we might use those core concepts to successfully build and optimize RAG models.</p><p>The computational linguistics concepts mentioned in the previous article that I will discuss within the context of RAG are tokenization, morphological analysis, syntactic analysis, semantic analysis, pragmatic analysis, and natural language generation.</p><h3>What is Retrieval-Augmented Generation?</h3><p>RAG is a hybrid architecture that combines a <strong>retriever</strong> with a <strong>generator</strong> to enhance the factual accuracy of an LLM and reduce hallucinations. The process can be broken into four main stages:</p><ol><li><strong>Query Encoding:</strong> A user input or prompt is encoded into a query vector.</li><li><strong>Document Retrieval:</strong> Relevant documents are fetched from an external corpus using similarity search. This is usually a dense vector search that is performed over a knowledge base.</li><li><strong>Augmentation</strong>: Retrieved documents are fed back into the prompt to have a more accurate and informative input for the LLM.</li><li><strong>Contextual Generation:</strong> Retrieved content is passed to a generator model or LLM (e.g., a <a href="https://medium.com/@minh.hoque/a-comprehensive-overview-of-transformer-based-models-encoders-decoders-and-more-e9bc0644a4e5">transformer-based decoder</a>), which produces a fluent and contextually relevant output.</li></ol><p>Originally introduced by Lewis et al. in their 2020 seminal paper, <a href="http://arxiv.org/pdf/2005.11401">“Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks”</a>, RAG combines the benefits of information retrieval with the flexibility of neural text generation. <a href="https://web.stanford.edu/~jurafsky/slp3/7.pdf">Neural language models</a> use neural networks to both understand and produce natural language.</p><h3>RAG Flow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*ySKQe-YMCKPMxj4NHasCYw.png" /><figcaption>RAG flow: yellow boxes have core NLP concept and where they fall</figcaption></figure><h4><strong>1. User Input:</strong></h4><p>The raw natural language input provided by the user. This is typically a question, prompt, or instruction. Sometimes we derive the input from a pipeline, and sometimes there&#39;s a direct user interface.</p><h4><strong>2. Tokenization and Parsing:</strong></h4><p><em>Tokenization</em> splits the input text into discrete units or tokens that the models can understand, such as words or subwords. <a href="https://web.stanford.edu/~jurafsky/slp3/19.pdf">Parsing</a> is an optional step that applies <em>syntactic analysis, </em>effectively creating a dependency tree or sentence diagram under the hood, to help models understand grammatical structure and resolve ambiguities in meaning. This prepares the input for meaningful embedding and improves retriever relevance through better query understanding.</p><p>Dependency parsing might be especially useful if you are working on a RAG model for a very specialized use case or when the user is using complex sentence structure. Let&#39;s take the following sentence: “Subject to prior written consent by the disclosing party, the receiving party shall not disclose Confidential Information to any third party, except as required by applicable law.” The dependency tree appears as below:</p><p>ROOT: disclose<br> ├── aux: shall<br> ├── neg: not<br> ├── nsubj: party<br> │ └── amod: receiving<br> ├── dobj: Information<br> │ └── amod: Confidential<br> ├── prep: to<br> │ └── pobj: party<br> │ └── amod: third<br> ├── advcl: subject<br> │ └── pobj: consent<br> │ └── amod: written<br> │ └── agent: party<br> │ └── amod: disclosing<br> └── advcl: except<br> └── prep: by<br> └── pobj: law<br> └── amod: applicable</p><p>In this example, without the parser, your retriever may not get the memo that disclosure might happen without prior consent, or it may fail to understand who gives consent vs. who receives consent.</p><p>Using a parser like <a href="https://spacy.io/">spaCy</a> or <a href="https://stanfordnlp.github.io/CoreNLP/">CoreNLP</a> may meet your needs. Still, a custom parser step may be necessary in super specialized legal, financial, or particular scientific domains to pass information correctly to the embedder or retrieve the most relevant data through the retriever. Nonstandard grammar, long noun phrases, and context-dependent modifiers can be tricky for the common parsers to break down appropriately.</p><h4><strong>3. Embedding:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9OFO83WBEYLgsx-A2rvRng.png" /><figcaption>What a dense vector representation might look like</figcaption></figure><p>Transforms the tokenized query into a <a href="https://www.pinecone.io/learn/series/nlp/dense-vector-embeddings-nlp/">dense vector representation</a> or embedding that performs <em>semantic analysis </em>to derive meaning. <a href="https://sbert.net/">Sentence-BERT</a>, Dense Passage Retriever (DPR) encoder, and other transformer-based embedding models can be used here.</p><p>At the risk of being overly general and missing the nuance in specific embedding models, dense vector representations provide decimal values within the vector instead of 1s and 0s, as is the case in sparse vectors. Dense vectors allow for semantic meaning to be passed through the decimals via various underlying algorithms by representing similarities between words and concepts in the text. For example, the vector will represent that the words “art” and “painting” are semantically related.</p><p><a href="https://medium.com/@manansuri/a-dummys-guide-to-word2vec-456444f3c673">Word2Vec</a>, <a href="https://nlp.stanford.edu/projects/glove/">GloVe</a>, and <a href="https://huggingface.co/docs/transformers/en/model_doc/bert">BERT</a> models are context-aware and attempt to perform some <em>pragmatic analysis </em>to determine hidden or nuanced meanings,<em> </em>though this is a constantly evolving part of RAG development. For example, these models can understand the difference between “he shot the photo” and “he shot the gun”. Even though both use the word “shot”, the context is very different between the two uses.</p><h4><strong>4. Retrieval:</strong></h4><p>Uses the query embedding to search a pre-encoded corpus and perform <em>semantic analysis</em> to return the most relevant documents. Retrieval typically uses <a href="https://ai.meta.com/tools/faiss/">FAISS</a> or other vector search libraries and retrieves the top k documents. Here, retrieval is similarity-based, not keyword-based. Interestingly, the seminal Lewis et al. paper on RAG mentioned above did not find significant differences in the performance of retrieving 5 or 10 documents.</p><p>A ranked list of documents or passages deemed most relevant to the query is pulled from a vectorized knowledge base, and the top k are picked from that list. The content could be product manuals, web pages, PDFs, legal documents, support articles, etc.</p><p>While similarity-based retrieval is the most common, based on your use case, it may make sense to create a custom retriever to pull out keywords from the previous steps and pass them to a more generic API. You might do this if there is a good keyword API out there for your project, or if trying to reduce computation costs.</p><h4><strong>5. Generator:</strong></h4><p>A decoder-only or encoder-decoder model (like BART, T5, or GPT) that takes the query and retrieved documents as input and generates a fluent, context-aware response using <em>natural language generation</em>. The actual generation is the easy part. Everything that came before ensures the response is contextually accurate and without hallucinations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fdHraDsqs_ALFywWKt8h6w.png" /><figcaption>An image showing how cross-attention works in an encoder-decoder model</figcaption></figure><p><em>Natural language generation</em> uses cross-attention to blend the query and retrieved context, is often fine-tuned for specific downstream tasks, and can handle paraphrasing, summarizing, or answering questions about the response. <a href="https://medium.com/@sachinsoni600517/cross-attention-in-transformer-f37ce7129d78">Cross-attention</a> is a core concept in neural networks, specifically transformer models with encoder-decoder architectures, where a RAG model could focus on the retrieved documents. Without cross-attention, hallucinations would be much more prevalent because the decoder would not have the additional external context.</p><p>Although perhaps unclear in the image above, the queries typically come from the decoder, and the keys and values typically come from the encoder. The decoder is repeatedly trying to summarize what it knows, using the output of the encoder to reference what it is trying to write and keep it factually honest. This process will occur iteratively until the final result is produced.</p><h4><strong>6. Result:</strong></h4><p>The final text output, grounded in the retrieved knowledge and refined by the generator’s language modeling capabilities, is produced using all 5 of the previous steps.</p><h3>Why Linguistics Still Matters in LLM Architectures</h3><p>Despite the emergence of end-to-end architectures, computational linguistics remains essential in building effective RAG systems. Understanding how language is structured, interpreted, and used in context allows engineers to design systems that not only perform well on benchmarks but also meet the nuanced needs of users in real-world applications.</p><p>By integrating core linguistic insights into retrieval strategies, document processing, and output generation, we can continue to push the boundaries of what RAG models can achieve. At <a href="https://newmathdata.com/">New Math Data</a>, we have deep expertise in data and AI systems, where RAG is just one of many tools in our toolbox. Please reach out or comment below to share your experiences with or ideas about computational linguistics or RAG!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8767fa7066b" width="1" height="1" alt=""><hr><p><a href="https://blog.newmathdata.com/using-core-concepts-of-computational-linguistics-with-rag-f8767fa7066b">Using Core Concepts of Computational Linguistics with RAG</a> was originally published in <a href="https://blog.newmathdata.com/">newmathdata</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to: AWS OAM Sink and Link]]></title>
            <link>https://blog.newmathdata.com/how-to-aws-oam-sink-and-link-cdbe0968718e?source=rss-cebaae6b1b67------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdbe0968718e</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[cloudwatch]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Alexis McKenzie]]></dc:creator>
            <pubDate>Thu, 03 Apr 2025 15:02:25 GMT</pubDate>
            <atom:updated>2025-04-03T15:02:25.492Z</atom:updated>
            <content:encoded><![CDATA[<h4>How and Why to Setup Cross-Account Logging in AWS</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BnYFQc43aboM3q0LnKO2FA.png" /></figure><p>I recently implemented cross-account logging using AWS Observability Access Manager (OAM) for a comprehensive monitoring application my team and I are building. In this, we are looking to create one UI to understand performance and costs across the products in our domain. When setting up cross-account logging, I struggled to find clear documentation on how to do so in <a href="https://www.terraform.io/">Terraform</a> and made a few mistakes with permissions until I understood how OAM policies work. When troubleshooting, ChatGPT made up some silliness that did not make sense, and so this article aims to help you solve a problem that took me a bit longer to solve than I think it should have.</p><p>Cross-account logging is great if you want to colocate logs from multiple accounts. This approach can help you understand portfolio-level questions like: How are all the <a href="https://aws.amazon.com/api-gateway/">API gateways</a> in your domain performing? What is the breakdown of response types per endpoint? What is causing latency in your application? Do all applications in your domain experience similar metric patterns?</p><h3>AWS OAM</h3><p><a href="https://docs.aws.amazon.com/OAM/latest/APIReference/Welcome.html">Observability Access Manager</a> is a game-changer for organizations managing observability data across multiple AWS accounts and regions. Instead of manually setting up complex IAM roles, policies, and log subscriptions, OAM provides a seamless, scalable, and secure way to unify metrics, logs, and traces into a centralized monitoring account.</p><p>Prior to OAM’s release in 2020, you might have had to ferry your data between accounts using Kinesis Data Firehose, Kinesis Data Streams, or a slightly more complex architecture involving a lambda, kafka, and some complex permissioning. Fortunately, times have changed.</p><p>With OAM, you can:</p><ul><li><strong>Effortlessly share CloudWatch metrics, logs, and X-Ray traces</strong> across accounts and regions.</li><li><strong>Eliminate the need for manual log forwarding</strong> — no more subscription filters or Kinesis streams!</li><li><strong>Use a single-pane-of-glass dashboard</strong> in CloudWatch to monitor applications spanning multiple AWS environments.</li><li><strong>Improve security and governance</strong> by managing access with fine-grained <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_identity-vs-resource.html"><strong>resource-based policies</strong></a>.</li><li><strong>Reduce costs</strong> by consolidating observability data instead of duplicating logs and metrics. This approach does not yield any additional costs over the initial generation of the data.</li></ul><p>As organizations scale, their AWS footprint often spans multiple accounts. Factors such as organizational dynamics, poor governance, security concerns, compliance requirements, and cost management drivers can create account sprawl. AWS OAM simplifies observability by connecting all this data — ensuring DevOps, SREs, and security teams can troubleshoot faster, optimize resources, and detect anomalies in real time.</p><h3>Sinking</h3><p>A sink is a central resource within AWS OAM for receiving observability data that needs to be created in the central logging account. These pieces of code below need to be run first before the link is established so that the policy document can be attached to the sink, thus confiring permissions for any linking accounts. If this is not setup, linking attempts will fail.</p><p>You can use the code below and change the resource names according to your needs, but you’ll need to setup the account IDs for the accounts you plan to link through your locals.</p><p>While we only needed to share CloudWatch metrics and log groups, additional conditions can be set depending on your application architecture. XRay and ApplicationInsights are two other services that might be relevant here and have their own set of resource types you can add to the list in the policy document below.</p><pre>resource &quot;aws_oam_sink&quot; &quot;monitoring_sink&quot; {<br>  name = &quot;monitoring-sink&quot;<br>}<br><br>data &quot;aws_iam_policy_document&quot; &quot;cross_account_policy_doc&quot; {<br>  statement {<br>    actions = [<br>            &quot;oam:CreateLink&quot;,<br>            &quot;oam:UpdateLink&quot;<br>            ]<br>    principals {<br>       type = &quot;AWS&quot;<br>       identifiers = [&quot;${local.account_one}&quot;,&quot;${local.account_two}&quot;]<br>    }<br>    effect = &quot;Allow&quot;<br>    resources = [&quot;*&quot;]<br>    condition {<br>      test = &quot;ForAllValues:StringEquals&quot;<br>      variable = &quot;oam:ResourceTypes&quot;<br>      values = [&quot;AWS::CloudWatch::Metric&quot;, &quot;AWS::Logs::LogGroup&quot;]<br>    }<br>  }<br>}<br><br>resource &quot;aws_oam_sink_policy&quot; &quot;monitoring_sink_policy&quot; {<br>  sink_identifier = aws_oam_sink.monitoring_sink.id<br>  policy = data.aws_iam_policy_document.cross_account_policy_doc.json<br>}</pre><h3>Linking</h3><p>Any accounts sharing logs with the sink will need to have the following adding to their Terraform repositories.</p><p>The sink_identifier should match the region, account, and sink_id shown in the Terraform output for the sink creation.</p><pre>resource &quot;aws_oam_link&quot; &quot;account_one_source_link&quot; {<br>  label_template = &quot;account_one_source_link&quot;<br>  sink_identifier = &quot;arn:aws:oam:${local.region}:${local.monitoring_account_id}:sink/${local.sink_id}&quot;<br>  resource_types = [&quot;AWS::CloudWatch::Metric&quot;, &quot;AWS::Logs::LogGroup&quot;]<br>}</pre><p>Finally, you can also add the link_configuration parameter to <a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/oam_link">aws_oam_link</a> to filter out different log groups that arent relevant to your cross-account monitoring efforts.</p><p>You should be able to validate these steps worked because not only should your Terraform succeed, but you should see CloudWatch Log Groups from other accounts in your monitoring account amongst its CloudWatch Log Groups.</p><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*fzlvvhjv4jO974qyizGlPw.jpeg" /><figcaption>Lean Architecture Diagram</figcaption></figure><p>The above diagram shows a lean view of this application architecture. Of course, there are many networking, security, authentication, and authorization components not included in this image such as Azure AD, AWS WAF, Route53, and CloudFront.</p><h3>Next Steps</h3><p>There are a few options for creating cross-account dashboards that we tinkered with. If you are looking for an internal developer dashboard, a <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create_xaxr_dashboard.html">CloudWatch dashboard </a>may very well suffice. This worked well for us in the beginning when we were trying to show the usefulness of the concept of cross-account log sharing and that the same metrics could be viewed for different accounts in an often directly comparable way.</p><p>However, we ended up building a more comprehensive dashboard in <a href="https://aws.amazon.com/quicksight">QuickSight</a>. There are a few reasons this worked better for our product:</p><ol><li>The CloudWatch dashboard approach did not have simple permissions management for embedding in a webapp for our various users. The options for this seemed to be using an &lt;iframe&gt;, but the user has to have <a href="https://aws.amazon.com/iam/features/manage-permissions/">IAM permissions</a>. This was not exactly useful for our leadership users.</li><li>QuickSight dashboards are more customizable. For example, we could integrate error messages with tables to paint a comprehensive picture of the application performance at each moment in time.</li><li>QuickSight dashboards have a cleaner UI that lets us easily toggle between different timeframes and products.</li><li>QuickSight permissions are configurable at the row level, which let us filter dashboards to specific user groups.</li><li>We were already familiar with embedding using the <a href="https://docs.aws.amazon.com/quicksight/latest/user/embedding-overview.html">QuickSight Embedding SDK</a> and understood the paradigm for using Active Directory permissions over the top of that to provide more granular permissions.</li></ol><h3>Conclusion</h3><p>Cross-account logging was one piece of a larger project where we setup monitoring of various processes and workflows in a centralized application dashboard. In addition to the approach and code I’ve shared above, we built an accompanying workflow using cross-account eventing to understand performance of specific workflows.</p><p>Here at <a href="https://newmathdata.com/">New Math Data</a>, we recommend looking into creating something similar to understand performance and monitoring of applications within a specific domain of your business. Now that you have some ready-to-use Terraform you can setup some cross-account CloudWatch dashboards in just a few hours! Please reach out or comment below if you would like to discuss more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdbe0968718e" width="1" height="1" alt=""><hr><p><a href="https://blog.newmathdata.com/how-to-aws-oam-sink-and-link-cdbe0968718e">How to: AWS OAM Sink and Link</a> was originally published in <a href="https://blog.newmathdata.com/">newmathdata</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Core Concepts for Small Language Models]]></title>
            <link>https://blog.newmathdata.com/core-concepts-for-small-language-models-0ea6b7d922fc?source=rss-cebaae6b1b67------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ea6b7d922fc</guid>
            <category><![CDATA[computational-linguistics]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[natural-language-process]]></category>
            <dc:creator><![CDATA[Alexis McKenzie]]></dc:creator>
            <pubDate>Thu, 09 Jan 2025 16:01:49 GMT</pubDate>
            <atom:updated>2025-01-15T18:05:44.486Z</atom:updated>
            <content:encoded><![CDATA[<h4>Foundational Computational Linguistics Concepts and how they relate to Language Models</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6BP6Nde9Jbhe-8mN" /><figcaption>How ChatGPT Envisions an Infographic for Small Language Models</figcaption></figure><p>LLMs are all the rage, and to use them effectively as engineers and users of any kind we could benefit from thinking about them in the context of some core Natural Language Processing (NLP) concepts. At <a href="https://newmathdata.com/">New Math Data</a>, we’ve been building a lot of RAG and other models lately, and so I have been thinking about how to tie some key academic concepts of NLP to concepts you need to use to build successful RAG models. And thus came the vision for this article and the follow-up. These concepts I will be discussing were critical to how the rules-based, statistical, neural network, and deep learning models that preceeded the LLMs of today were designed. This article hopes to help you dip your toes in the ocean that is <a href="https://plato.stanford.edu/entries/computational-linguistics/">computational lingustics</a>.</p><p>An NLP system must have the following capabilities:</p><ul><li>Tokenization — separating text into smaller tokens that can be analyzed</li><li>Morphological Analysis — word formation</li><li>Syntactic Analysis — sentence structure</li><li>Semantic Analysis — meaning</li><li>Pragmatic Analysis — understanding</li><li>Natural language generation — creating relevant text</li></ul><p>This article will discuss what these terms mean in an easy to understand way, and in another article we will discuss how we satisfy each of these when building RAG models.</p><h3>Core Concepts</h3><h4>Tokenization</h4><p><a href="https://nlp.stanford.edu/IR-book/html/htmledition/tokenization-1.html">Tokenization</a> is the process of separating text like sentences, notes, or many, many sentences into specific components, regardless of if they are full or correctly typed words, that make them up.</p><p>For example, if you have the statement “I love playing videogames with my friends”, a tokenized version would be [“I”, “love”, “playing”, “videogames”, “with”, “my”, “friends”]. Sometimes we may break up larger compound words into smaller parts that are easier for the computer to understand. So, “videogames” might become “video” “games”. We do this to speed up processing of information and get the computer to recognize patterns in the words, sentences, and phrases.</p><h4>Morphological Analysis</h4><p>Morphological analysis is like looking at a word as if it’s made of different LEGO bricks, and seeing how those parts fit together to make meaning.</p><p>For example, let’s look at the word “playing.”</p><ul><li>“Play” is one LEGO piece — it tells us what action we’re doing.</li><li>“-ing” is another LEGO piece — it shows us that the action is happening right now.</li></ul><p>When we put these LEGO bricks together, we get the full word “playing”, which means doing the action of play right now. So, morphological analysis is like taking apart words to see the little pieces inside. By understanding each piece, we know what the whole word means!</p><h4>Syntactic Analysis</h4><p>Syntactic analysis is building sentences using the puzzle pieces of who is doing what in the sentence, who they are doing it with, etc. Sentence diagrams are a tool you might have learned in middle school that visually shows how the words in the sentence fit together. While educators might debate the usefulness of sentence diagramming for children, if we can write algorithms to diagram sentences for machines we can graphically show how the words relate to each other, making it easier to understand the meaning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*2LyVCSM-NamvWSrQ" /><figcaption>A sentence diagram</figcaption></figure><p>For example, here we see that “I” is the subject, “love” is the action, and “playing videogames” is the object of my affection (direct object). The prepositional phrase “with my friends” provides some details about the way in which I like playing videogames. If I changed that to “for my friends” or “about my friends” the sentence would have a different meaning. The linkage to “playing videogames” show that connection.</p><p>Sentence diagrams help a machine understand meaning because they visually map out the structure of a sentence, making it clear how each word relates to others. It shows the role of the words (object, direct object, verb, etc), the relationship between those words (how are they connected), the hierarchy (main ideas vs modifiers), and helps the computer start to understand patterns through creating a consistent approach for interpreting sentences.</p><h4>Semantic Analysis</h4><p>Semantic analysis is about understanding each word in a sequence of words, putting those words together, and validating that it makes sense.</p><p>1.<strong>Understanding Each Word</strong>: Semantic analysis looks at each word in the sentence and often uses a reference dictionary to understand what it means:</p><ul><li>“I” means the person talking.</li><li>“Love” means really, really liking something.</li><li>“Playing” means doing something fun or engaging.</li><li>“Videogames” are electronic games that you play on a screen.</li><li>“With” means together with someone else.</li><li>“My friends” means the people that the speaker cares about and likes to spend time with.</li></ul><p>2. <strong>Putting the Words Together</strong>: Next, semantic analysis sees how these. words work together:</p><ul><li>“I” am the person who loves something.</li><li>“Playing videogames” is the thing that I love.</li><li>“With my friends” explains that I’m not playing alone; I’m playing together with friends.</li></ul><p>3. <strong>Making Sure It Makes Sense</strong>: Finally, the computer or algorithm checks if the sentence makes sense. It sees that a person (I) can love an activity (playing videogames) and that it’s possible to play with friends, so the sentence is meaningful and sounds natural.</p><p>Semantic analysis is like seeing the forest through the trees, putting all the pieces together and seeing the big picture of what the sentence is saying to determine if it’s meaningful and logical.</p><h4>Pragmatic Analysis</h4><p>Pragmatic analysis is the process of layering context and hidden meaning into the understanding of words. This part had, until recently, been a challenge for large language models and sometimes it still is.</p><p>“I love playing videogames with my friends” could have different meanings depending on the context in which it is said. If you are a child who doesn’t want to leave a friend’s house because you “love playing videogames with [your] friends” the context is quite different from if you are playing videogames alone and thinking about how great it would be to be playing with your friends or if you are grounded and trying to plead your case for why you should be released to play videogames with your friends.</p><p>This part can be tricky for humans and machines alike because context about the person and/or the specific situation can influence the pragmatic analysis.</p><h4>Natural Language Generation</h4><p><a href="https://medium.com/sciforce/a-comprehensive-guide-to-natural-language-generation-dd63a4b6e548">Natural language generation</a> (NLG) has three core steps:</p><ol><li>Understandimg the question you are asking (called Natural Language Understanding or NLU)</li><li>Finding the answer</li><li>Turning that information into words humans can understand</li></ol><p>The first two steps involve a lot of iterating on the components discussed above: tokenization, morphological analysis, syntactic analysis, semantic analysis, and pragmatic analysis. Once these pieces have been satisfied to a reasonable degree, natural language generation is relatively easy because the machine can respond in a formulaic way. Getting the right data and deriving the right meaning from that data is the tricky part.</p><p>Hope this helps you understand the core concepts in an NLP system! Stay tuned for our next article on how we apply these concepts when designing retrieval-augmented generation (RAG) models!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ea6b7d922fc" width="1" height="1" alt=""><hr><p><a href="https://blog.newmathdata.com/core-concepts-for-small-language-models-0ea6b7d922fc">Core Concepts for Small Language Models</a> was originally published in <a href="https://blog.newmathdata.com/">newmathdata</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Modeling for Developers]]></title>
            <link>https://blog.newmathdata.com/data-modeling-for-developers-b05f8f4d658f?source=rss-cebaae6b1b67------2</link>
            <guid isPermaLink="false">https://medium.com/p/b05f8f4d658f</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-strategy]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software]]></category>
            <dc:creator><![CDATA[Alexis McKenzie]]></dc:creator>
            <pubDate>Thu, 01 Feb 2024 16:01:43 GMT</pubDate>
            <atom:updated>2025-04-07T20:06:00.850Z</atom:updated>
            <content:encoded><![CDATA[<h4>An Introduction to Data Modeling and Why it Matters for Development Teams</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*8UR7RW63zXENAN8kavDNzQ.png" /><figcaption>Data modeling allows you to find structure where it might otherwise be hard to do so. (By Midjourney)</figcaption></figure><p>Data modeling is a critical yet often underrated skill in technology development and within development teams. This article aims to teach you the basics of it and why it is important. This article will introduce you to the concept of a data model, how to create one in a business setting, and some tools you should investigate for creating them collaboratively. Additionally, I will cover some concepts from traditional data modeling you might want to explore, and I will briefly discuss how to incorporate unstructured data into your models. I don’t think there is only one right way to model data, but knowing the concepts can help you think intelligently about how the data in your systems ties together and therefore build better systems. This can help you understand what pieces need to come from your application, which come from other databases or APIs, and which originate in some crusty old Access database on a shared drive somewhere.</p><h3><strong>Why Should You Model Data?</strong></h3><p>Many times in my career I have joined development teams at large, sophisticated organizations with an existing product only to find nebulous requirements and low team understanding of what the system they have designed does, where it gets its data from, and what data this system should be producing. Data modeling can help solve this problem as a sort of lean requirements document and communication tool, making sure there is alignment on what the product is aiming to achieve with guidelines for how to achieve it. It can serve as a constant resource for teammates to understand the whole picture even if they often work on smaller parts of the application. Completing this activity early in the development process is most useful, but all is not lost if it happens farther down the road.</p><h3>What is a Data Model?</h3><p>A data model is a visual representation of an information system and a communication tool for designing systems of all levels of complexity. Traditionally data models are only used for representing structured data, but I have some techniques for modeling semi-structured and unstructured data that I will share with you later in this article.</p><p>Data can be modeled based on the level of detail you want to provide. There are typically three levels of detail we work with: conceptual, logical, and physical models. Conceptual models show all the concepts for the product and how they relate to each other whereas logical models pay more attention to the specific attributes that exist within those concepts and how they relate to each other.</p><p>Physical models then take logical models one step further by showing how the implementation will occur with the specific data types, nuances, and optimizations of the database system considered in the models. For example, most databases will use a UUID (Universally Unique IDentifier) to uniquely identify information whereas GUIDs (Globally Unique IDentifiers) are similar but tend to be used in Microsoft-specific databases and systems. This is the sort of distinction you make when converting a logical model to a physical model. However, I will focus on conceptual and logical models here.</p><p>For fun and because I love ice cream, I will use the example of creating an app for managing orders and inventory for an ice cream shop to demonstrate these concepts.</p><p>When creating the conceptual model, you want to get all the ideas out there for what things are relevant to this ice cream app. Many questions will come up in this exercise, and I find it quite useful to work on the conceptual model with the business to get answers to these questions faster. Some questions that make you feel like you do not understand the business will likely come up: do we allow delivery of our ice cream? Who ARE all our suppliers, and how DO we add new ones? It can help to have an experienced facilitator for these conversations, but it is not critical.</p><p>Below is an example of the high-level concepts you might have produced doing this exercise. When we have done this in workshops and with business groups, there are always extra words that are volunteered that don’t really fit the high-level conceptual model. BUT that does not mean they are not useful. Those words and concepts will go into how we design the logical model, which adds attributes to these high-level concepts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_wutyMBgNA7YcCs3FN07dQ.png" /></figure><p>Once we have gotten all the high-level concepts out there, we want to figure out how they relate to each other. There are a handful of techniques for doing this, but I like to add verbs to the connections between the high-level concepts. One example of that finished conceptual model is below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*vVQY68ToZuTA05zEv7SCow.png" /></figure><p>Finally, once you have a conceptual model that incorporates all the key parts of your product, you have two important steps left to create your logical model before you iterate on the resulting model.</p><ol><li>Adding attributes to your high-level concepts, which now become tables. The attributes you assign become the columns.</li><li>Adding relationships between the tables.</li></ol><h4>Table relationships</h4><p>Relationships between tables are often expressed in crows-foot notation, and this is the part many developers I have worked with struggled to get right on the first attempt. So, if you are confused, know you are not alone. It takes time and practice to really master.</p><p>The symbols below are used to show how tables relate to each other. You want to specify if, for example, a product can contain zero, one, or many ingredients. Most of the lines you have in your conceptual model should be replaced with these symbols which will inform many things about how you implement your final product such as database constraints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*5AB3h8Q_W4VFpgKfm7dU-Q.png" /></figure><h4>Attribute selection</h4><p>Adding attributes is another useful activity to perform with the business representatives. Getting all the ideas out for what data needs to be collected, incorporated, or displayed is quite powerful. Below is an example of what <em>part</em> of the conceptual model might look like as a logical model:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*OWR7ES2j_fj7ocN_3wCa3Q.png" /></figure><p>There are four useful statements that this model shows.</p><ol><li><em>Customers</em> make <strong>zero to many</strong> <em>orders</em>. Based on our business logic we might let people be “customers” before making a purchase. Maybe it’s a necessary condition that they first sign up and only then can make a purchase.</li><li><em>Orders</em> are made by <strong>one and only one</strong> <em>customer</em>. Our business team decided they do not want to split checks.</li><li>Each <em>order</em> contains <strong>one or many</strong> <em>products</em>.</li><li>Each <em>product</em> is in <strong>zero to many</strong> <em>orders</em>. When we add new products, they will not be in any orders right away. This crow’s foot representation accounts for that.</li></ol><h4>Exercise</h4><p>A great exercise for you is to complete the model I started. There can be a few answers depending on how you think the business logic would work here.</p><h4>Next steps</h4><p>After this exercise, there can be a handful of next steps. The team can then suss out if this data already exists in the ecosystem and should have a separate source of truth or if it should originate in the application we are designing. Determining this may necessitate modifications to the model structure. If you initially envision data this application owns and data another application owns in the same table it usually makes sense to split that apart for ease of updating asynchronously.</p><p>Once you have that complete version of the model, it is time to iterate!</p><p>Some additional questions to think about as you iterate through your design:</p><ul><li>Do you need to store all updates or just the most recent true value?</li><li>Do you have any duplicates where your system will need to update multiple tables at once? If so, you will almost always want to clean this up.</li><li>Do you need to show analytical results in the app? Do the results need to be always up-to-date or can you tolerate some latency?</li><li>Do you have any many-to-many relationships between your tables? How can you make that easier for the system to join?</li><li>Are all your primary and foreign keys numerical?</li></ul><h3>Tools for Creating Data Models</h3><p>I prefer <a href="https://app.diagrams.net/">draw.io</a>, <a href="https://www.lucidchart.com/pages/">Lucid Chart</a>, or <a href="https://miro.com/">Miro</a> because they have clean UIs, and they let you focus on just the concepts, their attributes, and the relationship between the concepts, which become tables or documents. So many other tools for enterprise are bogged down with too much planning, process, and irrelevant detail that they are both boring and cumbersome to use.</p><h3>Traditional Data Modeling Techniques</h3><p>Once you have created a logical model using the above approach you might want to take some ideas from traditional data modeling schools of thought. You can still get a lot of business value out of data modeling without this, but the concepts in this section help you consider various nuances that will help your system design. Normalization and dimensional modeling are the main concepts I find useful to incorporate into aspects of the applications I have built.</p><h4>Normalization</h4><p>Normalization is a useful concept that helps us think about how to handle duplicate information in tables and rows, thus improving data integrity. Data warehouse modeling using normalization (or normal forms) was proposed by <a href="https://www.eiminstitute.org/meet-the-experts/bill-inmon/">Bill Inmon</a>, who is widely considered to be the father of data warehousing. There is some momentum to move away from central data warehouses due in part to the trouble of validating the accuracy of information across disparate systems. To me, this happens because of the lack of clear ownership you get with a centralized view of all company data. BUT understanding <a href="https://www.javatpoint.com/dbms-normalization">normalization</a> and where we can and cannot have duplicate information in our tables is critical to a clean and <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">dry</a> design in smaller data systems, too; this type of design promotes cheaper and more efficient data storage.</p><h4>Dimensional Modeling</h4><p><a href="https://www.kimballgroup.com/data-warehouse-business-intelligence-resources/kimball-techniques/dimensional-modeling-techniques/">Dimensional modeling</a> is a powerful technique developed by <a href="https://www.kimballgroup.com/author/ralph/">Ralph Kimball</a> in the 1990s. It seeks to design data analysis systems using facts and dimensions where dimension tables provide context such as <strong>who</strong> ordered the ice cream, <strong>what</strong> they ordered, <strong>when</strong> they ordered it, and <strong>where</strong> they ordered it from. Fact tables condense the data into useful aggregates that summarize the key analytical takeaways such as how much ice cream we sold, and how much our packaging and ingredients cost us over that same period. This fact could have all the details that allow us to extrapolate if our business is profitable or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*9KcDY2gFwCvHOCQw7g3MYw.png" /></figure><p>The level of granularity you are working with and the grain you want to have in each step of the application is extremely important. For example, level of granularity is important in our ice cream application to understand if we want to record data at the order level or at the bucket of ice cream sold level (or perhaps both). Whenever I design and build new systems, I am constantly asking myself if we are operating at the right grain or granularity of information.</p><h3>Some Thoughts on Modeling with noSQL and Combined SQL-NoSQL Systems</h3><p>My general thought on modeling data that is less structured and therefore probably more likely to use a NoSQL database is as long as there is some identifier and some rules for what this data will look like, you can use the same techniques discussed above. Below is an example of how I might incorporate a Document database where all my recipes are kept in a document database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*jPL7ynQdYmC52DiSW5fByA.png" /></figure><p>The above shows that a <em>product</em> has <strong>zero or one </strong><em>recipe</em>, and each <em>recipe</em> is for <strong>one and only one</strong> <em>product</em>.</p><h3>Conclusion</h3><p>Data modeling can save your team a ton of time and rework because it connects the business concepts to what needs to be engineered. The team can then focus on how to build that solution with a solid understanding of what and why. In a time when Agile is so present and some organizations tout requirements gathering as waterfall-esque, activities like this can be profoundly useful; they force us to have the right kinds of conversations and get the ideas relevant to the product on the table for everyone to look at from many different angles.</p><p>Please reach out if you have questions or ideas about how to do any of this productively or have any related ideas you would like to talk about.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b05f8f4d658f" width="1" height="1" alt=""><hr><p><a href="https://blog.newmathdata.com/data-modeling-for-developers-b05f8f4d658f">Data Modeling for Developers</a> was originally published in <a href="https://blog.newmathdata.com/">newmathdata</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Series on Flask APIs, Part 1: GETting and POSTing]]></title>
            <link>https://medium.com/data-science/a-series-on-flask-apis-part-1-getting-and-posting-33985dfe8816?source=rss-cebaae6b1b67------2</link>
            <guid isPermaLink="false">https://medium.com/p/33985dfe8816</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[api-development]]></category>
            <dc:creator><![CDATA[Alexis McKenzie]]></dc:creator>
            <pubDate>Mon, 23 Aug 2021 18:51:11 GMT</pubDate>
            <atom:updated>2021-11-03T21:42:17.076Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vjE8bnD4BASrB8xACJ3cFA.jpeg" /><figcaption>APIs allow clients to communicate with servers and are critical to software architecture. Image by<a href="http://www.johnqdo.com/"> John Do</a> with permission.</figcaption></figure><p>This article is part of a series on Flask APIs. This part addresses creating a basic REST API using a JSON doc and running that API locally. Each subsequent part will incorporate new technologies to help you better understand APIs and DevOps in the cloud.</p><p><strong>The Basics: What is Flask, What are APIs, What is a REST API?</strong></p><p><a href="https://flask.palletsprojects.com/en/2.0.x/">Flask</a> is a Python microframework commonly used for creating APIs, or Application Programming Interfaces. APIs let you interact with applications. Even modules in Python are a type of API, for this reason: They let you interact with external code in your application. APIs act as a sort of contract between the server and you. As such, have clear documentation for the call formatting and the type of response that is expected.</p><p>Flask is a microframework, in contrast to a full-stack framework, that facilitates receiving HTTP requests, processing those requests in a controller, and returning an HTTP response. You can use Flask as a component in a full stack project with Angular or React, but we probably won’t be going into that in this series. Microframeworks typically lack authentication, form validation and database abstraction layers on their own, but those can be built in using other components.</p><p>“REST” applies architectural constraints to an API. REST stands for Representational State Transfer and means that when a call is made, a representation of the state is also transferred with that call. These include GET, POST, PUT and DELETE as our verbs, and their usage results in a representation of the server’s data being returned. <a href="https://vimeo.com/478496666">There are five critical components for your API to be “RESTful”:</a></p><ol><li>A <strong>uniform interface</strong> that standardizes the request format via our verbs and has logical and patterned URI routes to interact with the API</li><li><strong>Client-server separation</strong> that allows for the client and server to evolve separately and communicate only via the request URI</li><li>A <strong>stateless</strong> request so that each request is self-contained and need not create a server session and the server need not maintain data about past requests</li><li><strong>Cacheable</strong> response data on the server side to improve scalability and client-side performance</li><li>And finally, a <strong>layered system architecture</strong> to allow for multiple layers in the application (for authentication typically) and for the client and server to be unaware of which layer they are communicating with</li></ol><ul><li>An optional sixth constraint for <strong>code on demand</strong> allows the server to respond with code instead of a representation of the data in JSON or XML format.</li></ul><p>If we miss any of the key components, our API is simply REST-like. For more information on RESTful APIs, check out the <a href="https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm">Roy Fielding dissertation</a>.</p><h3>Building a Basic Flask API</h3><p>Prerequisites: You must have python and <a href="https://flask.palletsprojects.com/en/2.0.x/installation/">Flask installed</a>.</p><ol><li>Create a local folder for your flask API and open up said folder in <a href="https://code.visualstudio.com/">VS Code</a>. You may also want to <a href="https://docs.github.com/en/get-started/quickstart/create-a-repo">put this in a git repo</a> from the beginning. It will make the subsequent parts of this series easier.</li><li>Create two folders and a py file as below. Name the folders <em>static</em> and <em>templates</em>. Flask is specifically looking for folders with these names, so a functional approach to folder structures will save you headaches in the future.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*HR_WON1y0_2ptVrJN3KCDA.png" /><figcaption>Image by Author</figcaption></figure><p>3. Open up the demo_api.py file and write the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1a565ae9b372b4463efd161881eb6b2/href">https://medium.com/media/f1a565ae9b372b4463efd161881eb6b2/href</a></iframe><p>It is critical you have the shebang on Line 1. The shebang is an interpreter directive that tells the <a href="https://embeddedartistry.com/fieldmanual-terms/program-loader/">program loader</a> that this file should be interpreted as a Python file, and /usr/bin/env represents the logical path for where Python is installed. Excluding the shebang will likely not cause problems now, but it will when you try to run this in the cloud.</p><p>The route decorator on Line 9 is a feature of Flask that lets us easily create endpoints for our API. In general, <a href="https://realpython.com/primer-on-python-decorators/">a decorator</a> lets us extend the behavior of a function.</p><p>The render_template function on Line 14 takes the text variable on Line 11 and renders it in the <em>index.html</em> file.</p><p>4*. Next, create a file called <em>index.html</em> in the templates folder with the below code:</p><pre>&lt;!DOCTYPE html&gt;</pre><pre>&lt;html lang=&quot;en&quot;&gt;</pre><pre>&lt;head&gt;</pre><pre>&lt;title&gt;Flask Demo&lt;/title&gt;</pre><pre>&lt;/head&gt;</pre><pre>&lt;body&gt;</pre><pre>{{html_page_text}}</pre><pre>&lt;/body&gt;</pre><pre>&lt;/html&gt;</pre><p>The double curly braces house the variable referenced in the render_template function in the Python file.</p><p>If you need more info on html, check out <a href="https://www.w3schools.com/html/">W3Schools</a>.</p><p>*You do not need to create an html file, and the code snippets will tell you how to complete this API with or without.</p><p>5. Open up a terminal/command prompt and cd into the directory with your demo_api.py file. Next, type:</p><pre>$ export FLASK_APP=demo_api</pre><pre>$ flask run</pre><p>You should see the following output in you terminal/command prompt:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*0xzue72_bmUDIhd-mQ4eMQ.png" /><figcaption>Image by Author</figcaption></figure><p>6. Go to <a href="https://127.0.0.1:5000/">https://127.0.0.1:5000</a> . This is the localhost on port 5000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*A29ZmhdG1JRjicKxt8jHsg.png" /><figcaption>Image by Author</figcaption></figure><p>Localhost, or 127.0.0.1, is a reference to your home computer. No websites can have an IP address that starts with 127 since those IPs are reserved for loopbacks, which let you interact with your computer’s simulation of a webserver. We are able to test applications in localhost because the computer simulates a webserver when a loopback is triggered.</p><h3>GETting and POSTing Data to an API</h3><p>In this section, we’re going to expand the functionality of the API to show how to GET and POST data to a file. Let’s imagine a business scenario where we’re logging and retrieving yearly events. Let’s say we have three objectives: We want to go to /all and see all the events for all time, we want to go to /year/&lt;year&gt; and see events for that particular year, and we want to add events in case some important ones are missing.</p><p>Any time you have a route with an unspecified method, Flask assumes the method is GET (that the client is requesting data from the server).</p><p>You will need to create a file with data in it. First, create a folder called <em>data </em>and create a file within that called <em>data.json </em>. Paste the following into <em>data.json</em>:</p><pre>{&quot;events&quot;:[{ &quot;year&quot;:&quot;2020&quot;,</pre><pre>&quot;id&quot;:1,</pre><pre>&quot;event_category&quot;:&quot;pandemic&quot;,</pre><pre>&quot;event&quot;:&quot;covid&quot;</pre><pre>},</pre><pre>{ &quot;year&quot;:&quot;2020&quot;,</pre><pre>&quot;id&quot;:2,</pre><pre>&quot;event_category&quot;:&quot;environmental&quot;,</pre><pre>&quot;event&quot;:&quot;west coast wildfires&quot;</pre><pre>},</pre><pre>{ &quot;year&quot;:&quot;2021&quot;,</pre><pre>&quot;id&quot;:1,</pre><pre>&quot;event_category&quot;:&quot;sports&quot;,</pre><pre>&quot;event&quot;:&quot;summer olympics&quot;</pre><pre>}</pre><pre>]</pre><pre>}</pre><p>Let’s start with adding an /all route . We need to create another route and function in our <em>demo_api.py</em> file that reads from the <em>data.json</em> file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/367da597b2f7f904b1f14b1d9b3b6700/href">https://medium.com/media/367da597b2f7f904b1f14b1d9b3b6700/href</a></iframe><p>The json_url variable on Line 18 is referencing the path where the data is located. We then use json.loads to open the file and render it inside the <em>index.html</em> page. Note that we can pass all sorts of different data into one template as long as we pay attention to the variables.</p><p>Make sure this works as expected for you before progressing.</p><p>Now, we are going to work on the /year/&lt;year&gt; route. Check out <a href="https://vimeo.com/507239057">this video</a> for some thoughts around endpoint naming. First, create a file in <em>templates </em>called <em>events.html. </em>We can no longer use the <em>index.html</em> file because we have multiple items in our events list in the data file. Paste the following code into <em>events.html</em>:</p><pre>&lt;!DOCTYPE html&gt;</pre><pre>&lt;html lang=&quot;en&quot;&gt;</pre><pre>&lt;head&gt;</pre><pre>&lt;title&gt;Flask Demo&lt;/title&gt;</pre><pre>&lt;/head&gt;</pre><pre>&lt;body&gt;</pre><pre>{% for item in html_page_text %}</pre><pre>&lt;p&gt;{{ item}}&lt;/p&gt;</pre><pre>{% endfor %}</pre><pre>&lt;/body&gt;</pre><pre>&lt;/html&gt;</pre><p>Next, we need to create a new route to get data by year. The full code should look like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1207273d07a7b7a9af00468d3e0ab16c/href">https://medium.com/media/1207273d07a7b7a9af00468d3e0ab16c/href</a></iframe><p>Notice on Line 24 I included methods =[‘GET’] even though we didn’t do that for any other routes in the past. If a route is only getting data, you do not need to specify the methods, but we will be expanding the methods shortly.</p><p>Line 31 is making sure we access the data inside the events key in the <em>data.json</em> file. Line 32 gets the data passed into the route and converts it to a variable. We then iterate through all the data in that list to get the data for the year of interest using a list comprehension on Line 33.</p><p>Now you can pass any year into the path and the data in <em>data.json</em> will be filtered to only show events for that year. The for-loop in the <em>events.html</em> is critical to display all events for years with multiple events listed. If you use <em>index.html</em> on Line 36 instead you will see that only one event for each year is returned.</p><p>If you go to <a href="http://127.0.0.1:5000/2020">http://127.0.0.1:5000/year/2020</a> in your browser, you should see the following results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*6wIvtjtpC76FbdVB7wsM_w.png" /><figcaption>Image by Author</figcaption></figure><p>Now we are going to handle adding new events to the <em>data.json</em> file. Create another html file under the <em>templates</em> folder called <em>form.html</em>. In order to POST, we need some type of form to send data (or we could also use Postman and pass data in parameters, but more on that later). Paste the following into <em>form.html</em>:</p><pre>&lt;!DOCTYPE html&gt;</pre><pre>&lt;html lang=&quot;en&quot;&gt;</pre><pre>&lt;head&gt;</pre><pre>&lt;title&gt;Flask Demo&lt;/title&gt;</pre><pre>&lt;/head&gt;</pre><pre>&lt;body&gt;</pre><pre>&lt;form action=&quot;#&quot; method=&quot;post&quot; &gt;</pre><pre>&lt;p&gt;Yearly Events:&lt;/p&gt;</pre><pre>&lt;table&gt;</pre><pre>&lt;tbody&gt;</pre><pre>&lt;tr&gt;</pre><pre>&lt;td&gt;Category:&lt;/td&gt;</pre><pre>&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;category&quot; /&gt;&lt;/td&gt;</pre><pre>&lt;/tr&gt;</pre><pre>&lt;tr&gt;</pre><pre>&lt;td&gt;Event:&lt;/td&gt;</pre><pre>&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;event&quot; /&gt;&lt;/td&gt;</pre><pre>&lt;/tr&gt;</pre><pre>&lt;/tbody&gt;</pre><pre>&lt;/table&gt;</pre><pre>&lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;submit&quot;/&gt;&lt;/p&gt;</pre><pre>&lt;/form&gt;</pre><pre>&lt;/body&gt;</pre><pre>&lt;/html&gt;</pre><p>First, we need to render this form in our application. Adding the /add route as below will let us do that.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b11da8e6642c7aee8c88b192298705b/href">https://medium.com/media/1b11da8e6642c7aee8c88b192298705b/href</a></iframe><p>Everything in the /add route that starts on Line 25 should be familiar to you except the send_file function. This lets us send the contents in the form to a client. However, at this point, without anything to receive and process POSTs, you will get an internal server error.</p><p>We now need to write some logic to get the POSTed data from the form. There are several ways to do this, but I will show you one approach. Feel free to include other approaches in the comments below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c48e6ad35ef38dbddf73eabcdafb92db/href">https://medium.com/media/c48e6ad35ef38dbddf73eabcdafb92db/href</a></iframe><p>We need to specify that this accepts the POST method on Line 1. If not, none of the code will work.</p><p>Lines 15 through 20 pull the data out of the form that’s posted. The code is referencing those elements by the names specified in the <em>form.html</em> attributes. Lines 21 through 25 put that data into a dictionary so all the data is retrieved from one form submittal is together.</p><p>Lines 27 through 30 are a bit more complex based on how the data file is formatted, but I will walk you through my thought process based on how the data is structured. There is great documentation for <a href="https://docs.python.org/3/library/functions.html#open">Python built-in functions like open</a>, but I chose r+ as the mode to make sure the file could be read and updated.</p><p>First, we need to get the json changes to work as we envisioned. Initially, I thought, <em>OK, I need to load the data currently in the file, append the new data to the end of the events list, and then overwrite the original file.</em> If you attempt to add another value, you will notice this doesn’t exactly work…the new dictionary gets added to the end of the old dictionary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*tnjJvvb6P0hNcgr78nLl2w.png" /><figcaption>Image by Author</figcaption></figure><p>So we need to start at the beginning of the file instead of appending to the end. That’s where the <a href="https://www.tutorialspoint.com/python/file_seek.htm">seek function</a> comes in. This points us to the beginning of the file instead of the end (where the data was previously getting appended)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f32bee182c276147aa95b0e81085d2a/href">https://medium.com/media/5f32bee182c276147aa95b0e81085d2a/href</a></iframe><p>Now you have a basic API that can GET and POST data from a form to a document!</p><p><strong>Notes/Troubleshooting: </strong>If you run the above code, you may notice that the first line gets overwritten. If your original <em>data.json</em> had some indents, this may be problematic. Here is where a useful argument in <a href="https://docs.python.org/3/library/json.html">json.dump</a> comes in handy. Indent!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a6eb487a099aa5ca78861ecb5a4304a/href">https://medium.com/media/2a6eb487a099aa5ca78861ecb5a4304a/href</a></iframe><p>You can use any level of indentation from 0 up, but you will need to play around with it depending on how the <em>data.json</em> file was indented.</p><p><strong>Some other approaches:</strong> You can use additional modes in the built-in <a href="https://docs.python.org/3/library/functions.html#open">open function</a> to first read and then overwrite the file. If you have additional suggestions or comments, please post in the comments section.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33985dfe8816" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/a-series-on-flask-apis-part-1-getting-and-posting-33985dfe8816">A Series on Flask APIs, Part 1: GETting and POSTing</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Data Mesh Approach to Data Warehousing]]></title>
            <link>https://medium.com/data-science/a-data-mesh-approach-to-data-warehousing-cd71e55490ba?source=rss-cebaae6b1b67------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd71e55490ba</guid>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[data-mesh]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Alexis McKenzie]]></dc:creator>
            <pubDate>Wed, 14 Jul 2021 15:27:40 GMT</pubDate>
            <atom:updated>2022-03-22T22:26:38.086Z</atom:updated>
            <content:encoded><![CDATA[<h4>The pros and cons of data mesh as well as steps that organizations should take to improve their data strategies.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uBcqlYzYrxM1Qszo0m_wEg.jpeg" /><figcaption>How should data warehouses evolve for a fast-paced big data world? Image by<a href="http://www.johnqdo.com/"> John Do</a> with permission.</figcaption></figure><p>Data mesh is a provocative new paradigm that offers a data strategy that is similar to software engineering best practices like microservice architecture. But, is this right for data?</p><p>The original concept was proposed by Zhamak Dehghani, who asserted that a domain-driven, self-service approach to data was the way forward — a product approach to data, in which the data being collected is constantly evaluated to make sure it’s relevant, valuable and actually being used.</p><p>This concept stands juxtaposed to having one legacy monolithic system that contains all company data. Data mesh offers a decentralized approach to data management and puts it in the hands of people closer to the data and its uses.</p><p>This article will discuss the pros and cons of data mesh as well as steps that organizations should take to improve their strategies. My opinion is that this approach should have gained traction long ago, but we must proceed with caution and offer some possible modifications to the original concept.</p><p>If we fall fast for this new methodology and uproot our organizations, we have in part missed the point. As data picks up pace, we must organize them in a manner that is modular and as Agile as possible. This is challenging, because data are inherently less Agile than software for two reasons: 1) Any small change made to a data model has a cascading impact and 2) Most companies have created data warehouses that are both enormous and complex. It takes time and collaboration to create thoughtful data models that properly represent both the raw data and appropriate granularity of data across the organization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*xAVvb6JBUTgWq1vVsP9uiw.gif" /><figcaption>Image by <a href="http://www.johnqdo.com/">John Do</a></figcaption></figure><p><strong>What is a data mesh?</strong></p><p>A data mesh is domain-driven design (DDD) for data! In DDD, the structure of data is determined by the domains of an organization, so each domain would drive the organization and logic.</p><p>Since data are understandable as entities and attributes, both of which are naturally domain-driven, DDD makes at least as much sense here as it does for software engineering. Zhamak’s data mesh puts product thinking into the data domain where <a href="https://martinfowler.com/articles/data-monolith-to-mesh.html">data products are APIs</a>. Data needs to be clearly defined and documented — i.e., “discoverable.”</p><p>The data mesh concept has a lot in common with traditional data marts, which are aggregations of data in data warehouses that are often domain-driven and managed by a small team in a more Agile manner. They are used to answer specific strategic questions and develop insights.</p><p><strong>How can FAIR principles help?</strong></p><p>The <a href="https://www.paperlesslabacademy.com/2019/06/12/fair-principles/">FAIR principles</a> of data are in line with the goals of data mesh and provide clear components to check-off when building a data mesh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EXaxmFUCm4o44XWPLoVpFg.jpeg" /><figcaption>Image by <a href="http://www.johnqdo.com/">John Do</a></figcaption></figure><p>These principles ensure that data models and dictionaries for a particular data source can be found in a central location (“Findable”), and that access patterns and requirements are clearly documented with information on how to request access to a data source (“Accessible”). It is highly possible that HIPAA or PII training need to occur prior to someone getting access or that access is restricted to employees with a particular job title or type. The requirement here is simply that access requirements and restrictions are not a mystery to employees or users.</p><p>The “Interoperable” component mandates that the mechanism for translating between different data sources is clear. For example, if there is a domain for customers, a domain for orders, and a domain for vendors, the orders domain documentation should clearly indicate how to connect to both the customers and vendors domains from the orders data assets. In short, interoperability makes sure users can connect to domains from other domains.</p><p>Finally, the “Reusable” component brings all the components together. The point of creating any data asset is to be able to reuse the components in applications, tools and reports.</p><p><strong>What is right with data warehouses?</strong></p><p>Data warehouses give us a complete view of our company data. Two schools of thought are primary in data warehousing: the Inmon Enterprise Data Warehouse (EDW) approach and the Kimball dimensional modeling approach.</p><p>EDWs are good at fast writes and a traditional extract, transform and load (ETL) pattern. Dimensional modeling brought faster reads and a less normalized (more denormalized) approach to the table. New cloud data warehouses like Redshift or Azure Synapse make it easier to follow an extract, load and transform (ELT) method where the data warehouse itself is leveraged to perform transformations. So, there is still a decent amount of flexibility in the capabilities of data warehouses, especially newer ones on the market.</p><p><strong>What is wrong with data warehouses?</strong></p><p>If you have ever worked on a large, monolithic data warehouse you will be familiar with the pain involved in making any modifications to business logic OR incorporating new data OR addressing gaps in the data. It is slow, it is cumbersome, and it takes a while for the business to see the results. Often you need to befriend the 20-year veteran who worked on the initial conception to understand the intricacies of the data. If something were to happen, such as winning the lottery, retirement or a new opportunity outside their current organization, a large legacy of data knowledge could be lost. In my career I have seen many data warehouses that are plagued by a low <a href="https://en.wikipedia.org/wiki/Bus_factor">bus factor</a>, perhaps BECAUSE there is just so much to know.</p><p>EDWs were designed to house disparate data in a normalized manner due to expensive storage and relatively inexpensive compute (comparatively). Normalization ensures lack of redundancy and fast writes, but it comes at a cost: expensive joins and reads. More modern approaches to data storage tend to get away from full normalization. This means, going to first or second normal form usually suffices, and there is no performance need to force your data to conform to 6NF or DKNF (sixth normal form or domain-key normal form).</p><p>Aside from the EDW approach to data modeling, dimensional modeling is also a technique used in data warehousing.</p><p><strong>What could go wrong with data mesh?</strong></p><p>Lack of clear ownership over data can be a huge problem. Some replicated data is not necessarily a problem, but without clear team ownership the problem of data replication will exacerbate. Without clear ownership, you will potentially get different answers to the same questions by looking at different data products.</p><p>If you ask the same quantitative question to people in your organization and get different answers, this is an indication your data strategy is not working. These strategy failures are typically the result of poor management, not engineering.</p><p>I have seen competing teams calculate and forecast the same information from database systems built by those individual teams. Much more could be gained by working to create a common solution where engineering teams work with the business to establish common definitions and look to resolve conflicts between competing source systems. But creating a common solution and source of truth requires clear ownership by one team.</p><p><strong>What could go right with data mesh?</strong></p><p>When done properly, data mesh clarifies who owns the data and therefore who can help add additional features, provide more information about discrepancies and oddities, and work with business and software teams to resolve gaps.</p><p>Data is broken down into domains that do not need to be, and in most cases should not be, completely normalized. Completely normalized data is not necessary anymore because not only is storage cheap, normalization increases the join complexity for Business Intelligence (BI) and advanced analytics use cases. Instead, in most of the teams I have worked on we have opted for more of a “starflake” schema: a combination of snowflake and star. This has allowed for us to meet the requirements of other development teams, advanced analytics and reporting use cases.</p><p><strong>Possible Domain Division for E-Commerce Business</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yz4VNSmw_TFcrrjw123RqQ.jpeg" /><figcaption>Image by Author and John Do</figcaption></figure><p>Another important goal and ideal outcome of adopting a data mesh is that there are clear integration points between the domains (the interoperable piece in the FAIR principles). This can make use of an integration table or API endpoint, but it may also be built into <a href="https://www.kimballgroup.com/data-warehouse-business-intelligence-resources/kimball-techniques/dimensional-modeling-techniques/facts-for-measurement/">fact tables</a> exposed as APIs or planned beforehand. For example, to connect your customer domain to your order domain, you should include a customer ID in the fact table that summarizes your order details. You may also choose to include it in your primary order table to make joining customer and order details (not just high-level information) more efficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*fBhutA3yoE1DerNX_goAoQ.png" /><figcaption>Image by Author</figcaption></figure><p>The above diagram shows how transactions and analytics should be differentiated to ensure ACID compliance and robust analytical systems (more on this below). ACID stands for atomicity, consistency, isolation, and durability and is a critical consideration in database systems.</p><p><strong>A data mesh approach to data warehousing</strong></p><p>What if I want fast data of different grains? This is where I propose an alternative to the data mesh concept. I propose that we do not abandon the data warehouse but instead make domain-oriented data warehouses that capture the smallest grain of data available. If you are working in an e-commerce system, you want to store all the order updates and modifications, not just the current state. Current state can be stored in a fact table, and all this data can be consumed either directly from the table or in an API. Even if data is consumed directly from the database, read-replicas may come in handy to improve read performance since the replica will not be competing with the primary database. Read-replicas are not exactly real-time, but they tend to be eventually-consistent with single-digit millisecond latency, making them close enough to real-time to meet most business requirements.</p><p>APIs alone are not a data strategy, but they are part of a robust data strategy. API-first and API-only strategies are starting with the wrong question; they’re asking to move data without first asking if they should. Without analysis it’s hard to understand how you should do things, or if the application you’re looking to build even makes sense. It is easier to take a database and turn it into an API than the other way around. If you ever want to get insights from your data, API-first or API-only is not the way forward. APIs allow applications to talk to each other, so API-first is equivalent to application-first. APIs programmatically deliver data where data cannot be used for analytical purposes without relocating it into another data product. APIs lack compute and interoperability on location, so they are nowhere near a complete data strategy.</p><p>Databases provide stability and storage capacity to contain all data in a particular domain, such as orders. You may currently have multiple databases that contain order information, but it is worth the hard work of consolidating in such a way that avoids destructive transformations. Destructive transformations are data transformations that result in the loss of data. For example, if you aggregate your order data to only include the current state, ignoring all intermediate order changes, you are obfuscating some data that might be useful.</p><p>Critical to my proposed version of the data mesh is that at the data warehouse level, data should exist at the smallest grain, rolling up as needed in fact tables. And critical to the success of this approach is treating data as a product that exists in more modular components than the traditional EDW. Consolidating your databases in this manner is an important part of keeping your data as Agile as possible. So, if a column needs to be added for whatever reason, it is relatively simple to do so. Database and API development should occur in lockstep to make sure all requirements are met and the development cycle is as quick as possible.</p><p>I have seen extremely tangled webs of databases, but if a concerted effort is made to retire the legacy databases (which really is possible), your business can evolve much more readily. Using the concept of data mesh for data warehouses can help systematically retire legacy EDWs.</p><p>Also worth noting (in defense of the argument that APIs alone are not a data strategy) is that all BI tools on the market either require a database connection or may have an insufficient API connector. If they do have an API connector, they tend to not be as capable due to round-trip connections. But, even if you build your own socket connections for streaming data reliably, APIs should match the table schemas for data consistency and ease of use. REST APIs are an important part of the data strategy since they promote better security, are technology agnostic, and can be cached and scaled through use of a bastion or reverse proxy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WkRDf6tx-b5XSJy5Ug6WLw.jpeg" /><figcaption>Image by Author</figcaption></figure><p>*This API would return data in the same schema as the fact_orders table, but there could also be a parameter to select individual orders instead of simply pulling all available data.</p><p><strong>How do we migrate?</strong></p><p>Buckle up! It’s not going to be as hard as it sounds, but it involves a few key steps:</p><ol><li>Document your current systems and which domains they contain at a high level</li><li>Split up ownership of legacy EDWs and new systems at the schema or table level</li><li>Clearly define which data engineers are responsible for what data domains</li><li>Be comfortable with some duplicated data in different domains. You should still try to minimize duplication, but it is not something worth fighting over for a few columns that might be used slightly differently in different domains.</li></ol><p>Data engineers should openly discuss data grains with the stakeholders and include lineage at the record level. Building lineage in is often as simple as creating a “source” column; in many cases, legacy and new data will need to be staged together and transformed differently. Which data comes from which system will need to be as transparent as possible to improve data quality readily.</p><p>It is a lot of work to migrate a legacy monstrosity to one (or several) domain-driven data mesh(es), but it is worth it. Data doesn’t need to be a perpetual battle. All companies can take steps to solve their data issues through this process.</p><p>Decentralized command of data is required so that you can have success all the way down to the attribute level. Your data product and supporting team must have clear boundaries and guidance for the individual owners of the data. These boundaries and guidance can include class words for naming consistency, standard cleaning scripts, approaches for handling data with different delay requirements, etc. Domain teams need to understand the intricacies of the data they are working with and how it relates to the overall business. Proper command and control for data is hard, requires building trust and psychological safety, but it is possible.</p><p>Much like going to the moon in the 1960s, getting your corporate data in order is hard but necessary. It requires significant initial effort, but it is a worthy effort. And those that do not rise to the occasion are doomed to be left behind.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd71e55490ba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/a-data-mesh-approach-to-data-warehousing-cd71e55490ba">A Data Mesh Approach to Data Warehousing</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>