<?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 Billy Mobile on Medium]]></title>
        <description><![CDATA[Stories by Billy Mobile on Medium]]></description>
        <link>https://medium.com/@billyblog?source=rss-2585b057823a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IMGzI16KmxGlOku6UoTmtA.png</url>
            <title>Stories by Billy Mobile on Medium</title>
            <link>https://medium.com/@billyblog?source=rss-2585b057823a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 16:58:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@billyblog/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[Integrating d3 with react — Memo]]></title>
            <link>https://medium.com/billyengineering/integrating-d3-with-react-memo-20e5999e2053?source=rss-2585b057823a------2</link>
            <guid isPermaLink="false">https://medium.com/p/20e5999e2053</guid>
            <category><![CDATA[charts]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[d3js]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Billy Mobile]]></dc:creator>
            <pubDate>Thu, 21 Dec 2017 11:56:33 GMT</pubDate>
            <atom:updated>2017-12-21T14:48:20.248Z</atom:updated>
            <content:encoded><![CDATA[<h3>Integrating d3 with react — Memo</h3><p>by <a href="https://medium.com/u/21d5a797b4b4">Samuel Lissner</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*j7SdwUuVIvp_r0mdZaGzOA.png" /></figure><p><em>In </em><a href="https://www.billymob.com/"><em>billy mobile</em></a><em>, we gave our front-ends a facelift with </em><a href="https://reactjs.org/"><em>react.js</em></a><em> and </em><a href="https://redux.js.org/"><em>redux</em></a><em>. One brand-new application requires a lot of charting. Initially, we made some progress with </em><a href="http://www.chartjs.org/docs/latest/"><em>Chart.js</em></a><em>. Relatively soon we discovered its inherent constraints using &lt;canvas&gt; for rendering elements in the browser, especially for tooltips that overflow the parent canvas container. We decided to move our graphs to </em><a href="https://d3js.org/"><em>d3.js</em></a><em>, although facing a challenge of integrating the library smoothly with our existing react architecture. As billy’s front-end team, we would like to share our experiences with everyone aiming to combine the two libraries.</em></p><h3>Summary</h3><p>This memo summarizes various paradigms on how to integrate d3.js with react.js. There is no clear single established way how to solve the integration problem. A first intuitive, but flawed approach is to use both libraries by rendering the DOM parallelly. However, this my lead to clashes between react and d3, managing that piece of mutable DOM. On the other side, the better practices established are:</p><ol><li>React for the DOM renders, d3 for the maths;</li><li>Use react-faux-dom library to integrate existing d3 code;</li><li>Don’t render DOM, use canvas.</li></ol><p>A good way seems to be paradigm 1. Elijah Meeks article uses exclusively react to render the DOM elements to avoid react/d3 DOM control clashes — d3 for the maths. However, many authors seem to opt for paradigm 2 (faux-dom). It would remain intact reacts full control over the (virtual) DOM while allowing for full usage of d3. It can be seen as an option when it is necessary to integrate already existing, fully implemented d3 code.</p><h3>Integrations</h3><h4><strong>Basic Tutorials</strong></h4><ul><li><a href="https://medium.com/@c_behrens/enter-update-exit-6cafc6014c36">https://medium.com/@c_behrens/enter-update-exit-6cafc6014c36</a> Fundamental article on d3, explains the underlying concepts very well. If you have no clue about d3, read this first.</li><li><a href="https://medium.com/@tibotiber/react-d3-js-balancing-performance-developer-experience-4da35f912484">https://medium.com/@tibotiber/react-d3-js-balancing-performance-developer-experience-4da35f912484</a> Debates paradigms 1, 2 and how to integrate react with d3. Favors paradigm 2 (faux-dom) over the others.</li><li><a href="https://mikewilliamson.wordpress.com/2016/06/03/d3-and-react-3-ways/">https://mikewilliamson.wordpress.com/2016/06/03/d3-and-react-3-ways/</a> Overview article on the paradigms 1, 2, 3.</li><li><a href="http://nicolashery.com/integrating-d3js-visualizations-in-a-react-app/">http://nicolashery.com/integrating-d3js-visualizations-in-a-react-app/</a> More introduction.</li></ul><h4><strong>Original approach (problematic):</strong> <em>Using both libraries parallelly for rendering the DOM</em></h4><p>Render a d3 container element with react, then let d3 do the rest of DOM manipulation on its own. By this you are stepping out of the react tree. But it leaves you with mutable DOM managed by d3. This can cause react to quit DOM elements because it takes full control of the DOM-virtual DOM trees. See the section on <a href="https://reactjs.org/docs/reconciliation.html">reconciliation</a> in react docs.</p><blockquote><strong><em>Note</em></strong><em>: You can’t easily render react components with d3 functions. </em>selection.html(&lt;MyComponent/&gt;)<em> won’t work.</em></blockquote><p>Given these fundamental problems, a variety of paradigms have been used in practice to avoid the situation of conflicting DOM management.</p><h4><strong>Paradigm 1:</strong> <em>React for the DOM, d3 for the maths</em></h4><p>Compiles DOM elements as react components, but with the help of d3 (mathematical) functions. Makes no use of d3 data bindings and selection.</p><ul><li><a href="https://medium.com/@Elijah_Meeks/interactive-applications-with-react-d3-f76f7b3ebc71">https://medium.com/@Elijah_Meeks/interactive-applications-with-react-d3-f76f7b3ebc71</a> Very good article that explains the fundamental problem of using d3 with react parallelly and presents paradigm 1 as acceptable work around to the problem.</li><li><a href="https://swizec.com/blog/using-d3js-transitions-in-react/swizec/6797">https://swizec.com/blog/using-d3js-transitions-in-react/swizec/6797</a> However, there may be problems with draggable objects and transitions. You can, however, implement react transformation libraries yourself. See for example: <a href="https://react-move.js.org/#/">https://react-move.js.org/#/</a></li><li><a href="http://www.adeveloperdiary.com/react-js/integrate-react-and-d3/">http://www.adeveloperdiary.com/react-js/integrate-react-and-d3/</a></li></ul><h4><strong>Paradigm 2</strong>: <em>Use Faux DOM for isolated d3 renderization</em></h4><p>Same basic problem as paradigm 2: Cannot use d3 to update DOM, use react instead. faux-dom library allows to create a fake DOM, to manipulate it with D3, and then to transform it into a React component. React will not directly manage that DOM.</p><ul><li><a href="https://github.com/Olical/react-faux-dom">https://github.com/Olical/react-faux-dom</a> (library): DOM like data structure to be mutated by d3 et al., then rendered to react elements.</li><li><a href="https://oli.me.uk/2015/09/09/d3-within-react-the-right-way/">https://oli.me.uk/2015/09/09/d3-within-react-the-right-way/</a> some approaches to realize this paradigm.</li><li><a href="https://blog.sicara.com/a-starting-point-on-using-d3-with-react-869fdf3dfaf">https://blog.sicara.com/a-starting-point-on-using-d3-with-react-869fdf3dfaf</a> React doesn’t expect another library to modify the DOM. Article explains which mistakes to avoid when using faux-dom.</li></ul><h4><strong>Paradigm 3</strong>: <em>Use canvas instead of DOM renders</em></h4><ul><li><a href="https://bl.ocks.org/mbostock/946ddf8a32b3b660ffd8">https://bl.ocks.org/mbostock/946ddf8a32b3b660ffd8</a> This is an d3 canvas chart that later can be implemented in react. (See again also <a href="https://mikewilliamson.wordpress.com/2016/06/03/d3-and-react-3-ways/">https://mikewilliamson.wordpress.com/2016/06/03/d3-and-react-3-ways/</a> ).</li></ul><h3>Code Examples</h3><p>Before reviewing the code examples, better make sure to read at least the chapters above on the flawed, original approach and paradigm 1.</p><h4>The problematic, original approach</h4><p>In the following example, you can clearly see that react’s lifecyle and <em>render() </em>methods, and the methods of the <em>d3-selection </em>(<em>enter()</em>, <em>update()</em>, <em>exit()</em>)<em> </em>package are mixed in order to manipulate the DOM. This can lead to the “diffing out” of the d3 managed DOM elements through react.js virtual-DOM/DOM reconciliation algorithm as mentioned above.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/417d2d8b340b2bb98ff6f45fc5fda389/href">https://medium.com/media/417d2d8b340b2bb98ff6f45fc5fda389/href</a></iframe><h4>Our solution: Paradigm 1</h4><p>In this example, we do not make use of <em>d3-selection </em>methods. Rendering and destruction of DOM elements lies exclusively in the domain of react.js. D3, no less important, provides its mathematical functions for scaling and data preprocessing. Please note that you may encounter problems while using d3 transformation and animation tools. Likely you have to implement your own transformation methodology with react.js. However there do exist react.js animation/transformation libraries, too, that could help you out.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/428054a938451522672e94927eec5122/href">https://medium.com/media/428054a938451522672e94927eec5122/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20e5999e2053" width="1" height="1" alt=""><hr><p><a href="https://medium.com/billyengineering/integrating-d3-with-react-memo-20e5999e2053">Integrating d3 with react — Memo</a> was originally published in <a href="https://medium.com/billyengineering">billyengineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Billy’s backbone]]></title>
            <link>https://medium.com/billyengineering/billys-backbone-how-a-close-partnership-with-our-hosting-provider-thrives-our-adnetwork-b007a32d538b?source=rss-2585b057823a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b007a32d538b</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[adtech]]></category>
            <category><![CDATA[data-center]]></category>
            <category><![CDATA[business-relationships]]></category>
            <category><![CDATA[hosting]]></category>
            <dc:creator><![CDATA[Billy Mobile]]></dc:creator>
            <pubDate>Thu, 23 Nov 2017 10:44:10 GMT</pubDate>
            <atom:updated>2017-11-23T10:56:04.084Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*-ORM_SLKftoJjOSnhgHLVw.jpeg" /></figure><h3>How a close partnership with our hosting provider thrives our adnetwork</h3><p>Success in the adtech industry is defined conventionally in terms of conversion rates, marketplace size and other key performance indicators of the business. However, talking about indicators alone is not enough. Less seen is the aspect of having an unstained delivery on the hardware side. And here, so the impression we have, it cannot be stressed enough how important it has been to build a close relationship between us and our hosting provider.</p><p>With <a href="https://www.leaseweb.com/">LeaseWeb</a> we have an extremely reliable hosting partner in the background. A resilient long-term relationship served both-sides well in times where rapid response was urgently required. As there is a plenitude of hosting providers, the key differentiator for us, thus, is not solely pricing, availability and robustness. These are minimum requirements many hosting companies must and do deliver. What makes the difference between an averagely good and an excellent provider is the ability to add a layer of extraordinary human capacity and mutuality to steer huge data and hosting projects through steady and especially unsteady waters.</p><p>Given our experience with LeaseWeb, these are our advices how to build a great relationship with your data center.</p><p>The first advice is: <strong>Evaluate the capacity of your partner to protect you</strong>. Every company’s infrastructure needs to be protected. So the trust in your data center’s installation are important, both for physical and virtual security, protection against networking attacks, and so on.</p><p>But regardless how well prepared a company is on the hardware side, it is inevitable that some system fails. Sure, redundancy is important and is the price worth one has to pay. In Billy for example we do run a preventive rack, firewall, switch and energy (racks and server) redundancy. This costs more than the double, but it is our life insurance. At least for the sysadmin team.</p><p>Yet, sometimes even redundant systems crash. Or a failure emerges that a redundant system is not designed for to intercept. In such more than stressful situation, the only means you have to avoid looming disaster is a good hands-on team in the data center. “Your team” in the data center can save the situation for you. You need to be able to trust the people in there. So the second point is: <strong>Build a great relationship to the people running the data center</strong>.</p><p>Although relationships are tested in rough moments, they are build over time. Not months, years. Because months are not sufficient. As Billy, we frequently visit our service provider in their headquarters in the Netherlands to keep up the personal relationship. Also: Send (or receive) some cookies and champagne for christmas. ;-)</p><p>Beyond that, <strong>pooling key staff running the project together is a huge advantage</strong>. In our case, we can rely on our account manager. For many years now, <a href="https://www.linkedin.com/in/walidchoughari/">Walid Choughari</a> is our personal contact person in Amsterdam. He is in frequent contact with our Sysadmin Team. With the help of Walid and his colleagues, we were able to solve all problems.</p><p>Finally, success is not only defined by overcoming problems. When the good times roll, <strong>you need to scale, and you need it fast</strong>. A great hosting provider allows you to add new services without painful delay. They are capable to add up services in the cloud, as bare metal or CDN. Remember, you are serving ads around the world.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b007a32d538b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/billyengineering/billys-backbone-how-a-close-partnership-with-our-hosting-provider-thrives-our-adnetwork-b007a32d538b">Billy’s backbone</a> was originally published in <a href="https://medium.com/billyengineering">billyengineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Feature: Integrating Kafka with Spark Streaming]]></title>
            <link>https://medium.com/billyengineering/feature-integrating-kafka-with-spark-streaming-47763f6bcf58?source=rss-2585b057823a------2</link>
            <guid isPermaLink="false">https://medium.com/p/47763f6bcf58</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[scala]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[apache-kafka]]></category>
            <dc:creator><![CDATA[Billy Mobile]]></dc:creator>
            <pubDate>Thu, 09 Nov 2017 11:24:06 GMT</pubDate>
            <atom:updated>2017-11-09T11:28:12.860Z</atom:updated>
            <content:encoded><![CDATA[<h4>Apache Spark Streaming + Kafka 0.10 (3/4)</h4><p>by <a href="https://medium.com/u/28f285c49703">Joan Viladrosa</a>, <a href="https://medium.com/u/21d5a797b4b4">Samuel Lissner</a>.</p><blockquote>This story is part of a series of articles related to the integration of Apache Spark Streaming and Apache Kafka. Feel free to check the other ones <a href="https://engineering.billymob.com/apache-spark-streaming-kafka-0-10-1f3c29a694cb">here</a>.</blockquote><h3>New Apache Spark Streaming 2.0 Kafka Integration</h3><p>But why you are probably reading this post (I expect you to read the whole series. Please, if you have scrolled until this part, go <a href="https://engineering.billymob.com/apache-spark-streaming-kafka-0-10-1f3c29a694cb">back</a> ;-)), is because you are interested in the new Kafka integration that comes with Apache Spark 2.0+. For retrocompatibility reasons, the previous integration is maintained, and you can still use it. It is actually the stable one, but come on, we love experimental features, don’t we?</p><p>So two different maven artifacts are available now: <em>spark-streaming-kafka-0–8</em> and <em>spark-streaming-kafka-0–10</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*XrJh_nnf_VEtSaicdPoeuw.png" /></figure><p>Sadly, the Python API has been dropped from the new one for now (surely there will be one when the API is no longer experimental). But if you are interested in the new amazing features that comes with Apache Kafka 0.10 (mostly security and encryption), this is your only way to go. Luckily, it’s very similar to the previous direct approach, so minor changes will be needed to your code (some examples later).</p><p>Instead of the simple API, we will be using the new Consumer API provided with Apache Kafka 0.9+. The new consumer pre-fetches messages into local buffers to improve performance. In order to make use of these buffers, it makes sense to keep the consumers cached and alive by loading them into executors. Spawning new consumers for each task, on the other hand, would be bad practice as it makes the buffers useless.</p><p>So the same consumers will be used again and again for each task. The new Consumer API allows to allocate more consciously the Spark executors while consuming data. This is where the new LocationStrategies kicks in. We can specify on the creation of the DStream, where we want our consumers to be placed. Three different options are provided to cover all use cases:</p><ul><li><em>PreferConsistent</em>. Distribute partitions evenly across all available executors</li><li><em>PreferBrokers</em>. If your Spark Cluster is on the same very nodes of your Kafka Cluster, this strategy will spawn consumers for each partition on the same node of the leader broker for that partition.</li><li><em>PreferFixed</em>. If you want to specify any other magical and awesome distribution of consumer among executors.</li></ul><p>Also the way we can specify to which topics and partitions to subscribe has improved, and we can actually change those on runtime without stopping the stream. The ConsumerStrategies are as follow:</p><ul><li><em>Subscribe</em>: To subscribe to a fixed collection of topics</li><li><em>SubscribePattern</em>: Use a regex to specify the topics of interest</li><li><em>Assign</em>: Specify a fixed collections of topics AND partitions</li><li>If <em>none</em> of the above fits you, ConsumerStrategy is a public class that you can extend and implement your own.</li></ul><p>But probably the main reason to use new Kafka 0.10 is the security, since the new Consumer API supports SSL connections between your executors and kafka brokers. But, take into consideration that this will only secure the connection between Spark and Kafka, you are still responsible for separately securing Spark inter-node communication and other output operations.</p><h3>New Integration Example code</h3><p>You can find the whole example with a maven project to just import it with your favourite IDE at: <a href="https://github.com/joanvr/spark-streaming-kafka-010-demo">https://github.com/joanvr/spark-streaming-kafka-010-demo</a></p><p>We will discuss this a bit further here.</p><p>First of all, we will need to create a Map with all the configurations of the stream. Obviously, you will need to provide the kafka brokers servers. Also the serializer of the key and the value of your messages (you can use the already implemented ones that come with the kafka client library for bytes, doubles, integers, longs and strings). If you want to use the offset commit API you will also need to specify the group.id, where to start the offsets the first time, and if you want to auto commit the offsets. More on this later when we will discuss the major semantic use cases.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1e9241df1b688d8586cd32f48f25f74/href">https://medium.com/media/b1e9241df1b688d8586cd32f48f25f74/href</a></iframe><p>Then we will need to specify to which topics we want to subscribe. The Subscribe Consumer Strategy takes an Array of topics, so we will create an array with a single string inside for the purpose of the demo.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16d141c7ab0c71db1cc8fe4aa1f5efc7/href">https://medium.com/media/16d141c7ab0c71db1cc8fe4aa1f5efc7/href</a></iframe><p>Finally we just need to create the Direct Stream using the helper on the KafkaUtils object package helper. Notice that we are using a PreferConsistent LocationStrategy here.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12eb9d689cb0900108eafc5c6c5e1515/href">https://medium.com/media/12eb9d689cb0900108eafc5c6c5e1515/href</a></iframe><p>Once you have a DStream, you can start using all the well known operations you can do with Spark. For this demo, we implemented a typical WordCount, and finally store it as Text Files.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37848ef40c4b74cd48e5efa640f6380b/href">https://medium.com/media/37848ef40c4b74cd48e5efa640f6380b/href</a></iframe><p>At this point we have all setted up, so we just need to start our streaming context and see the magic happen. Hopefully, if everything works fine, soon you will start seeing files written into the output directory. Also you can connect to Spark UI on the 4040 port of the host you are running the demo.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a388f14cebea493764cf0a59cf226b2/href">https://medium.com/media/6a388f14cebea493764cf0a59cf226b2/href</a></iframe><h3>Some other topics not covered in the demo</h3><p>Apart from some very simple use cases, usually you will want more control over your offsets and when to commit them. You can easily do it if you cast each RDD of the stream to an instance of HasOffsetRanges, and then use them with the stream casted as CanCommitOffsets class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db5e2168667564136c7c6d94964bd0fb/href">https://medium.com/media/db5e2168667564136c7c6d94964bd0fb/href</a></iframe><p>Take into account that the offsets are committed asynchronously, so it might fail and you will end up with repeated records in case of failure. I recommend you to use your own way to store the offsets if that makes sense for your use case.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47763f6bcf58" width="1" height="1" alt=""><hr><p><a href="https://medium.com/billyengineering/feature-integrating-kafka-with-spark-streaming-47763f6bcf58">Feature: Integrating Kafka with Spark Streaming</a> was originally published in <a href="https://medium.com/billyengineering">billyengineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Spark Streaming]]></title>
            <link>https://medium.com/billyengineering/introducing-spark-streaming-c1b8be36c775?source=rss-2585b057823a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1b8be36c775</guid>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Billy Mobile]]></dc:creator>
            <pubDate>Tue, 12 Sep 2017 08:52:45 GMT</pubDate>
            <atom:updated>2017-09-12T09:53:11.435Z</atom:updated>
            <content:encoded><![CDATA[<h4>Apache Spark Streaming + Kafka 0.10 (2/4)</h4><p>by <a href="https://medium.com/u/28f285c49703">Joan Viladrosa</a>, <a href="https://medium.com/u/21d5a797b4b4">Samuel Lissner</a>.</p><blockquote>This story is part of a series of articles related to the integration of Apache Spark Streaming and Apache Kafka. Feel free to check the other ones <a href="https://engineering.billymob.com/apache-spark-streaming-kafka-0-10-1f3c29a694cb">here</a>.</blockquote><h3>What is Apache Spark Streaming?</h3><p>Apache Spark is <em>the</em> trending big data technology right now. It was disruptive to the established Big Data and Data Science ecosystem. And sure, it possesses amazing capabilities.</p><p>Spark Streaming enables stream processing for Apache Spark’s language-integrated API. That is: Letting you write streaming jobs the same way you write batch jobs. This is the main advantage. Spark streaming relies on the same API, integrations, guarantees and semantics as Spark batch processing. As programming languages it supports Java, Scala and Python.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iBrb8EHqCrMrtGtc." /></figure><h3>How does it work?</h3><p>Spark Streaming is built upon a micro-batch approach. It discretizes the input data stream into batches of data. The Spark Engine continues to process the well-known basic data structure of Spark: Resilient Distributed Datasets (short RDDs), which are just distributed chunks of the original data. There are also some other amazing features provided out of the box, like <a href="https://databricks.com/blog/2015/07/15/introducing-window-functions-in-spark-sql.html">windowing functions</a>, but those are out of the scope of this post.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XKD4sFqGUq2z8Y5X." /></figure><p>So right now we have those discretized streams. We can apply all transformations to them like we would do conventionally. Because, under the hood, the Spark Streaming engine will apply those transformations to each RDD of the stream.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l6Rl-hOPQQH-hsnF." /></figure><p>What really makes Spark Streaming really cool compared to other Streaming Architectures is task balancing and recovery in case of node failure. (The balancing of tasks among nodes on a partition unbalanced stream.) The latter, although really cool, has some side effects, as we cannot guarantee exactly-once semantics for output actions. Probably you already faced this kind of problems in batch applications. In streaming applications the problem turns out to be more notorious since your application probably will be running 24/7 non-stop.</p><h3>How does Spark Streaming’s Kafka Integration work?</h3><p>As we said, a lot has changed over the time, both in Spark and Kafka sides, to make this integration more fault-tolerant and reliable. Here a quick overview over the changelog:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UXnGdh1HsYfwzbt4." /></figure><h4>Original Approach with Receivers</h4><p>The original approach to integrate Kafka with Spark was through receivers. That was basically an Apache Kafka high-level API Consumer instantiated on each Spark executor. They were receiving the messages asynchronously and stored them into the executor memory, while updating the offsets in zookeeper. Later on, the Spark Streaming Driver launched jobs on the data already received. Although this approach works, it had very poor fault-tolerance guarantees. Messages were lost on every restart, or node failures, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*By8SKq6nGDlFohmC." /><figcaption>Original approach with receivers</figcaption></figure><h4><strong>Fault tolerant Write-Ahead Log</strong></h4><p>To solve this issues, the next version (just a few months later) included a WAL (Write-Ahead Log). The main idea here is to write all the information, that the receiver receives on each executor, into a durable filesystem like HDFS (and not only to memory). In case of failure or loss of memory data, we can recover the state by consulting this WAL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WQiz2wYU2Wb5Cmg0." /><figcaption>Fault tolerant WAL</figcaption></figure><p>If we take a closer look, we see that not only the actual data is written into the log. We also find the metadata of the receivers that the Streaming Context of the Driver handles. This approach, with the already existent checkpointing (which is almost the same idea applied to the spark context), leads us to a fault-tolerant solution that guarantees no data loss.</p><p>But taking into consideration that Kafka has already its own retention for recovery, this solution seems to be a bit overkill. We could consult the lost information from Kafka’s Write-Ahead Log. It makes little sense to store and process all the information again in another durable filesystem. Also complexity is augmented through inflated amount of dependencies (the more you count, the more can fail). All this lead to a total new approach that both simplifies the usage and improves the performance and fault-tolerance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rwbmLlQfVc3yoFGk." /><figcaption>Storing metadata and data to WAL</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0QpL3aAoVm4oDm20." /><figcaption>Recovering metadata and data from WAL</figcaption></figure><h4><strong>Direct Streams or Kafka Direct Stream Integration</strong></h4><p>With Apache Spark 1.3 arrived a new approach of streaming integrations without the need of receivers. Also Kafka offers a new and simplified way to interact with Spark Streaming. The main shift was to use the “simple” API instead of the high level API, and taking advantage of the core feature of Kafka: it’s a durable log with custom retention. It is no longer necessary to store Kafka data in memory or add an additional Write-Ahead Log, because we can just ask the data directly from Kafka.</p><p>So, the first step runs on the Spark Streaming driver. It asks Kafka for the latests offsets on each partition of the topic. With this information (topic, partition, offset start and offset end), the driver launches deterministic and repeatable jobs on the executors in the right order. Then each executor will process the tasks, while retrieving the data from Kafka. If a job fails due to node failure, it does not matter, we have not lost anything. Just re-schedule the task on another executor and retrieve the data again from Kafka.</p><p>You may notice that the Zookeeper dependency has gone. Since we are no longer using the High Level API, there is no need for a coordinator of the consumer group. You will still be in charge of storing and keeping those offsets safe in case of Driver failure or Application restart, so probably you will keep storing them in ZooKeeper or some other place, but at least we reduced the dependencies of the basic use case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9k38xvMXkuJDFykY." /><figcaption>Kafka Direct Stream using Simple API</figcaption></figure><h3>Other Streaming Improvements</h3><p>Over the versions, Spark Streaming UI received some improvements, with 1.4 adding graphics and histograms on how our application is handling the batches, and with 1.5 including metadata of the Direct Receivers.</p><p>We won’t discuss in detail all those capabilities, but it’s always a good thing know your application capabilities. So 👍 to improvements about monitoring on Spark Streaming Applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qJVRat-DklejUOMx." /><figcaption>Timelines and Histograms from Spark 1.4+</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zRylOhfDt070ugPZ." /><figcaption>Details of each Spark Streaming micro batch</figcaption></figure><p>Enough theory! In our next article we will present some code examples and a small demo on how to tie together Spark Streaming and Apache Kafka in practice.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1b8be36c775" width="1" height="1" alt=""><hr><p><a href="https://medium.com/billyengineering/introducing-spark-streaming-c1b8be36c775">Introducing Spark Streaming</a> was originally published in <a href="https://medium.com/billyengineering">billyengineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Apache Kafka]]></title>
            <link>https://medium.com/billyengineering/introducing-apache-kafka-38cb5b3f350e?source=rss-2585b057823a------2</link>
            <guid isPermaLink="false">https://medium.com/p/38cb5b3f350e</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[message-queue]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Billy Mobile]]></dc:creator>
            <pubDate>Mon, 14 Aug 2017 15:17:27 GMT</pubDate>
            <atom:updated>2017-09-12T09:52:45.690Z</atom:updated>
            <content:encoded><![CDATA[<h4>Apache Spark Streaming + Kafka 0.10 (1/4)</h4><p>by <a href="https://medium.com/u/28f285c49703">Joan Viladrosa</a>, <a href="https://medium.com/u/21d5a797b4b4">Samuel Lissner</a>.</p><blockquote>This story is part of a series of articles related to the integration of Apache Spark Streaming and Apache Kafka. Feel free to check the other ones <a href="https://engineering.billymob.com/apache-spark-streaming-kafka-0-10-1f3c29a694cb">here</a>.</blockquote><h3>What is Apache Kafka?</h3><p>Although Apache Kafka has evolved during the years, and right now it becomes a distributed streaming platform, in its guts, it’s still a publish-subscribe messaging system. What does that mean?</p><p>It’s a place where your applications can send messages, and later on, other applications can read and process them. A lot of systems can do that, but what makes Apache Kafka great and unique, is its scalability, fault-tolerant capabilities and retention system. And also, it is blazingly fast. ;-)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9jooCan8nQUWX0kW." /></figure><p>We consider Apache Kafka a central point in our architecture. All core applications communicate with Kafka back and forth. There are a lot of different connectors already provided by the open source community, for all kind of streaming technologies and frameworks. So, usually it is easy and fast to integrate your own applications with Kafka.</p><h3>Kafka Glossary</h3><p>First of all, we should get familiar with some Kafka terminology to get started with. The message feed in our publish-subscribe messaging system is called <strong>Topic</strong>. A given topic can be used by <strong>Producers</strong> to publish messages, and by <strong>Consumers</strong> to subscribe to them and process the stream. The <strong>Broker </strong>is a server (or a bunch of servers) that confronts a Kafka cluster, and holds, receives and sends the actual data.</p><p>A topic is then split into several <strong>partitions</strong> (which will define the maximum amount of parallelism that we can achieve, but more on this later). Each partition is a timestamp sorted list of messages. Producers can only write new data at the end of the partition. Each message can be located with the help of an offset within each partition. So we can refer unequivocally to them with three parameters: topic, partition, offset. Although we can guarantee the order of messages along one single partition, there is no way to know, only by its offset, the order of two messages of two different partitions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dari7WHEpxnJNUOh." /></figure><p>What really makes Kafka so fast, is actually the fact that it does very little. Neither the brokers, nor even the entire Kafka cluster does store the state of the consumers (actually, Kafka provides a mechanism to do so, but it’s not enforced. Many integrations do not use it). Each consumer is responsible of storing the offsets of each partition which have been already processed. In case of failure or restart, the consumer indicates from which offsets it continues reading.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2Qmr7FjwFFlQ4j6h." /></figure><p>One might think that the partitioning might be a bit of a nightmare; given the problem of processing a stream of data in a fixed order or of specific semantics. However, it’s the mechanism Kafka uses to split data of a single topic across different brokers. By this, it achieves more storage, and even more parallelism. For your applications, it really provides a great boost in performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CDDl1E5FICvhOT7r." /></figure><p>But please, remember at all times that you are using a distributed system, and that consumer <a href="https://kafka.apache.org/documentation/#semantics">delivery semantics</a> — that describe the guarantees, or successful delivery, to processes in a group — are up to you, not Kafka.</p><h3>Kafka Timeline</h3><p>A lot has changed since Apache Kafka became an Incubator Project. First we got the new Producer API written in Java. Because the prior one was written in Scala, this has reduced the dependencies for Java applications. Also Kafka has become faster and more fully featured.</p><p>However, things got really interesting with the new Consumer API. Basically, because it merged into one the best parts of the two prior, separate and different Consumer APIs: the high level API and the low level API.</p><p>The high-level API supported consumer groups, and handled failover, but didn’t support many of the more complex usage scenarios. The “<em>simple</em>” consumer API provided full control, but usually that means that the developer has to take into account and manage the failover and errors themselves. This is probably not the best tradeoff.</p><p>As it has been said, the new Consumer API combines the capabilities of both. It offers group coordination and lower level access. Therewith you can build your own consumption strategies.</p><p>With the latest release (0.10), we got security enhancements, but more exciting: <em>The Kafka Streams</em>. We aim to talk more about them in a future post. But briefly: it is a Java library for building distributed stream processing apps, with a very nice and friendly API and semantics. For developers already knowing Java 8 streams capabilities, it makes a perfect start to get dirty with Apache Kafka.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1ngfXgyYxbfsac8w4vChw.png" /></figure><p>So, stay tuned for the next article of the series, Introducing Spark Streaming!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38cb5b3f350e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/billyengineering/introducing-apache-kafka-38cb5b3f350e">Introducing Apache Kafka</a> was originally published in <a href="https://medium.com/billyengineering">billyengineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Spark Streaming + Kafka 0.10]]></title>
            <link>https://medium.com/billyengineering/apache-spark-streaming-kafka-0-10-1f3c29a694cb?source=rss-2585b057823a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f3c29a694cb</guid>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[integration]]></category>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[apache-kafka]]></category>
            <dc:creator><![CDATA[Billy Mobile]]></dc:creator>
            <pubDate>Mon, 14 Aug 2017 15:15:42 GMT</pubDate>
            <atom:updated>2017-12-11T11:10:14.169Z</atom:updated>
            <content:encoded><![CDATA[<h4>an integration love story</h4><p>by <a href="https://medium.com/u/28f285c49703">Joan Viladrosa</a>, <a href="https://medium.com/u/21d5a797b4b4">Samuel Lissner</a>.</p><p>Since its inception, Spark Streaming supported consuming data provided by Apache Kafka. Kafka has been for many years a prime choice of a messaging queue service integrating with Spark. But a lot has changed since those times, for both Spark and Kafka. In general terms: the integration has matured. Today, it’s more fault-tolerant and reliable. However, there are notable differences in usage, and many exciting new features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*KxsTc4oUaEJVU2J4akI4Xw.png" /></figure><p>At <a href="https://www.billymob.com/">Billy Mobile</a>, Spark Streaming with Kafka has beefed up our real-time processing services, such as our offer prediction model, our tracking system or the ingestion and aggregation of our real-time stats and reporting system.</p><p>With this series of articles, we would like to share our experience using these technologies and focus on the main differences between the newer integration (starting from Kafka 0.9, respectively Kafka 1.0) and the previous one (for Kafka 0.8).</p><ul><li><a href="https://engineering.billymob.com/introducing-apache-kafka-38cb5b3f350e"><strong>Introducing Apache Kafka</strong></a></li><li><a href="https://engineering.billymob.com/introducing-spark-streaming-c1b8be36c775"><strong>Introducing Apache Spark Streaming</strong></a></li><li><a href="https://engineering.billymob.com/feature-integrating-kafka-with-spark-streaming-47763f6bcf58"><strong>Kafka Spark Streaming Integration with demo code!</strong></a></li><li><strong><em>Semantics and (Billy) use cases examples (soon)</em></strong></li></ul><p>Hope you enjoy them, and stay tuned for upcoming articles!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f3c29a694cb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/billyengineering/apache-spark-streaming-kafka-0-10-1f3c29a694cb">Apache Spark Streaming + Kafka 0.10</a> was originally published in <a href="https://medium.com/billyengineering">billyengineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Billy Mobile at App Promotion Summit]]></title>
            <link>https://medium.com/billy-blog/billy-mobile-at-app-promotion-summit-cc5da375ec43?source=rss-2585b057823a------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc5da375ec43</guid>
            <category><![CDATA[mobile-advertising]]></category>
            <category><![CDATA[affiliate-network]]></category>
            <category><![CDATA[mobile-app-promotion]]></category>
            <category><![CDATA[billy-mobile]]></category>
            <category><![CDATA[app-promotion-summit]]></category>
            <dc:creator><![CDATA[Billy Mobile]]></dc:creator>
            <pubDate>Fri, 21 Jul 2017 14:36:53 GMT</pubDate>
            <atom:updated>2017-07-21T14:36:53.103Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vfRqfIHLMIoYtu-V8cxJsQ.png" /></figure><p>Last Wednesday the Billy team were in London️ for the awesome <a href="https://www.facebook.com/AppPromotionSummit/?fref=mentions">App Promotion Summit</a>! The Billies had a great day networking and listening to fascinating insights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*cW7KsAixhiJ3Cab5S0N5Nw.jpeg" /></figure><p>Some stand out features of the event included:</p><p>🔹Intimate workshops where the audience could ask questions to the speaker. This meant it was easy to gain insights into other people’s perspectives via the questions they were asking.</p><p>🔹An impressive talk at the end of the day focused on helping app developers. Developers were able to talk to the audience about their app, receive feedback and gain other’s opinions on how best to engage in app promotion.</p><p>As always, a huge thanks to the event organisers and everyone we got a chance to meet and catch up with. Till next time!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dYOpaqhtSEiToyWTen20JQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc5da375ec43" width="1" height="1" alt=""><hr><p><a href="https://medium.com/billy-blog/billy-mobile-at-app-promotion-summit-cc5da375ec43">Billy Mobile at App Promotion Summit</a> was originally published in <a href="https://medium.com/billy-blog">Adtech’s Corner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Meet the Billies: Meet Claudia]]></title>
            <link>https://medium.com/billy-blog/meet-the-billies-meet-claudia-fcd97db8d86c?source=rss-2585b057823a------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcd97db8d86c</guid>
            <category><![CDATA[affiliate-network]]></category>
            <category><![CDATA[mobile-advertising]]></category>
            <category><![CDATA[billy-mobile]]></category>
            <category><![CDATA[meet-billy-mobile]]></category>
            <dc:creator><![CDATA[Billy Mobile]]></dc:creator>
            <pubDate>Fri, 21 Jul 2017 14:32:24 GMT</pubDate>
            <atom:updated>2017-07-21T14:37:14.114Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*QPso4F3-zWJ7tmXE7Cccaw.jpeg" /></figure><p><strong>Name:</strong> Claudia Musteata</p><p><strong>Role:</strong> Advertisers Platform Manager — Business developer for our new DSP.</p><p><strong>Hometown:</strong> Botosani, Romania</p><p><strong>LinkedIn profile:</strong> <a href="https://www.linkedin.com/in/claudiamusteata/">https://www.linkedin.com/in/claudiamusteata/</a></p><p><strong>Favorite Ad:</strong> Love Has No Labels | Diversity &amp; Inclusion | Ad Council: <a href="https://l.facebook.com/l.php?u=http%3A%2F%2Fbit.ly%2F1GhFYYy&amp;h=ATNgaXU8bpWxk69026ITfzFD1xNZiOaSMtZD9jYflxmup5I7mN4FXhHt18eXHu0SDmycJm77Chlz0EH9-uW7aMdKtlJl6n9vsLtoY_FKn9Y-Tb_rl4uda7X1wA-BJrTO3SEy4Ajb_hK30zdBGvqtoSSGfakaTg&amp;enc=AZNw8SECsmijtCvn2K_Nb7jefhPvwT8pS8QZEMiE48D6o34CShzEQORyq0zYiSy4IEa3cW7XN0AWRuUlesDMGpPPbM0vH9vmOH9ktfvq76J_XbbJXX81kp-LFrMBsvzGVODZZKLHaWSStTU_sazOrmCmn9-6pZFIEo4wfm3RBZYUaImoZTacJ2KZ2W7zBS2lw7G5W46LamiS-j4UHKfGWGcr&amp;s=1">http://bit.ly/1GhFYYy</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*sC69XjNqILUysrTcjKMS7w.jpeg" /></figure><p><strong>Hobbies:</strong> Gym, reading, mountain walks, sunbathing, coffee with friends, spending time with my beloved ones.</p><p><strong>Favourite time of the day:</strong> Evenings — watching the sunset with a glass of red wine.</p><p><strong>What I like the most at Billy:</strong> The challenges and how people react to them. Great team spirit, the get togethers after work on a Friday, working with good professionals and friends- it´s a dream come true!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcd97db8d86c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/billy-blog/meet-the-billies-meet-claudia-fcd97db8d86c">Meet the Billies: Meet Claudia</a> was originally published in <a href="https://medium.com/billy-blog">Adtech’s Corner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Meet the Billies: Meet Roberto]]></title>
            <link>https://medium.com/billy-blog/meet-the-billies-meet-roberto-aa702a8b6ec3?source=rss-2585b057823a------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa702a8b6ec3</guid>
            <category><![CDATA[affiliate-network]]></category>
            <category><![CDATA[mobile-advertising]]></category>
            <category><![CDATA[meet-billy-mobile]]></category>
            <category><![CDATA[billy-mobile]]></category>
            <dc:creator><![CDATA[Billy Mobile]]></dc:creator>
            <pubDate>Fri, 21 Jul 2017 14:26:11 GMT</pubDate>
            <atom:updated>2017-07-21T14:26:11.643Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*4gm59oGbKZnXwJ7AYDORmA.png" /></figure><p><strong>Name:</strong> Roberto Alcubilla Méndez.</p><p><strong>Role:</strong> Mobile apps User Acquisition Manager. We promote your mobile apps getting great quality users!</p><p><strong>Hometown: </strong>Valladolid, Valladolid, Spain.</p><p><strong>LinkedIn profile:</strong> <a href="https://www.linkedin.com/in/roberto-alcubilla-m%C3%A9ndez-004b6a127/">https://www.linkedin.com/in/roberto-alcubilla-m%C3%A9ndez-004b6a127/</a></p><p><strong>Favorite Ad: </strong>Heineken | Walk in fridge <a href="https://www.youtube.com/watch?v=yIutgtzwhAc">https://www.youtube.com/watch?v=yIutgtzwhAc</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*pdt6w25opc9RicCpT3XqNQ.jpeg" /></figure><p><strong>Hobbies:</strong> Team sports, specially basket — Travel — Enjoying friends and family’s company.</p><p><strong>Favourite time of the day:</strong> The afterwork at Billy when the day has been productive and profitable.</p><p><strong>What I like the most at Billy:</strong> The Billies and their attitude.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa702a8b6ec3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/billy-blog/meet-the-billies-meet-roberto-aa702a8b6ec3">Meet the Billies: Meet Roberto</a> was originally published in <a href="https://medium.com/billy-blog">Adtech’s Corner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Big Data in Digital Advertising]]></title>
            <link>https://medium.com/billyengineering/big-data-in-digital-advertising-59bed9204335?source=rss-2585b057823a------2</link>
            <guid isPermaLink="false">https://medium.com/p/59bed9204335</guid>
            <category><![CDATA[billy-mobile]]></category>
            <category><![CDATA[tech-stack]]></category>
            <category><![CDATA[mobile-advertising]]></category>
            <category><![CDATA[affiliate-network]]></category>
            <category><![CDATA[big-data]]></category>
            <dc:creator><![CDATA[Billy Mobile]]></dc:creator>
            <pubDate>Thu, 06 Jul 2017 09:59:07 GMT</pubDate>
            <atom:updated>2017-07-06T10:38:19.887Z</atom:updated>
            <content:encoded><![CDATA[<h4>The billy mobile architecture</h4><p>by <a href="https://medium.com/u/28f285c49703">Joan Viladrosa</a>, <a href="https://medium.com/u/21d5a797b4b4">Samuel Lissner</a>.</p><p>In digital advertising, it is of the utmost importance to show the highest-performing advertisements to your thousands or even millions of visitors at the right time. In order to be competitive in such an environment a great demand is placed on high performing architectures.</p><p>We will take a close look in this post at the tech stack of<a href="https://www.billymob.com/"> <em>Billy Mobile</em></a><em>,</em> one of Spain’s leading ad-networks. Billy is an example of how complex and often seemingly contradictory architectural requirements can be realized through big data technology, while delivering the highest possible performance.</p><h4>V for Velocity</h4><p>As a digital marketplace that optimizes traffic in the mobile advertising industry, <em>Billy Mobile’s </em>architecture handles the traffic between thousands of advertisers and publishers. Our ad-servers account for tens of thousands to millions of visits during a single day. Together, they are producing around 60 gigabytes of data.</p><p>This entails a couple of problems: High data throughput may contradict rapid access and response time. Small chunks entering at a massive scale could unexpectedly congest pipes.</p><p>So, how can one avoid these negative effects using the least necessary hardware resources? We will address this by going through the architectural components step-by-step.</p><h4>Minimizing response time</h4><p>Let’s start with our first important architecture component. The <strong>Ad-Manager Service</strong> is the initial entry point of a long chain of decision making and data processing. It receives data from one of our publishers, which, in turn, receives visitor requests. Our publishers want to know<em> which offer is the best for the incoming traffic</em>.</p><p>To answer this question, we have to match a set of variables (targeting), provided by the incoming visitor, with the offers in our databases. These offers were defined by our advertisers. Typical targeting variables are connection type, country, device type and so on. On average, the Ad-Manager has to answer about 2,000 such visitor requests per second without losing a single one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/0*8yN3iKgb0RWekOdJ." /></figure><p>Ad-Manager is a Java application. It is a HTTP server based on the Netty framework. Netty is an asynchronous event-driven network application. It allows for rapid development of maintainable high-performance protocol servers and clients. Internally, it is orchestrating a bunch of microservices. For example, an external provider informs us about the location of a visitor by matching their IP address to the site. Such data is decisive during the which-offer-to-show decision-making process.</p><p>So, the netty-based Ad-Manager receives incoming HTTP requests from our customers’ servers. Based on the nature of advertising and the underlying business model, those requests are then redirected to a specific endpoint. In this routing layer, each endpoint usually receives the data of a different offer category or type. This is, for instance, incoming traffic of offers with the type “banners” or “links”. From there, we start processing the request, extracting all the information we can. Our objective is to predict the best advertisement that we can answer back to the publisher in less than 20 ms (percentile 95).</p><h4>Balancing heavy load</h4><p>To achieve a rapid response time and speed, we have set up a bunch of servers that run Ad-Managers. This increases both system availability and scalability. Being a computer cluster, though, the load balancing through all of the front servers is achieved via <strong>HA Proxy</strong>. This application is a reliable, high performance TCP/HTTP load balancer. HA Proxy has proven to achieve between 15,000 and 40,000 hits per second. It is capable of saturating a two gigabit connection with a relative low-end hardware (dual core xeons).</p><p>So, it makes sense for us to use this high-throughput technology without having to worry about it being a bottleneck. On top of HA Proxy, we distribute the traffic through the HA Proxy servers via a DNS balancer with a round robin and fail-fast strategy.</p><p>One challenge was storing cookie and user-related data with a single state on all Ad-Managers in the cluster. To manage state and share memory between the fronts, we use Redis Cluster. <strong>Redis</strong> is an in-memory key-value (data structure) store. It provides several good features that let us manage this huge amount of in-memory data, such as the auto-expire function of keys. It is simply a timeout function that invalidates keys after a certain amount of time. This allows us to reduce the amount of memory used by adjusting the Time To Live (TTL). Also, the amount of data structures (such as sorted sets and hashes), helps improve the performance of some queries without having to deal with huge network payloads and client processing.</p><h4>Leveraging high data throughput to storage</h4><p>A response from our Ad-Managers contains the best-performing advertisement suitable for one particular visitor to one publisher’s server. However, all of the responses that our Ad-Manager sends back to the visitors (including further contextual data) are also copied into a <strong>Apache Kafka</strong> Cluster. Kafka can be seen as a distributed log system; it is horizontally scalable, fault-tolerant, wicked fast, and runs in production in thousands of companies. Kafka is also<a href="https://engineering.linkedin.com/kafka/benchmarking-apache-kafka-2-million-writes-second-three-cheap-machines"> proven to ingest millions of records per second in relative low-end hardware</a>.</p><p>However, in our case, it is more appropriate to think about a queue system. This is where Ad-Manager and other components send all of the messages that our systems generate. Kafka keeps them safe until we can ingest them with Apache Storm for further processing (more below). Kafka allows us to temporarily decouple front- and back-end architectures. This is extremely useful when components in the back-end undergo maintenance work.</p><p>The best metaphor for imagining Kafka as a queue log mechanism is that of a water-tap. Kafka and Storm are connected by a hose. Kafka is the mechanism that prevents the water (data) in the hose from escaping. What happens to a hose (as to Kafka), though, when the tap is closed? It inflates through the pressure of the incoming water (data). However, as long as we open the tap in a timely manner, the pent-up data, like water, flushes out in massive quantities.</p><p>In reality, however, Kafka is not sending data; instead, the next player, <strong>Apache Storm</strong>, is ingesting the data from Kafka. Storm is a free and open source distributed real-time computation system. When Storm fetches data from Kafka, it usually stores it into Hive for good, with a minimum delay. Storm is fast: A benchmark clocked it at over a million tuples processed per second per node.<a href="https://hortonworks.com/blog/microbenchmarking-storm-1-0-performance/"> Storm 1.0 is even faster</a>.</p><p>The code is distributed in Storm topologies. A topology is basically a graph with two types of nodes: <em>Spouts</em>, a source of stream data (for example, the Kafka Spout, which reads from Kafka), and <em>Bolts</em>, which applies some processing into the stream of data. Thus, the topology is a top-level abstraction of the Storm stream-processed data flow. The data flows from the front via Kafka and Storm to other components. Usually, in the end, it is being inserted into <em>Apache Hive</em> as the main data mass storage (through the Hive Bolt, as you have probably guessed).</p><h4>Queriability through structure</h4><p>Before talking about Hive, we should mention Apache <strong>HBase</strong><em>. </em>In general, HBase is a key-value big data store. In billy, we use HBase as an entity cache. We store the impressions and other data entering into our systems. As a result, we are able to join information between impressions and conversions to the corresponding clicks and conversions once they occur.</p><p>Remember: Chronologically speaking, impressions happen first, followed in minor quantities by clicks and other conversions. So, when to use HBase? Use HBase when you need random, realtime read/write access to your Big Data (some tens of TBs every month). Also, it couples perfectly with the hadoop ecosystem, being able to query its data through the variety of processing frameworks available (hive, pig, mapreduce, spark, etc.)</p><p>Finally, as mentioned, we store the data in Apache <strong>Hive</strong>. Apache Hive is the SQL layer on top of Hadoop. This makes the data queryable for further analysis, albeit those queries process relatively slowly. Usually, when it comes to Hadoop, everything is batch, immutable, and slow (although big data! yay!), thus making it hard to achieve a near-real-time approach for ingesting data. This is a hurdle when making data available as fast as possible to our data-science guys, commercial team, and also to our prediction algorithm. There are a variety of solutions for achieving some kind of mutating data ability. However, all of them were very hard to maintain and difficult to code.</p><p>Fortunately for us, Apache Hive has recently included an amazing feature: ACID transactions and Streaming API. It allows us to continuously add more data in the form of delta micro-batches, without losing availability or consistency. The magic happens in the background, completely managed and without hassle for our data. Hive stores every micro-batch as a delta-file. Every now and then, when we have enough of those files, the compactor comes in action and merges them into the base data. The most important part: The data is available as soon as it is committed (stored as a delta file).</p><h4>Conclusion</h4><p>One can see that every component in the architecture represents a necessary leverage in the data flow. From beginning to end, the data processing speed slows down, but increases in terms of structure and the ease of querying it. At first, massive and rapid response time is necessary, as it is necessary to secure data integrity while processing. In the mid-level, Storm and Hbase guarantee a relatively quick distribution and access to data for response processing. This data, however, is less structured, making it hard to extract for further data evaluation and analysis. This purpose is fulfilled by Hive on ACID. Ultimately, no single component could solve the inherent challenges that Billy Mobile advertising is facing. However, the right orchestration of components in the<a href="https://www.billymob.com/"> Billy Mobile</a> architecture achieves this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59bed9204335" width="1" height="1" alt=""><hr><p><a href="https://medium.com/billyengineering/big-data-in-digital-advertising-59bed9204335">Big Data in Digital Advertising</a> was originally published in <a href="https://medium.com/billyengineering">billyengineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>