<?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 Mengxi Lu on Medium]]></title>
        <description><![CDATA[Stories by Mengxi Lu on Medium]]></description>
        <link>https://medium.com/@mengxilu?source=rss-77b47fbe9ea5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LlZWtA1AqgcBYKw72c78RA.jpeg</url>
            <title>Stories by Mengxi Lu on Medium</title>
            <link>https://medium.com/@mengxilu?source=rss-77b47fbe9ea5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 01:52:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mengxilu/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[Configure Hystrix in Clojure]]></title>
            <link>https://medium.com/@mengxilu/configure-hystrix-in-clojure-870238df9b9b?source=rss-77b47fbe9ea5------2</link>
            <guid isPermaLink="false">https://medium.com/p/870238df9b9b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[hystrix]]></category>
            <category><![CDATA[clojure]]></category>
            <dc:creator><![CDATA[Mengxi Lu]]></dc:creator>
            <pubDate>Mon, 13 Feb 2017 17:45:42 GMT</pubDate>
            <atom:updated>2017-02-13T17:45:42.655Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Originally posted at </em><a href="http://lumengxi.com/2017/02/12/hystrix-config-in-clojure.html"><em>lumengxi.com</em></a></p><p>Hystrix is an amazing tool to help stop cascading failure and enable resilience in complex distributed systems. It is pretty straightforward to integrate it with your Clojure web applications, and works well out-of-the-box. However, if you want to modify Hystrix’s default behaviors, this tutorial will show you a few different ways to do so.</p><p>In fact, Hystrix leverages its <a href="https://github.com/Netflix/Hystrix/wiki/Plugins#properties-strategy">plugin</a> system which gives you full control over how properties are defined for the system. By default it uses <a href="https://github.com/Netflix/archaius">Archaius</a> as the default implementation, so the methods mentioned below would apply to any applications using the same for configuration management.</p><p>The full example code can be found in <a href="https://github.com/lumengxi/try-hystrix">this</a> repo.</p><h3>config.properties File</h3><p>This is my preferred way to configure Hystrix because it is more explicit. The default location for config.properties file is under resources, for example, if you create resources/config.properties with the following content:</p><pre># Hystrix global config<br>hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=5000<br>hystrix.command.default.circuitBreaker.sleepWindowInMilliseconds=6000</pre><pre># Hystrix config per group / command key<br>hystrix.command.helloWorld.execution.isolation.thread.timeoutInMilliseconds=8000</pre><p>Once you start your application, you might see some log lines like this:</p><pre>2017-02-12 16:26:59 INFO  URLConfigurationSource:127 - URLs to be used as dynamic configuration source: [file:/.../resources/config.properties]<br>2017-02-12 16:26:59 INFO  DynamicPropertyFactory:266 - DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@77d2e85</pre><h3>System Properties</h3><p>Another way to do this is to manipulate System Properties directly. For example, to setup global default timeout:</p><pre>(System/setProperty &quot;hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds&quot; &quot;2000&quot;)</pre><p>or a command key specific setting:</p><pre>(System/setProperty &quot;hystrix.command.helloWorld.execution.isolation.thread.timeoutInMilliseconds&quot; &quot;2000&quot;)</pre><h3>ConfigurationManager Interface</h3><p>You can also config Hystrix through the <a href="https://github.com/Netflix/archaius/wiki/Users-Guide#using-configurationmanager">ConfigurationManager</a>, if you prefer to programmatically generating those configs within the application. Here is an example of how it could work:</p><pre>(ns try-hystrix<br>  (:import (com.netflix.config ConfigurationManager)))</pre><pre>(defn set-hystrix-config!<br>  [cmd-key k v]<br>  (let [key (format &quot;hystrix.command.%s.%s&quot; cmd-key k)]<br>    (.setProperty (ConfigurationManager/getConfigInstance) key v)))</pre><pre>; Example usage<br>(set-hystrix-config! &quot;helloWorld&quot; &quot;circuitBreaker.requestVolumeThreshold&quot; 10)<br>(set-hystrix-config! &quot;helloWorld&quot; &quot;circuitBreaker.errorThresholdPercentage&quot; 60)</pre><p>And just the same as using system properties, these need to run at the entry point of the application (the -main method as an example).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=870238df9b9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Random thoughts on working with Go]]></title>
            <link>https://medium.com/@mengxilu/random-thoughts-on-working-with-go-6c481988f4ef?source=rss-77b47fbe9ea5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c481988f4ef</guid>
            <category><![CDATA[clojure]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Mengxi Lu]]></dc:creator>
            <pubDate>Tue, 18 Oct 2016 08:09:12 GMT</pubDate>
            <atom:updated>2016-10-18T08:09:12.999Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Originally posted on </em><a href="http://lumengxi.com/2016/10/16/thoughts-on-go.html"><em>http://lumengxi.com/2016/10/16/thoughts-on-go.html</em></a></p><p>Last week I had a chat with a friend, who has been pretty upset lately because he was having a hard time to introduce Rust to his company, a hard tech startup and a Go shop. He couldn’t understand why his co-workers would be willing to settle on, quotes from him, “such an ugly tool”.</p><p>Fair enough. Admittedly I was never a big fan of Go either. I think the <em>GOPATH</em> is a mess and the dependency management is gnarly; I like the concept of slice, but the operations are pretty weak and almost broken; the variable shadowing is funny and nil interface is somewhat <a href="https://groups.google.com/forum/#!topic/golang-nuts/wnH302gBa4I/discussion">confusing</a>; I don’t really have problem with its error handling like others do, but it does make the program rather verbose… and the list can go on and on.</p><p>There might be better alternatives nowadays. I am lucky enough to be able to use Clojure at work. To me, I think Clojure is both beautiful and productive, arguably the best tool for manipulating data, or designing a DSL. It does not really make sense to even try to compare Go with Clojure, these two are just fundamentally so different. For example, Clojure has first-class support for higher order sequence functions, like <em>map</em>, <em>reduce</em> and <em>filter</em>, which are absolutely essential for working with data.</p><pre>(map odd? [1 2 3])     ;;=&gt; (true false true)<br>(filter odd? [1 2 3])  ;;=&gt; (1 3)<br>(reduce + [1 2 3 4 5]) ;;=&gt; 15</pre><p>It is not that easy, but not too terrible either, to have something similar in Go. Here is an example:</p><pre>type testInt func(int) bool</pre><pre>func isOdd(x int) bool {<br>   if x%2 == 0 {<br>       return false<br>   }<br>   return true<br>}</pre><pre>func filter(xs []int, f testInt) []int {<br>   var res []int<br>   for _, val := range xs {<br>       if f(val) {<br>           res = append(res, val)<br>       }<br>   }<br>   return res<br>}</pre><p>Now you can use <em>filter</em> like this:</p><pre>xs := []int{1, 2, 3, 4, 5}<br>fmt.Println(filter(xs, isOdd))</pre><p>Of course, this is a significantly simplified example, it could get cumbersome soon due to the lack of generics in Go (although I never found it being a huge problem of implementing a handful of <em>sort.Interface</em>, but I have not yet used Go in large applications either).</p><p>Once you get used to Clojure, everything else just become awkward and odd. However, will I choose Clojure for large-scale web applications? Debatable, probably not. Will I still keep using it in my own projects? Sure. Because despite all the complaints, end of the day I can always count on it to “get the job done”. As a developer writing business software now, I have learned to respect that.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c481988f4ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Infrastructure at Oyster]]></title>
            <link>https://medium.com/@mengxilu/data-infrastructure-at-oyster-752c4ddda81c?source=rss-77b47fbe9ea5------2</link>
            <guid isPermaLink="false">https://medium.com/p/752c4ddda81c</guid>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[mesos]]></category>
            <dc:creator><![CDATA[Mengxi Lu]]></dc:creator>
            <pubDate>Sat, 13 Jun 2015 00:00:00 GMT</pubDate>
            <atom:updated>2016-01-02T04:53:30.506Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This post was originally posted on </em><a href="http://oyster.engineering/"><em>Oyster Engineering blog</em></a><em>, and it summarized 80% of what I have done since I joined Oyster on September 2014. The rest 20% was fixing bugs that were created during the 80%.</em></p><p>Our mission at Oyster is to connect readers with books they’ll love. We do this by combining <a href="http://blog.oysterbooks.com/post/107983760205/macmillan-joins-oyster-1-million-books">over 1 million books</a> with great discovery features via social, editorial, and algorithmic recommendations to make it easy to browse and discover a great book.</p><p>Oyster has its own unique challenges with data processing. For example, we have user behavioral data coming from online and offline sessions, and book reading progress is hard to represent with immutable data structure. We also have multiple teams that rely on data analytics in their own ways. The product team, for instance, relies on event data to understand how readers interact with Oyster apps, while marketing needs data to track user growth and conversions.</p><p>In this blog post, we will share our approach to building a scalable and accessible data system to support these diverse needs.</p><p><strong>The Backstory</strong></p><p>The first version of the Oyster data platform was built on <a href="http://aws.amazon.com/elasticmapreduce/">Amazon Elastic MapReduce</a>. We ran our offline batch processing jobs using <a href="https://github.com/twitter/scalding">Scalding</a>, and there were also multiple analytics jobs baked into the Django backend and managed by <a href="http://www.celeryproject.org/">Celery</a>.</p><p>This worked fine in the early days, because it’s very easy to scale up/down and monitor jobs in progress through the AWS web console. However, EMR also had multiple disadvantages:</p><ul><li>It gets expensive quickly as your data grows.</li><li>Performance is unpredictable.</li><li>Limited customizability. If your application is consuming data sources other than S3, or you need to use an unsupported Hadoop add-on, you end up spending a lot of time creating workarounds.</li></ul><p><strong>The New Stack</strong></p><p>Oyster has grown rapidly since launching in 2012, and we started to hit a lot of limits with our original system. To support our growth, we migrated to a new data infrastructure with the following design decisions in mind:</p><ul><li><a href="http://www.reactivemanifesto.org/">Reactive</a></li><li><a href="http://en.wikipedia.org/wiki/KISS_principle">KISS</a>. We want our data pipeline to start small and simple, but be able to scale over time.</li><li>Easy access. We introduced business intelligence tools to enable non-developers to answer their own questions about our data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6pIJK_SVUa4BzYxVrS4S5w.jpeg" /></figure><p><strong>The Datacenter Kernel: Mesos</strong></p><p><a href="http://mesos.apache.org/">Apache Mesos</a> is a fault-tolerant cluster manager and the cornerstone of our elastic compute infrastructure. While Hadoop presents challenges in parallel scale-out, Mesos provides efficient resource isolation and sharing across distributed applications or frameworks. It bridges the gap between hardware and applications (or frameworks, in the context of Mesos), and solves the issue of elasticity and virtualization for large-scale deployments.</p><p>We have used Mesos in production for several months now and are very satisfied with its performance. We are able to dynamically provision and add new workers to the pool without changing any cluster configurations, and our developers have greater control over deployment, without worrying about resource allocation.</p><p><strong>ETL Jobs as Data Applications</strong></p><p>We love <a href="http://spark.apache.org/">Spark</a> here at Oyster because it offers a simple programming<a href="http://spark.apache.org/docs/0.8.1/api/core/org/apache/spark/rdd/RDD.html">abstraction</a> that provides powerful parallel computing and persistence capabilities. It can handle batch, interactive, and real-time data processing (<a href="https://spark.apache.org/streaming/">Spark Streaming</a>) in one framework. Spark also comes with MLlib, a library of efficient implementations of many popular algorithms directly built using Spark.</p><p>Spark/MLlib is our primary data processing engine. We use it for book recommendations, <a href="http://blog.oysterbooks.com/post/111273877195/the-new-home-for-discovering-books-on-oyster">personalizing the Home experience</a>, and many other ETL jobs. Thanks to Mesos, we don’t need to maintain a dedicated Spark master/slave cluster. Instead, we encapsulate each ETL job into isolated Spark applications and run them on the Mesos cluster alongside other frameworks.</p><p>To achieve this, we package all dependencies of an ETL job into an uber jar using the sbt-assembly <a href="https://github.com/sbt/sbt-assembly">plugin</a>, ship it to all Mesos workers, and then execute the ETL jobs just like regular Java applications. This pattern enables us to rapidly develop and deploy data applications. For datasets that need further downstream processing by other services, we serialize the output using <a href="https://avro.apache.org/">Avro</a> and use <a href="https://www.rabbitmq.com/">RabbitMQ</a> to notify other systems that the data are ready to go (we will provide a detailed look into this notification system in the second part of the series).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wAwljafuIt0wF9xKOPnz8A.jpeg" /></figure><p>For ETL job scheduling, we use <a href="https://mesos.github.io/chronos/">Chronos</a>, a distributed and fault-tolerant task scheduler which also runs on top of Mesos. Chronos uses Mesos’ primitives for storing state and distributing work, and it provides a RESTful API over HTTP, meaning you can quickly delete all tasks for a job if it gets stuck.</p><p><strong>Business Intelligence</strong></p><p>Every day we collect and aggregate hundreds of metrics to understand our performance and how readers engage with Oyster. <a href="http://www.looker.com/">Looker</a> helps us look across these data in a more meaningful way. We connect it to<a href="http://aws.amazon.com/redshift/">Redshift</a>, our primary analytics data store, and use its expressive model language to create views for business operations, user engagement, growth/retention, and more. Different teams leverage these data and visualizations to make more informed product decisions.</p><p>At Oyster we are all passionate about data. If you have great ideas on building data infrastructure in a fast changing environment, come <a href="https://www.oysterbooks.com/jobs">join us</a>!</p><p><em>Originally published at </em><a href="http://lumengxi.com/home/2015/6/13/data-infrastructure-at-oyster"><em>lumengxi.com</em></a><em> on June 13, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=752c4ddda81c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>