<?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 Barry Ralston on Medium]]></title>
        <description><![CDATA[Stories by Barry Ralston on Medium]]></description>
        <link>https://medium.com/@barryralston?source=rss-a0a7e7c60ae9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*IY3VgFy4eDEBb8ziUOMrVA.jpeg</url>
            <title>Stories by Barry Ralston on Medium</title>
            <link>https://medium.com/@barryralston?source=rss-a0a7e7c60ae9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 19:12:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@barryralston/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[When to Swing the Hammer]]></title>
            <link>https://medium.com/@barryralston/when-to-swing-the-hammer-bde13b5ad1f?source=rss-a0a7e7c60ae9------2</link>
            <guid isPermaLink="false">https://medium.com/p/bde13b5ad1f</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Barry Ralston]]></dc:creator>
            <pubDate>Mon, 03 Feb 2020 16:01:01 GMT</pubDate>
            <atom:updated>2020-02-03T16:01:01.294Z</atom:updated>
            <content:encoded><![CDATA[<h4>The Problem &amp; Solution to Sourcing Data from Two Places</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nKRAl7_KhetNAx0j" /><figcaption>Photo by <a href="https://unsplash.com/@mphotographym?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Moritz Mentges</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>My wife Kim and I are refurbishing a home we recently purchased in her hometown of Southside, Alabama. The house was built in 1978 and perhaps had a hammer last swung in maintenance that same year. Always the planner, I accumulated a list of over 250 tasks that would need to be done before we could move in. The closing day left us both thrilled to have acquired our “Fixer Upper” and with trepidation of the months ahead.</p><p>Some tasks in such an undertaking require a great deal of skill and experience. I marvel at how the craftsmen fit together the flawless miter in the trim around our new entry doors with speed and efficiency. But there are also tasks that require only strength and determination to finish, such as removing the popcorn ceiling so popular in the 1970s. Or, having successfully tested negative for asbestos, removing the lime green and yellow linoleum lurking under the cracking tile in the laundry room. In a home rehabilitation journey, you have to know when to swing a hammer and when to write a check.</p><p>Software development has been compared to construction in many ways for many years. But in Shipt’s journey to maintain business visibility while moving from a <a href="https://shipt.tech/performance-is-a-feature-7a2451f1bf5b">monolith to microservices</a>, we too have had to determine when to swing a hammer (or our keyboards) and when to write a check.</p><h3>The Problem</h3><p>At Shipt, a principle driver of our migration from monolithic architecture to one based on microservices is to increase development agility. The prime directive of our Data Warehouse team is to create a unified data platform for continued business visibility through our microservices transformation. As our journey is a continual migration, we need to consume data from both our monolith’s Postgres database, which we call Platform DB, and the backing stores for the individual microservices. The Data Warehouse needs to use both data sources to create a unified, conformed view of the business.</p><p>These twin data pipelines of our project are being developed in parallel. One half of the project is composed of the data pipelines for consuming Create, Replace, Update, and Delete (CRUD) and business events from the various microservices into our Data Lake for <a href="https://shipt.tech/the-case-for-the-data-lake-fc4ba9ac85ea">eventual surfacing in our Data Warehouse</a>. The remaining half of the project is the data pipeline for replicating our Platform DB into our selected Data Warehouse platform, <a href="http://snowflake.com/">Snowflake</a>.</p><p>Jeopardizing the Platform DB by attempting to service analytic queries is a problem that has spread with contagion at Shipt. Overloading the Platform DB necessitates the maintenance of five read replicas in order to serve the analytic query needs. In a pattern certainly repeated by other data-driven organizations, query workloads submitted to the read replicas create a replica lag, which in turn both elongates query execution times and creates latency problems with the results of the queries. The analytic queries asking for real-time data on business activities instead return data that is anything but real-time with replication lags that routinely exceed an hour.</p><p>A logical replication solution allows our client Data Warehouse pipeline to consume changes to the Platform DB without creating additional workload on it. Specifically, we desired a replication strategy utilizing the Postgres Write Ahead Log (WAL) that would supply our data pipeline with real-time change data capture using what is essentially a by-product of the Platform DB. The WAL is a Postgres structure used to log changes committed to the database before those changes are written to Postgres table and index data files. As the master ledger of Platform DB activity, it is ideal as a source of truth for logical replication.</p><p>Additionally, our Platform DB contains information not necessary in the context of the Data Warehouse. Filtering columns from our Platform DB rules out yet another read-replica or byte-level replication. Instead, our final solution involves logical replication to move selected data from the platform to the Data Warehouse database.</p><h3>Solution Constraints</h3><p>When we first put it to the test, our analysis yielded a handful of constraints for our solution:</p><ol><li>We couldn’t add workload to the Platform DB. Ideally the solution would reduce workload on the platform by permitting retirement of the read replicas and redirecting analytic queries to the Data Warehouse.</li><li>A successful solution using the Postgres WAL would require a consumer process to take the changes in the WAL and map activity to the tables and columns in the target database. Logical replication based on the Postgres WAL is not without potential problems. Replication clients that fail to process changes on a timely basis can put the health of the Postgres “master” database in jeopardy should an unchecked WAL grow to the point of exhausting physical storage.</li><li>Any logical replication to the Data Warehouse would require two phases — an initial load to capture database state at the beginning of replication and an on-going change data capture process to maintain the logical synchronization between the platform “master” and the Data Warehouse “target” databases.</li></ol><p>Another consideration was the Postgres maintenance window that our Platform DB would have to undertake in order to make the parameter changes to enable WAL-based replication. As a 24/7 service, maintenance windows involving a service outage, which a restart of the Platform DB would doubtless cause, are avoided except when absolutely necessary.</p><h3>The Danger of Unchecked Replication</h3><p>When a Postgres Replication Slot is created, the ability for the master database to flush changes from the WAL is dependent upon the replication slot client’s timely processing of the changes in the WAL. If the client replication process fails to notify the master database that changes have been processed, the files for the WAL will continue to grow, consuming space that can put the health of the Postgres master at risk.</p><p>As illustrated below, the Postres WAL contains the data necessary to apply changes in order as they are committed to the source database. The vertical lines separate transactions each beginning with an address in the data stream that is used as the Log Sequence Number or LSN. The LSNs can be used to determine the amount of replication lag in bytes by calculating the difference in the location of the first transaction and the last transaction in our example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fw3nfqO135DZpxv6" /></figure><p>After successfully applying changes from the WAL to the target database, our Fivetran connector will notify the source database the WAL may be flushed and the recovery LSN may be advanced to the next, unprocessed transaction in the stream. As depicted below, the transactions in green have been consumed by the target database, and the source database no longer needs to maintain the data for replication purposes. It is important to note additional changes will likely be continuing to grow the WAL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JXTrYUYUhmyzc7s5" /></figure><p>We put in place two monitoring strategies to detect and alert of this condition. The first is a tool developed by our DBA team, who are responsible for the health and monitoring of all of our Postgres instances. Their tool, which we fondly dubbed <a href="https://venturebrothers.fandom.com/wiki/Snoopy">Snoopy</a>, reports on the WAL consumption via a Slack channel. Snoopy was integrated with our existing on-call alert processing to notify the DBA and Data Warehouse teams in the event that our WAL consumption becomes excessive or threatens the health of the Platform DB. The second is configuration within our <a href="https://fivetran.com/">Fivetran</a> connector to trigger an email alert to the Data Warehouse team in the event of detected lag in processing the changes from the source, Platform DB. Fivetran looks for changes every five minutes, and if a set of changes takes longer than thirty minutes to process, the Data Warehouse team is alerted.</p><h3>Build or Buy</h3><p>Fivetran is one of many products in the market that provide logical replication from Postgres to a target database, including Snowflake. The Postgres WAL contains all of the changes to the source database as a set of JSON messages. For logical replication to succeed, the WAL messages must be monitored, mapped to the target schema, applied to the target, and indicated as processed to the replication slot in order to flush WAL storage and avoid the WAL storage runaway condition.</p><p>Prior to landing on these products, we considered writing our own software to consume the replication slot messages. However, as we explored this option, the maintenance load for the in-house option seemed to outpace the benefits. As we migrate from the monolith to microservices, the forecast service life seemed to be small — on the order of a couple of years before no changes would be happening in our Postgres source.</p><p>In logical replication mode, the data stream reflects data manipulation language (DML) consisting of inserts, updates, and deletes. Data definition language is not explicitly accounted for in the replication data stream. Each change does contain the table name, column name, column data type, and column contents, so create table and alter table statements can be inferred from the data stream. Another benefit of Fivetran is the effect of schema-on-read flexibility with a relational and schema-on-write Snowflake database.</p><p>The initial load of our Platform DB was planned for the weekend following our maintenance window for the required Postgres parameter changes. After 36 hours of processing, our Platform DB initial synchronization was completed. The Fivetran connector was showing change data capture occurring on a regular basis within our targeted processing window.</p><h3>Our Implementation</h3><p>The implementation of logical replication for our Platform DB was not a simple matter of creating a replication slot and configuring Fivetran to utilize it. A maintenance window was scheduled and executed. Specifically, the configuration parameter <strong><em>wal_level</em></strong> was set to <em>logical</em>, and after a restart of the database server, our source database produced a logical decoding of the data changes, data manipulation language queries (DML) and was ready for logical replication.</p><p>A fragment of the logical decoding of the WAL, describing changes to the public.orders table is below. Immediately after the table is the operation (in the case of these two rows an insert and update). Finally, the value of each column in the table, including the data type, completes each record.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/626eb97521f44cab58f86e862c7bcf5e/href">https://medium.com/media/626eb97521f44cab58f86e862c7bcf5e/href</a></iframe><h3>Winning Results</h3><p>As a grocery delivery platform, the week of the Thanksgiving Holiday in the United States translates into our peak volume. The telemetry that both the DBA team and the Data Warehouse team put in place to monitor both the disk storage consumption of the Write Ahead Log and the latency of the Fivetran connector was under a microscope of scrutiny. Our teams were on-call with standing orders to drop the replication slot, which would render the Data Warehouse out-of-sync in the event that any process associated with logical replication put the Platform DB and our Thanksgiving Week at risk.</p><p>I am thrilled to report that not only did we make it through our initial peak week, but spikes in our business volume over the closing weeks of the year never tripped our alarms. We have been synchronizing our Postgres Platform DB successfully ever since.</p><p>If you find these database intensive pursuits interesting or you’re looking for an innovative team to join, <a href="https://www.shipt.com/careers/openings/">we’re hiring</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bde13b5ad1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Case for the Data Lake]]></title>
            <link>https://medium.com/@barryralston/the-case-for-the-data-lake-fc4ba9ac85ea?source=rss-a0a7e7c60ae9------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc4ba9ac85ea</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[data-lake]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Barry Ralston]]></dc:creator>
            <pubDate>Mon, 22 Jul 2019 15:01:01 GMT</pubDate>
            <atom:updated>2019-07-22T15:01:01.030Z</atom:updated>
            <content:encoded><![CDATA[<h4>Charting a Course from Microservices to Data Analysis</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iQC7tp_3unIxBRwL" /><figcaption>Photo by <a href="https://unsplash.com/@theexplorerdad?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Joshua Ness</a> on <a href="https://unsplash.com/search/photos/kayak?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Father’s Day this year, my son Trent and I took our kayaks down a stretch of class II rapids on the Coosa River from the Jordan Dam to the city of Wetumpka. Though we are both experienced kayakers on flatwater, this was our first whitewater trip. After a crash course in reading whitewater from one of the guides, we found ourselves alone in the approach to the Moccasin Gap set of rapids. From our position being pushed by the current into the first chute, it was difficult to see a navigable path through the rocks and rolling water. We managed to make it safely and upright through to the flat water below. As we turned our tiny vessels to admire what we had just been through, the correct path (and far from the one we used) was as evident as a dotted line on a map. Hindsight is indeed 20/20.</p><p>In technology, we often face rapids that are difficult to navigate. The correct path may not be evident until you have managed to safely navigate the rough water, or in some cases, until you’re halfway down it. At Shipt, we find ourselves charting a new path as we break our monolithic application into microservices — each with their own backing store and divorced from the monolithic database.</p><p>A microservices architecture is not a panacea. As a data-driven enterprise, our business functions have developed a significant stack of SQL-based tooling (reports/graphs/dashboards) tied directly to the original monolith’s relational database structures. Read-only replicas are used to permit real-time (minus replication lag) analysis — albeit against a set of data structures designed for transaction capture and not analytical, set-based queries. In the microservices world, there is no singular database and data engineering/data science resources are in short supply. How do we replace the one-stop data shop in a platform with multiple backing stores?</p><p>A data warehouse has been the traditional answer to this problem, but in a platform that could have dozens or hundreds of independent microservices, a data warehouse has a potentially fatal flaw. Each of the microservices releases versions of their service from continuous integration/continuous deployment (CI/CD) pipelines. Each release could bring about a schema change in the backing stores, which may be schema-less or schema-on-read at the least. An impedance mismatch occurs between the traditional data warehouse, hosted in a schema-on-write RDBMS, and the backing stores for the services. The resolution of the mismatch would usually be resolved in the Extract, Transform and Load (ETL) logic or Extract Load and Transform (ELT) code. Code means engineers and testing and support. There has to be a more productive solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-0WgaTrO11zQCeVwnFBhHg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@joshuaearle?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Joshua Earle</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>The Data Lake</h3><p>A Data Lake can be defined as a “<a href="https://www.mckinsey.com/business-functions/digital-mckinsey/our-insights/a-smarter-way-to-jump-into-data-lakes">system to hold, process, and analyze structured and unstructured data.</a>” The simplicity of the solution is its elegance and utility. Each of our microservices conforms to a contract to send entity CRUD and business event data to a queue for eventual, nearly immediate storage in AWS Simple Storage Service (S3). The pipeline specifics is another conversation on its own, but for now let’s declare the end result is a set of JSON files in S3. This preserves the raw data with no loss of fidelity that would occur as the result of an ETL/ELT process. Instead, the business event and entity data is available for multiple processors to leverage. An <a href="https://aws.amazon.com/emr/">Elastic Map Reduce (EMR) cluster</a>, <a href="https://aws.amazon.com/athena/">AWS Athena </a>(Presto as a service), and pySpark in a Spark cluster (or <a href="https://aws.amazon.com/glue/">AWS Glue</a>) can all utilize the data. Best of all, this requires <strong>no code</strong> to accommodate source schema changes in the Data Lake. All of the data from the source services is available in the lake as soon as it’s published, minus pipeline lag. The next step to making the data available is to fill the Data Lake.</p><h3>The Aqueduct</h3><p>Our first-generation Data Lake leverages a set of services available from AWS, including SNS, SQS, and S3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gp4keE1X9gLvByBT3iU7vA.png" /></figure><p>As illustrated above, the Cart Service publishes CRUD events to an SNS topic, <strong><em>bus_cart-service_crud-event</em></strong>. The message consists of data elements common to SNS as well as a message payload specific to the Cart Service. SNS is intended for pub/sub messaging for distributed systems. Additionally, SNS messaging allows for time-critical publication and consumption by topic subscribers. But in order to make use of the SNS topic, we leverage the SQS fanout architecture pattern.</p><p>Fanout is used when a single SNS message may have multiple processes subscribing to the SNS topic, each with their own asynchronous processing. We have a service producing information (Cart), which is of interest to many downstream processes or consumers. The AWS SNS to SQS services provide connections between the SNS topic and an SQS queue.</p><p>In our case, many SQS queues and other processors are subscribed to this topic, but the only queue we are interested in for Data Lake “plumbing” is bus_cart-service_crud-event_data-lake-ingest. The SQS queue serves two purposes:</p><ol><li>It is the logical protocol of choice given the SNS processor options of SQS, creating an http/https endpoint, email, SMS or an AWS Lambda.</li><li>Favoring configuration over code. As the lowest of the low-code options, the SNS to SQS connection makes the most sense.</li></ol><p>SQS is available in two different types, Standard and FIFO. Unfortunately FIFO queues are not <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-subscribe-queue-sns-topic.html"><em>currently</em> compatible</a> with SNS, but the Standard type is sufficient for our needs. A potential obstacle that must be overcome is the “best effort” ordering of messages. The order in which CRUD operations are processed is critical to representing the state consistently in the Data Lake.</p><p>The next step in the process is leveraging Logstash to move our messages from SQS into S3. We move the SQS messages to S3 when 5MB of messages have accumulated or every 5 minutes, whichever happens first.</p><pre># upload batch after ${size_file} or ${time_file}, whichever comes first<br>rotation_strategy =&gt; “size_and_time”</pre><pre># upload after 5MB of data<br>size_file =&gt; 5242880 # upload after 5MB of data</pre><pre># upload after 5 minutes<br>time_file =&gt; 5</pre><p>The motivation for this strategy is two-fold:</p><ol><li>We avoid a 1:1 relationship between messages and S3 files. This has two benefits. First we avoid a large number of files in S3, by grouping activity by SNS message sent time. Second, the AWS Glue Job uses these raw files to create Parquet, an Optimized Row Column (ORC) copy of the raw data creates a compressed, splittable copy of the data for efficient reading by AWS Athena.</li><li>Because of the best-attempt message ordering by SQS, batching the messages maximizes the opportunity to ensure consistency in the Data Lake. While we are not solving for potential out of sequence messaging in the Data Lake, both partitioning and creation of Parquet files for Athena queries means CRUD operations for a given entity will be represented accurately.</li></ol><p>Once the messages are reflected as files in S3, AWS Glue Crawler is used to crawl the S3 data store in order to derive the schema and any changes that have occurred to the structure. Second, an AWS Glue Job is used to transform the data from S3 to an optimized row store (ORC) format, in our case Parquet. As part of the Glue processing, a central metastore or the Glue Catalog, is updated with information about the Cart data, making the columns available in AWS tooling like Athena.</p><h3>Just the Beginning</h3><p>Creating the repository of our business event and entity data is just a start. The Data Lake is not a solution to every data access issue, but it absolutely adds data analysis capabilities to nearly raw, historical data with no extraction burden on the source services. Teasing out point-in-time or historical perspective from the Data Lake will require additional processing, which is best served by a dimensional model in a data warehouse. Of course, the Data Lake usage patterns can add additional perspective to the design of the dimensional model for our data warehouse. Down the river, federated query to access newly added attributes in the Data Lake combined with a dimensional model in the data warehouse may soon augment the data analysis toolset at Shipt.</p><p>If you have a knack for plumbing data lakes, or if you find creating value from web-scale data interesting, we’re hiring. Check out our <a href="https://www.shipt.com/careers/openings/">careers page</a> to learn more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc4ba9ac85ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>