<?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 Jose Nino on Medium]]></title>
        <description><![CDATA[Stories by Jose Nino on Medium]]></description>
        <link>https://medium.com/@junr03?source=rss-8e5e2bb06aab------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*RjMvdyIwVcl6W1XS.jpeg</url>
            <title>Stories by Jose Nino on Medium</title>
            <link>https://medium.com/@junr03?source=rss-8e5e2bb06aab------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 06:08:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@junr03/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[Observability for the Missing Hop]]></title>
            <link>https://eng.lyft.com/observability-for-the-missing-hop-6688c6f3911a?source=rss-8e5e2bb06aab------2</link>
            <guid isPermaLink="false">https://medium.com/p/6688c6f3911a</guid>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[time-series-data]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[envoy-proxy]]></category>
            <dc:creator><![CDATA[Jose Nino]]></dc:creator>
            <pubDate>Wed, 12 Feb 2020 17:52:53 GMT</pubDate>
            <atom:updated>2020-06-25T19:01:14.490Z</atom:updated>
            <content:encoded><![CDATA[<h3>Envoy Mobile time-series metrics</h3><p><a href="https://www.envoyproxy.io/">Envoy’s</a> guiding vision has always been:</p><blockquote>The network should be transparent to applications. When network and application problems do occur it should be easy to determine the source of the problem.</blockquote><p>The second part of this vision has played an important role in Envoy’s increasing presence in modern day distributed systems. Envoy has a best-in-class, comprehensive suite of observability data points. From distributed tracing, to logging, to time-series metrics, data from Envoy allows an operator to understand their system.</p><h3>Time-series metrics for the server</h3><p>At Lyft, time-series metrics emitted by Envoy enable engineers to explore different system conditions. For instance, they are able to see the concurrency that a service has at a given time, or the amount of healthy nodes for a particular service, or latency at p95. The possibilities seem almost endless. While this plethora of metrics is incredibly powerful, I would argue that the most powerful aspect is consistency: engineers are able to use the same metrics and dashboards to observe all of Lyft’s systems, regardless of which microservice they are interested in. Since Envoy runs at every hop of the network, every hop of the network emits the same metrics! (For more details on Lyft’s Envoy dashboards, please take a look at this <a href="https://blog.envoyproxy.io/lyfts-envoy-dashboards-5c91738816b1">blog post</a>).</p><h3>The missing hop</h3><p>There is one hop in Lyft’s network mesh that did not enjoy the same consistency in observability: the hop from our mobile clients to the edge of our server infrastructure. This is an important hop in our network — perhaps even the most important. In the words of our <a href="https://eng.lyft.com/announcing-envoy-mobile-5c2067d9ade0">blog post</a> announcing Envoy Mobile:</p><blockquote>Three 9s at the server-side edge is meaningless if the user of a mobile application is only able to complete the desired product flows a fraction of the time.</blockquote><p>If we are unable to observe this hop, we are unable to improve reliability and resilience for our mobile clients. Among the many reasons expanded upon in our <a href="https://eng.lyft.com/announcing-envoy-mobile-5c2067d9ade0">previous</a> <a href="https://eng.lyft.com/lyfts-journey-through-mobile-networking-d8e13c938166">blog</a> <a href="https://eng.lyft.com/envoy-mobile-v0-2-deep-dive-7ed262cfdf93">posts</a>, observability for this hop was a big reason why we decided to invest in Envoy Mobile. By giving our mobile clients the same observability stack as our other hops, we could obtain metrics that were consistent with ours <a href="https://blog.envoyproxy.io/lyfts-envoy-dashboards-5c91738816b1">server infrastructure</a>.</p><h3>Envoy Mobile to the Rescue!</h3><p>We <a href="https://eng.lyft.com/envoy-mobile-v0-2-ready-for-donuts-a8aa852a900b">announced</a> the release of Envoy Mobile <a href="https://github.com/lyft/envoy-mobile/releases/tag/v0.2.0">v0.2</a> in November. In that announcement, we mentioned that Envoy Mobile had replaced the networking libraries in Lyft’s alpha rider app and that we were going to build observability integration into Envoy Mobile. The rest of this blog post describes how we executed on this and in order to start taking advantage of Envoy’s time-series metrics on our mobile clients as of early December.</p><h4>Envoy Extension Points</h4><p>One of Envoy’s most powerful features is all of its <a href="https://www.envoyproxy.io/docs/envoy/latest/extending/extending">extension points</a> — probably only second to its best-in-class observability. Envoy can be extended to add more filters (both at L4 and L7), new transport sockets, and new health checkers. Most pertinent to our work on observability is the fact that Envoy has an extensible <a href="https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/observability/statistics#arch-overview-statistics">stats sink</a> interface. This means that developers can create new ways to expose Envoy’s time-series metrics by creating new stats sink implementations.</p><p>One of the stats sink implementations is the “<a href="https://www.envoyproxy.io/docs/envoy/latest/api-v2/config/metrics/v2/metrics_service.proto#envoy-api-msg-config-metrics-v2-metricsserviceconfig">metrics service</a>” stats sink. This implementation encodes metrics in <a href="https://github.com/prometheus/client_model/blob/master/metrics.proto">Prometheus’ protobuf format</a> and sends them over gRPC to a remote service. This is a fitting model for Envoy Mobile because we can’t install a stats collector on phones, nor can we scrape metrics from a known endpoint.</p><h4>Mobile Metrics Infrastructure</h4><p>Lyft’s Envoy Mobile metrics pipeline looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*z7fPqvrjVNrdtXTM" /><figcaption>Envoy Mobile metrics pipeline</figcaption></figure><p>On the left we have the mobile clients running Envoy Mobile as their network library. Envoy’s stats configuration allows us to configure two important aspects for the mobile environment:</p><ol><li>Stats flushing interval: given battery and data concerns in mobile environments, we must finely tune flushing intervals over longer time periods. In the long term, we would like to change <a href="https://github.com/lyft/envoy-mobile/issues/573">flushing to be based on OS level signals</a> like app backgrounding or termination.</li><li>Metric emission filtering: Envoy emits hundreds of different metrics, and not all of them are useful in a mobile environment. Envoy allows us to configure an <a href="https://github.com/lyft/envoy-mobile/blob/d27f0deb854d931f59effb0da6b9e2f8b9a6c4cc/library/common/config_template.cc#L80">inclusion_list of metrics tags</a>, as well as which metrics families to emit.</li></ol><p>Moreover, Envoy has a very useful property in its bootstrap configuration, the <a href="https://www.envoyproxy.io/docs/envoy/latest/api-v2/config/bootstrap/v2/bootstrap.proto.html?highlight=node">node property</a>. This field is used to identify an Envoy instance. In Envoy Mobile, we use it to tag the mobile client with <a href="https://github.com/lyft/envoy-mobile/blob/d27f0deb854d931f59effb0da6b9e2f8b9a6c4cc/library/common/config_template.cc#L95">useful information</a> like which OS it’s running on (i.e., “Android” or “iOS”). In the future, we could send even richer information such as the client release version, the OS version, the user-id, etc. The reason this metadata is useful is because it can be used in a metrics aggregation service to enrich the metrics collected from our clients.</p><p>The Metrics Service is a gRPC service we built to receive metrics from the clients (and is represented by the red block above). At its most basic, the Metrics Service receives metrics from clients on a gRPC stream, transforms them to statsd format (using Lyft’s <a href="https://github.com/lyft/gostats">gostats library</a>), and emits them to statsd aggregators. Using the rich metadata from the node field, the Metrics Service can also perform online aggregation based on runtime parameters. For instance, if we would like to aggregate metrics based on a specific client release to track down a bug, we can do that! Very powerful mechanisms can be built on top of this on-demand aggregation to keep costs low at steady-state, while allowing us to tap into a mine of data when it is useful.</p><h4>End Result</h4><p>After the metrics are aggregated, they are available to be plotted via the same front ends described in Lyft’s Envoy dashboard <a href="https://blog.envoyproxy.io/lyfts-envoy-dashboards-5c91738816b1">blog post</a>. This consistency allows service owners to work with tools they are already accustomed to. One of the most powerful moments I personally had in the last six months of working on Envoy Mobile was when I was able to plot the following two graphs side-by-side:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*9mPf23i3WX8O-Zgs" /><figcaption>request volume for envoy mobile (above) and Lyft’s edge envoy (below)</figcaption></figure><p><strong>These two graphs are plotting the same Envoy metric (</strong><strong>upstream_rq.count i.e., network traffic volume coming into Lyft’s platform), over the same time period. The important difference is that the top graph is plotting metrics coming from our mobile clients (Envoy Mobile), and the bottom one is plotting metrics coming from our edge infrastructure (Envoy Proxy). The top graph shows us the missing hop for the first time!</strong> Moreover, we have access to this data via the same metrics names as the rest of our infrastructure. This consistency goes a long way in reducing the cognitive load of the server engineers that operate infrastructure at Lyft, and we are now able to extend it to our mobile engineers as well.</p><p>It is truly powerful to be able to see complementary graphs like the ones above. The dashboards that we are now able to build give us insights that we did not have before, and we were able to do this by leveraging Envoy Mobile and Lyft’s existing metrics infrastructure. We built a transparent and observable network experience that <em>finally</em> includes mobile clients.</p><h3>Future Work</h3><p>This is just the first of many examples of the possibilities we are unlocking by using a unified network primitive across all platforms, with Envoy Mobile on our mobile clients and Envoy Proxy on the server. It highlights the fact that we can start reaping benefits by leveraging pre-existing infrastructure thanks to Envoy and Envoy Mobile’s flexible extension points and their plethora of observability data. If you are interested in reading learning more about Client Networking at Lyft or Envoy Mobile, please head over to the <a href="https://envoy-mobile.github.io/docs/envoy-mobile/latest/intro/additional_resources.html">additional resources</a> section in the Envoy Mobile docs.</p><p>Envoy Mobile is being built completely in open source, with publicly available <a href="https://github.com/lyft/envoy-mobile/issues?q=is%3Aopen+is%3Aissue+milestone%3A%22v0.3+%5C%22Secondi%5C%22%22">milestones</a>. If you find this work interesting, please come join us: <a href="https://github.com/lyft/envoy-mobile/issues/new">open up an issue</a> for a feature you’d like to see, or (even better) a PR!</p><p><em>Este artículo también </em><a href="https://medium.com/lyft-engineering-en-espa%C3%B1ol/observabilidad-del-salto-de-red-oculto-b72f6f157044"><em>está en español</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6688c6f3911a" width="1" height="1" alt=""><hr><p><a href="https://eng.lyft.com/observability-for-the-missing-hop-6688c6f3911a">Observability for the Missing Hop</a> was originally published in <a href="https://eng.lyft.com/">Lyft Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Envoy Mobile v0.2 deep dive]]></title>
            <link>https://eng.lyft.com/envoy-mobile-v0-2-deep-dive-7ed262cfdf93?source=rss-8e5e2bb06aab------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ed262cfdf93</guid>
            <category><![CDATA[envoy-proxy]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mobile-development]]></category>
            <dc:creator><![CDATA[Jose Nino]]></dc:creator>
            <pubDate>Tue, 04 Feb 2020 17:40:34 GMT</pubDate>
            <atom:updated>2020-02-04T17:40:34.766Z</atom:updated>
            <content:encoded><![CDATA[<p>In November we released <a href="https://github.com/lyft/envoy-mobile/releases/tag/v0.2.0">Envoy Mobile v0.2</a>. In the accompanying <a href="https://eng.lyft.com/envoy-mobile-v0-2-ready-for-donuts-a8aa852a900b">blog post </a>we detailed the features that the library supported and announced that we had replaced the networking libraries in Lyft’s alpha rider app with Envoy Mobile. In this blog post, I want to expand on the technical aspects of the v0.2 release and take a technical deep dive of Envoy Mobile’s current architecture.</p><h3>Why Bring Envoy… to Mobile?</h3><p>Many companies, Lyft included, have realized the benefits of deploying Envoy across their backend infrastructure: consistent behavior, dynamic configuration, and best-in-class observability, among others. Envoy handles every network hop in the data center. From the network edge, into the service mesh, even when egressing the <a href="https://aws.amazon.com/vpc/">VPC</a>, Envoy takes care of all the network traffic.</p><p>Envoy has done a great deal to help us achieve high reliability server-side: having a universal network primitive that is performant, reliable, configurable, and extensible has made the network largely transparent to server engineers. And importantly, Envoy’s best in class observability has made it increasingly easy to debug issues when they arise.</p><p>The realization that brought us to Envoy Mobile was that solving these problems in the <a href="https://eng.lyft.com/announcing-envoy-mobile-5c2067d9ade0">data center was not enough</a>, and over the last 6 months we have worked toward a v0.2 release where we could start to reap the benefits of a <strong>truly universal network primitive.</strong></p><h3>What is in v0.2?</h3><p>From our v0.2 announcement:</p><blockquote>Envoy Mobile v0.2 is a fundamental shift in how mobile clients use Envoy. Envoy Mobile now provides native Swift/Kotlin APIs that call through to Envoy directly (rather than using Envoy as a proxy), which apps use to create and interact with network streams.</blockquote><blockquote>This release includes a variety of new functionality:</blockquote><blockquote>1.HTTP request and streaming support.</blockquote><blockquote>2.gRPC streaming support through a built-in codec.</blockquote><blockquote>3.Automatic retries using Envoy’s retry policies.</blockquote><blockquote>4.Programmatic, typed configuration for launching the Envoy network library.</blockquote><h3>Library Internals</h3><p>Let’s see how the library was designed from the ground-up to achieve the functionality described above. This section will discuss:</p><ol><li>The build system and how it relates to the overarching organization of the library.</li><li>The lifetime of a request through the Envoy Mobile Engine and how we leverage existing Envoy constructs to ensure networking performance, reliability, and DRY code.</li></ol><p>Hopefully this deep dive is not only informative and interesting, but also entices you, the reader, to jump on board and start exploring the library!</p><h4>10,000 Foot View</h4><p>There are two main organizational dimensions in the Envoy Mobile project: API layers, and threading contexts. This section will describe both of them.</p><p><strong>API Layers</strong></p><p>At a high level, Envoy Mobile is a project in three parts:</p><ol><li><strong>Platform code: </strong>all the code that is written for either Android/JVM (in Java and Kotlin) or iOS (Objective-C and Swift). A fundamental goal of the library is cross-platform consistency. Therefore, the code in this layer is largely identical between both platforms.</li><li><strong>Bridging code:</strong> common C types that allow us to bridge from the platform specific constructs down to the C++ codebase. Note that this layer can also one day enable us to write bindings for other languages like Python, Rust, etc. (hint hint wink wink).</li><li><strong>Native code:</strong> written in C++ and interfaces directly with the rest of the Envoy codebase.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*VP6glDsttjCT4yLv" /><figcaption>the three layers of Envoy Mobile</figcaption></figure><p>This layered architecture is closely tied with how we build the library. Envoy itself is built with <a href="https://bazel.build/">Bazel</a>, which already has good tooling for multi-platform/multi-language projects, making it an excellent fit for building Envoy Mobile. Getting this set up was not trivial, and much of the initial effort of the project was put towards successfully compiling for each of the required languages and platforms. After completing the initial setup, things have worked reasonably well, most of the time.</p><p>The diagram below shows how the Bazel targets map over from the tiered architecture discussed in the previous section:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*MPwmofTdPF36i7wc" /><figcaption>high-level bazel targets are closely tied with how the library is architected</figcaption></figure><p>On the left, in red, we have platform-specific targets for iOS and Android. In the middle, in blue, are the targets for the bridging code. And lastly on the right, in green, is the native C++ code (both the core of the library, and Envoy itself, as a dependency). This gives us an overview of one fundamental dimension of the project: how we organized the library and thought about its API surface.</p><p><strong>Threading Contexts</strong></p><p>The other foundational concern was how we took something that was meant to be run as a multi-threaded process and ran it in a single threaded context within a sandboxed mobile application. In other words, running Envoy as an Engine, rather than a process. This dimension gave us the threading context in which the library had to be divided:</p><ol><li>The application threads that interact with the Engine and issue network calls.</li><li>The main Envoy thread which runs the Engine.</li><li>The callback threads where the Engine surfaces callbacks when responses are issued (whether from over the network or generated by the Engine).</li></ol><p>If we layer these threading concerns on top of the API layers of the library, we get a handy-dandy matrix that allows us to explain the lifetime of a request and the library components that make it happen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*EOdRlIhnewO6EZ08" /><figcaption>conceptual matrix of the Envoy Mobile library</figcaption></figure><h4>Library Lifecycle</h4><p>Using the mental model described above, we can explore the lifecycle of network I/O in Envoy Mobile.</p><p>Envoy Mobile exposes a top level Client interface <a href="https://envoy-mobile.github.io/docs/envoy-mobile/latest/api/starting_envoy.html">(iOS/Android</a>) that allows the application to start the Envoy Engine and provide it with a configuration. Although this Client is held in the application thread, the Engine is run in a separate native C++ thread — the Envoy main thread.</p><p>It is worth noting that Envoy itself contains mostly single-threaded code. When Envoy is running as a server, its main thread is responsible primarily for lifecycle tasks and bookkeeping. When a listener receives network events on a socket, its tasks are handled in worker threads. If a worker needs to interact with the main thread, it uses an <a href="https://github.com/envoyproxy/envoy/blob/master/include/envoy/event/dispatcher.h">event dispatcher interface</a> largely built on top of a <a href="https://libevent.org/">libevent</a> implementation (more information on Envoy’s threading architecture can be found in this <a href="https://blog.envoyproxy.io/envoy-threading-model-a8d44b922310">blog post</a>). Lastly, if a worker thread needs to issue network I/O off-band, it does so via an AsyncClient <a href="https://github.com/envoyproxy/envoy/blob/master/include/envoy/http/async_client.h">(code here)</a>.</p><p>In Envoy Mobile, we leveraged these existing Envoy constructs (cross-threading dispatch, and the AsyncClient). By hooking the Engine into the Envoy’s main thread event dispatcher and AsyncClients running in the context of the main thread. The result of this approach is that all the work is dispatched from the application threads to the Engine’s main thread and out to the network via existing mechanisms in Envoy.</p><p><strong>This means that we are harnessing Envoy Mobile into the battle-tested and hardened code paths of Envoy itself.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*nJHy9d15UeaQ5nQi" /><figcaption>the Envoy Mobile engine leverages Envoy constructs.</figcaption></figure><p>Like Envoy, Envoy Mobile considers streaming as a first class construct and is designed to work seamlessly with persistent streams while providing convenient traditional APIs. This forward-thinking approach ensures flexibility within the library and a path to unlocking new streaming protocols like QUIC in the future. This is largely evident due to the fact that we leveraged Envoy’s AsyncClient, but also by the streaming-based API exposed in Envoy Mobile’s bridge layer <a href="https://github.com/lyft/envoy-mobile/blob/master/library/common/main_interface.h">here</a>.</p><p>When the application creates and dispatches a request via Platform level APIs, Envoy Mobile transforms that request into a new HttpStream that lives in the Bridge layer. Before the Engine can pass handling of those API calls down to Envoy’s main thread (and thus to C++ memory constructs), we have to safely manage the ownership and lifecycle of memory passed by the application down to memory that will be handled by Envoy.</p><p>This was another case where Envoy Mobile was able to leverage pre-existing functionality in Envoy. Envoy has an elegant <a href="https://github.com/envoyproxy/envoy/blob/master/include/envoy/buffer/buffer.h">buffer abstraction</a>. Buffers are composed of buffer fragments that have callbacks that indicate when a buffer has been drained and the underlying memory is no longer needed. Perfect! This allowed us to directly tie platform memory management schemes to the lifecycle of memory usage in core Envoy code without any special bookkeeping — all in a platform-agnostic fashion.</p><p>To illustrate this example we can take a look at passing a Java ByteBuffer through Envoy Mobile. The ByteBuffer is converted to envoy_data in the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e9f49780dd79a10118f2e832e4a321a/href">https://medium.com/media/5e9f49780dd79a10118f2e832e4a321a/href</a></iframe><p>Importantly, note that there is no copying being done; envoy_data is wrapping the memory of the ByteBuffer directly. Additionally, it attaches a static release function (which deletes the global ref captured here), and the Java object as the type-erased context.</p><p>The envoy_data is then given to Envoy as an unowned Buffer fragment which, as described above, gets released when Envoy is done with the wrapping Buffer. The effect that this creates is that Envoy Mobile avoids unnecessary buffer copies even when passing memory blocks across threading and API boundaries — all without complicated bookkeeping.</p><p>Once the memory barrier is bridged and Platform-specific constructs are transformed into Envoy constructs (e.g from <a href="https://github.com/lyft/envoy-mobile/blob/4a19e375597063357909fbfb110764a7f7eaa794/library/common/types/c_types.h#L93">envoy_headers</a> in the Bridge layer to <a href="https://github.com/envoyproxy/envoy/blob/caf3896a7b4b4acdb1519ef02ec27d36e01f0f43/include/envoy/http/header_map.h#L366">Http::HeaderMap</a>in Envoy’s codebase), Envoy Mobile uses the event dispatcher to inject HTTP events into the AsyncClient. This integration is an instance where <a href="https://github.com/envoyproxy/envoy/pull/7752">some</a> <a href="https://github.com/envoyproxy/envoy/pull/8467">work</a> was done in upstream Envoy to fully enable this solution. We envision this type of collaboration to continue to flourish out of the partnership between Envoy and Envoy Mobile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*pNL7EBC0_Id-WfEn" /></figure><p>This gives us a fully functional solution in the outbound direction, where the application issues network I/O via Envoy Mobile.</p><p>Once the request is sent to the network and a response is received, Envoy Mobile needs to traverse in the inbound direction to surface the response back to the Platform layer. Envoy’s AsyncClient fires an array of <a href="https://github.com/envoyproxy/envoy/blob/80fa3f62f139b81b45d16e34fcedc2e28c7a2317/include/envoy/http/async_client.h#L57">callbacks</a> that were easily leveraged in Envoy Mobile’s codebase — another instance where Envoy Mobile’s deliberate design allowed us to utilize existing mechanisms in the Envoy codebase.</p><p>To prevent arbitrary user-provided Platform code from running and potentially blocking Envoy’s main thread, Envoy Mobile uses Platform-specific dispatching mechanisms (Grand Central Dispatch on iOS and Executors on Android) to fire callbacks on application threads using Platform-specific lambdas. This presented another interesting challenge: C function pointers (remember the Bridge layer is written in C) have no facility to capture state as true lambdas do. To facilitate mapping to Platform-specific callback abstractions, Envoy Mobile captures Platform-specific context in a type-erased manner. This allows Envoy to hold that context in a way that is memory-agnostic of its contents. Upon dispatch, that context is used to reconstitute the high-level Platform lambdas supported by the API, thus allowing Platform-rich handling of HTTP callbacks.</p><p>For instance, when iOS builds its envoy_http_callbacks, it assigns static callback functions that are capable of reconstituting the type-erased context and calling the Platform-given callbacks on a Platform dispatch queue. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11ef6efd36c8539273df71f3ec09d3e6/href">https://medium.com/media/11ef6efd36c8539273df71f3ec09d3e6/href</a></iframe><p>Note that this static function reconstitutes the void* context into a defined type known to the Objective-C code. The code is then able to get the Platform-specific EnvoyHTTPCallbacks object which has the user-provided dispatch queue, and the user-provided block to execute.</p><p>Lastly, we made a deliberate design decision in the library to avoid synchronization between the outbound and inbound directions (with the exception of stream cancellation state, which is checked atomically before callbacks dispatch to the application). All the management of the request and response state is delegated to the Engine, and Envoy Mobile enforces contracts in its internal APIs to keep these paths independent. This results in a dramatically simpler implementation in the library itself as well as in external code consuming the library.</p><p>Just like that, we have made a full trip around the lifecycle of HTTP traffic in the Envoy Mobile library:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*Lsi_FyE-D_Oprq85" /></figure><h3>The days ahead!</h3><p>As you can see in this blog post, Envoy Mobile is built using deep integration with the Envoy codebase, and leverages a lot of the technologies built into Envoy. Although Envoy Mobile already takes advantage of Envoy’s AsyncClient, this is just the beginning.</p><p>One of Envoy’s most powerful features is the concept of L7 filters. These filters are written to operate on HTTP-level messages without knowledge of the underlying protocol version. This feature has allowed complex deployments server-side, enabling functionality like health checking, rate limiting, or even fronting storage primitives like DynamoDB.</p><p>Since this project’s onset, we have been working toward solutions that open the doors for doing similarly complex operations on mobile clients agnostic of the architecture — solving problems like deferred requests, OAuth, and compression in one place across both mobile platforms. We believe Envoy’s L7 filter system is the best place to accomplish this.</p><p>One of the <a href="https://github.com/lyft/envoy-mobile/issues/543">issues</a> we opened in our fully public <a href="https://github.com/lyft/envoy-mobile/issues?utf8=%E2%9C%93&amp;q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+milestone%3A%22v0.3+%5C%22Secondi%5C%22%22+">v0.3 roadmap</a> was to work on Envoy Mobile’s filter chain support. In order to extend Envoy Mobile to have access to L7 filters, we needed to replace the Async Client-based direct API for one that harnesses Envoy’s <a href="https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/http/http_connection_management">HTTP connection manager.</a> This is exactly what we did in late December by exposing an Envoy API listener, and leveraging that in Envoy Mobile. Excitingly, with those two PRs we were able to fully test Envoy’s L7 filters in Envoy Mobile, starting with the <a href="https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/dynamic_forward_proxy_filter">dynamic proxy filter</a> which gives our mobile APIs even more flexibility as Envoy Mobile does not need to resolve DNS addresses a priori. This is just a taste of the power that we will be unlocking with the next version of Envoy Mobile!</p><h3>Other Resources</h3><p>This blog post dove deep into the internals of Envoy Mobile v0.2. It is our goal to develop Envoy Mobile out in the open and to distribute a rich set of materials which other parties in the industry can start leveraging, building upon, and collaborating on.</p><p>Here are a few other resources that compliment this post:</p><ol><li>If you prefer video: a lot of the content in this blog post was shared in two talks Mike Schore and I gave at <a href="https://www.youtube.com/watch?v=3ghO2K1Pd2k&amp;list=PLj6h78yzYM2MF1Ti3Mrfa9P0IlavyZYWt">EnvoyCon</a> and <a href="https://www.youtube.com/watch?v=NYb_nVWkP-I">KubeCon</a> NA 2019. If watching us explain the material is easier than reading about it, feel free to head on over!</li><li>This blog post compliments Michael’s <a href="https://eng.lyft.com/lyfts-journey-through-mobile-networking-d8e13c938166">blog post</a> about Lyft’s mobile networking journey very well. In his blog post he takes us through a brief history of API design at Lyft, and how we have evolved mobile APIs over the last few years. In other words, how we focused on the “what” that we transmit over our APIs, and how that culminated in Envoy Mobile: an opportunity to focus on “how” we transmit over our APIs.</li><li>The Envoy Mobile <a href="https://github.com/lyft/envoy-mobile">repo</a>, where we host our open source <a href="https://github.com/lyft/envoy-mobile/issues?q=is%3Aopen+is%3Aissue+milestone%3A%22v0.3+%5C%22Secondi%5C%22%22">roadmap</a>. We do this to encourage you to actively participate in this project!</li></ol><p>Stay tuned, we have a lot more content coming over the next few months, from how we are able to observe the network using Envoy Mobile metrics, to a deeper dive into the filter chain integration teased above!</p><p><em>If you’re interested in joining the team at Lyft, we’re hiring! Feel free to check out our </em><a href="https://www.lyft.com/careers"><em>careers page</em></a><em> for more info.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ed262cfdf93" width="1" height="1" alt=""><hr><p><a href="https://eng.lyft.com/envoy-mobile-v0-2-deep-dive-7ed262cfdf93">Envoy Mobile v0.2 deep dive</a> was originally published in <a href="https://eng.lyft.com/">Lyft Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Announcing Ratelimit]]></title>
            <link>https://eng.lyft.com/announcing-ratelimit-c2e8f3182555?source=rss-8e5e2bb06aab------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2e8f3182555</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[infrastructure]]></category>
            <dc:creator><![CDATA[Jose Nino]]></dc:creator>
            <pubDate>Wed, 08 Feb 2017 19:42:32 GMT</pubDate>
            <atom:updated>2018-02-09T22:26:54.082Z</atom:updated>
            <content:encoded><![CDATA[<h3>Announcing <a href="https://github.com/lyft/ratelimit">Ratelimit</a> : Go/gRPC service for generic rate limiting</h3><p>Today we are excited to open source Ratelimit, a Go/gRPC service designed to enable generic rate limit scenarios from different types of applications. For example, per IP rate limiting, or rate limiting the number of connections per second made to a database. Applications request rate limit decisions based on a domain and a set of descriptors. The Ratelimit service takes the request, matches it against the loaded configuration, checks against a Redis cache (although the in memory store can be easily swapped), and returns a decision to the caller.</p><p>Ratelimit is in production use at Lyft, and handles tens of thousands of rate limit requests per second. It is a reference implementation of the rate limit <a href="https://www.envoyproxy.io/docs/envoy/latest/configuration/rate_limit.html#grpc-service-idl">API</a> that <a href="https://eng.lyft.com/announcing-envoy-c-l7-proxy-and-communication-bus-92520b6c8191#.u3cb1mxat">Envoy</a>, our proxy and communications bus, uses. We use Ratelimit in both our edge proxies, and our internal service mesh to rate limit requests.</p><h4><strong>API</strong></h4><p>The Ratelimit service conforms to the Ratelimit protobuf defined <a href="https://github.com/lyft/ratelimit/blob/master/proto/ratelimit/ratelimit.proto">here</a>. It receives RateLimitRequests which are composed of a domain and a set of descriptors. A domain is a unique string that enables configuration to be application specific, without overlap. descriptors are a list of hierarchical entries that are used to determine the final key to lookup in the Redis cache. Combining these two concepts, Ratelimit provides a flexible framework for rate limiting a wide variety of scenarios. For example, to set a rate limit on connections per second to your datastore, you could define a configuration like this:</p><pre>domain: mongo_cps<br>descriptors:<br> — key: database<br>   value: users<br>   rate_limit:<br>     unit: second<br>     requests_per_unit: 10</pre><p>Then send requests to the Ratelimit service like:</p><pre>RateLimitRequest:<br> domain: mongo_cps<br> descriptors: (“database”, “users”)</pre><p>To check if your service should be allowed to create a new connection to the database.</p><p>You can find more requests examples and explanations on how they work <a href="https://github.com/lyft/ratelimit/blob/ff2e81d8f3601575662cfc7795903d50a833ab55/proto/ratelimit/ratelimit.proto#L31-L51">here</a> and <a href="https://github.com/lyft/ratelimit/tree/master#examples">here</a>.</p><h4><strong>Configuration</strong></h4><p>Ratelimit loads YAML configuration files from disk. Ratelimit uses a library we recently open sourced called <a href="https://github.com/lyft/goruntime">runtime</a> to load these files. The configuration file reflects the Ratelimit API described above. It contains a domain, descriptors for that domain, and rate_limit. Currently the service supports per second, minute, hour, and day limits. For more information on how to setup the service, and configure it please read the <a href="https://github.com/lyft/ratelimit#configuration">docs</a>.</p><h4><strong>Envoy ratelimit filters</strong></h4><p>Envoy integrates with the Ratelimit service via two <a href="https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/global_rate_limiting.html#global-rate-limiting">filters</a>:</p><p>1. <strong>Network Level Filter</strong>: Envoy calls the Ratelimit service for every new connection on the listener where the filter is installed. This way you can rate limit the connections per second that transit the listener.</p><p>2. <strong>HTTP Level Filter</strong>: Envoy calls the Ratelimit service for every new request on the listener where the filter is installed and the route table specifies that the Ratelimit service should be called. A lot of <a href="https://github.com/lyft/envoy/issues/179">work</a> is going into expanding the capabilities of the HTTP filter.</p><p>Like <a href="https://github.com/lyft/discovery">discovery</a>, Ratelimit expands the Envoy ecosystem and enhances the functionality that Envoy can accomplish in your infrastructure. We are excited to be releasing this additional piece of the Envoy ecosystem and can’t wait to hear what you think about it and do with it.</p><blockquote>Interested in open source work and having a big impact? Lyft is hiring! Drop me a note on <a href="https://twitter.com/junr03">Twitter</a> or at jnino@lyft.com</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2e8f3182555" width="1" height="1" alt=""><hr><p><a href="https://eng.lyft.com/announcing-ratelimit-c2e8f3182555">Announcing Ratelimit</a> was originally published in <a href="https://eng.lyft.com/">Lyft Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>