<?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 Emily McMahon on Medium]]></title>
        <description><![CDATA[Stories by Emily McMahon on Medium]]></description>
        <link>https://medium.com/@emilymc_64109?source=rss-d42062dd5c15------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*0QJkDYWSFfcZfg9g.jpg</url>
            <title>Stories by Emily McMahon on Medium</title>
            <link>https://medium.com/@emilymc_64109?source=rss-d42062dd5c15------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 15:24:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@emilymc_64109/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[Unified Event Logging]]></title>
            <link>https://medium.com/remitly/unified-event-logging-3a4cc64fa1c6?source=rss-d42062dd5c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a4cc64fa1c6</guid>
            <category><![CDATA[engineering-technology]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[big-data]]></category>
            <dc:creator><![CDATA[Emily McMahon]]></dc:creator>
            <pubDate>Fri, 22 Feb 2019 03:00:45 GMT</pubDate>
            <atom:updated>2019-03-13T06:08:05.040Z</atom:updated>
            <content:encoded><![CDATA[<h3>How we built a better, unified logging platform</h3><p>Before Unified Event Logging (UEL), we had multiple methods for recording events in our products, The data was stored in just as many locations. Most commonly, we used our production RDBMS for event logging. Naturally, the production database incurred a performance hit for recording all this event data.</p><p>For most event logging, we don’t need the value adds of an RDBMS: transactions, mutating rows, and low latency. Instead, we want higher throughput. Moreover, as we split out products into individual services (each potentially with their own storage system), we destroy the scalability of analytics as discoverability of data becomes impossible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YRcokucTFd6Wp5rz8AN2fA.png" /></figure><p>Essentially, UEL avoids the O(n²) explosion above, and achieves the O(n) system below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jI4zCA1t6IJs_5qdRSO7Vg.png" /></figure><p>For every service, there are cross-cutting concerns that are interested in the same stream of data — an event log of “what is happening” within that service. In particular, the service publishing the data</p><ul><li>doesn’t need to block on delivery and consumption of that data</li><li>shouldn’t have to make code changes to add more consumers for the same data stream</li><li>shouldn’t take the performance hit from handling the fan-out itself</li></ul><p>Thus, UEL meets the desirable points stated above: UEL publishes streams of events in a central place for discoverability while decreasing the number integration work required of dev teams. Concerns that can be handled asynchronously are handled asynchronously with very low-overhead SDKs, mitigating the performance concerns of additional service integrations. We also shift the burden onto an external system, reducing the load on our production OLTP system.</p><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0edwaw1p6VwgXeCvnm2RLQ.png" /></figure><p>At a high-level, all our hosts send data to a centralized ingestion point. This centralized point validates the events against declared schemas and then fans out the events to various places. We have a periodic job that creates Redshift tables using the schemas and does an incremental load.</p><p>The DLQ is actually several SQS queues. One is a true DLQ for events that fail very early on in the validation (typically these are events we cannot even parse due to clobbering). Additionally we have an invalid queue per team for events that are parseable but do not validate against the declared schema. We have one queue per team to make it easy for our users to fix and re-drive their failed events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dOaqLFuLalE2lNyC5IBogw.png" /></figure><p>On the hosts, every UEL SDK logs to rsyslog. These messages are periodically gathered by heka and shipped off to the collector.</p><p>For client-side events we obviously cannot use heka &amp; rsyslog. Instead our apps periodically send batches of events to an ingestion point. This ingestion point is used as a middle man where we can remove any malicious events before forwarding the events to the collector.</p><h3>The Events</h3><p>We knew we wanted the data to end up in our analytics warehouse. To facilitate this we require an event schema. That schema is used to</p><ul><li>validate the events</li><li>create tables in our warehouse that we periodically load the events into</li></ul><p>Every UEL event includes its schema name. The schemas themselves are described using Avro with one major modification: we introduced a composition feature to encourage schema re-use.</p><pre>{<br> “name”: “work_items”,<br> “doc”: “Events of the work_items state machine”,<br> “team”: “cst-engineering”,<br> “includes”:[“event_data/1.0”],<br> “valid_events”: [“create”, “cancel”, “finish”, “lock”, “unlock”, “steal”]<br> “type”: “record”,<br> “fields” : [<br> {<br> “name”: “work_item_id”, “type”: “int”,<br> “doc”: “the ID of the work_item”<br> },<br> {<br> “name”: “employee_name”, “type”: [“null”, “string”],<br> “doc”: “the employee who altered the work_item — can be null due to system modifications”<br> }<br> ]<br>}</pre><p>Schema composition posed a challenge as it’s much easier to develop tooling for flat data representations. So we took the extra step of defining our schemas in one language, and then transpiling them to a flat Avro Record.<br> <br>We made small modifications for usability: allowing CSON and JSON (although the CSON is transpiled into JSON) and enforcing the inclusion of a team field (so we can track down the owning team on validation failures).</p><h3>Data Loss</h3><p>One of the biggest concerns moving from a transactional database to an event stream was data loss.</p><p>To measure this, every Remitly host regularly emits “heartbeat” events. These heartbeat events are emitted with a nonce that allows us to infer our data loss by inspecting for missing events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MjeZkNMzbeeFRSlVDw2Q4g.png" /></figure><p>Note that this provides an upper bound for data loss. If we’re missing events after the biggest nonce, we’ll never know. This situation is indistinguishable from the heartbeater dying or a service restart so it’s a bit tricky to detect. Until we have reason to suspect that this is a problem we’re fine with this estimate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zwelmR3G8Af-1zRTyS1r3w.png" /></figure><p>Our loss rate of 0.0004% is well within our tolerance for most use cases. We’ve devised other methods for systems that cannot tolerate a lost event, such as financial event logging.</p><h3>Challenges</h3><p>UEL takes a very little operational support, especially when viewed relative to its business impact. Our biggest challenges with it stem from the fact that it’s so stable. On the rare occasions where something does break, we have to delve into codebases we haven’t touched in months or years.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a4cc64fa1c6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/remitly/unified-event-logging-3a4cc64fa1c6">Unified Event Logging</a> was originally published in <a href="https://medium.com/remitly">Remitly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>