<?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 Ilai Malka on Medium]]></title>
        <description><![CDATA[Stories by Ilai Malka on Medium]]></description>
        <link>https://medium.com/@ilaimalka?source=rss-7c94c5b678aa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9zegAJ0ZjfNz6bcr.jpg</url>
            <title>Stories by Ilai Malka on Medium</title>
            <link>https://medium.com/@ilaimalka?source=rss-7c94c5b678aa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 07:16:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ilaimalka/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[Going Serverless — a real use-case]]></title>
            <link>https://medium.com/@ilaimalka/going-serverless-a-real-use-case-1e40e80a2a9c?source=rss-7c94c5b678aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e40e80a2a9c</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Ilai Malka]]></dc:creator>
            <pubDate>Sun, 23 Feb 2020 14:16:52 GMT</pubDate>
            <atom:updated>2020-02-23T14:16:52.922Z</atom:updated>
            <content:encoded><![CDATA[<h3>Going Serverless — a real use-case</h3><p><em>At Nielsen Marketing Cloud, we use Serverless computing and cloud storage as a core component of our data processing platform. In this blog series, we will share what we believe to be high-value insights on how the computing world is changing and how you can leverage that to build incredible applications.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/0*fw14-YaoR4zaof-v" /></figure><p>In the previous <a href="https://medium.com/nmc-techblog/going-serverless-c334ae242ca6">post</a> of <em>Going Serverless</em>, we covered the computation world’s journey from owning servers to leasing servers and finally to rent computation power for very short periods, aka Serverless.<br>We saw the downsides of the first two paradigms and the ground-breaking benefits that Serverless unleashes.</p><p><strong>In this post, we will explore a data processing platform we’ve built in Nielsen, based on Serverless infrastructure.<br></strong>We will see how Serverless allows us to build highly scalable applications and even reduce costs.<br>We will also understand the pitfalls of Serverless and how to avoid them.</p><p>But before we begin…</p><h3><strong>What is Serverless?</strong></h3><p>The idea is that the server becomes a service. You just need to write a “function” (i.e a piece of code) and<strong> instead of managing servers yourself, a cloud provider dynamically allocates resources for your code.</strong></p><p>How is that related to scalability? When your application needs more resources (for example when the incoming traffic is high), you can execute more invocations of that function and the cloud provider will allocate the appropriate resources per invocation.<br>This allows you to build a <strong>“breathing” application that grows and shrinks in real-time and can handle any kind of load.</strong></p><p>Applications that aren’t built on Serverless infrastructure aren’t “breathing”. Let me explain with two examples:</p><p>A. The application runs on a <strong>server</strong> (or a cluster of servers) that <strong>has enough resources</strong> to handle the <strong>maximum load</strong> of the application.<br>In this case, <strong>most of the day</strong>, when the load is average, the server will be <strong>underutilized</strong> even though we are paying the <strong>full price</strong> for it.<br>This is very similar to a car that stands in the parking lot most of the day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EM0Uyc1dnjJK2rgd" /><figcaption>Underutilized car (most of the day…)</figcaption></figure><p>B. The application runs on a <strong>server</strong> (or a cluster of servers) that <strong>only has enough resources</strong> to handle the <strong>average load</strong> of the application. <br>In this case, the application will suffer from <strong>performance issues</strong>, and a <strong>backlog of tasks</strong> will start piling up. Exactly like traffic jams on narrow roads at rush hours.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qKts_wy_Hpk2iEl6" /><figcaption>A backlog of cars is piling up</figcaption></figure><h3><strong>Moving on to a real use-case</strong></h3><p>The application we needed to build was a <strong>data pipeline that streams data to our partners</strong>, which are ad platforms (as of today, we stream <strong>250 Billion events per day</strong> and growing).<br>Also, we had to design a <strong>scalable</strong> application, because the amount of the data can increase and decrease throughout the day.</p><p>When the team initially brainstormed how to design this application, <a href="https://spark.apache.org/"><strong>Apache Spark</strong></a> <strong>automatically came</strong> to everyone’s mind — Spark was built to handle huge amounts of data.<br>But <strong>the problem is scalability</strong>: while Spark is obviously scalable, its scalability is somewhat <strong>rough around the edges</strong> — your smallest “scalability unit” is an executor.<br>However, you don’t necessarily want to launch a new executor (or sometimes — a whole new worker node), just to accommodate a few short tasks.<br>And even if we do that, <strong>scaling-out (or scaling-in) takes time</strong> (which can range from seconds to minutes, if we launch a new worker node).<br>In our case, waiting several minutes for a new worker node to be added to the cluster is just too much.</p><p><strong>A second problem</strong> is that the input data is stored in <strong>thousands or even millions of files</strong>, which <strong>vary in size</strong>.<br>It will be difficult to tune the cluster to process them optimally, thus this application will end up being very expensive.<br>We had experience with that in the past — we had a Spark application that was splitting files to smaller chunks.<br>This application was working with a variety of file sizes — most of the files were very small (around 50MB), but now and then we had a really big file (about 5GB).</p><p>When we <strong>reimplemented</strong> this application <strong>using Serverless</strong> infrastructure, the <strong>cost dropped by 44X </strong>(from $1850 to $42 per month).<br>But the improvements weren’t just related to costs — the performance got much better since when a 5GB file arrived, the Serverless infrastructure allocated enough resources to process it quickly.</p><h3><strong>Spark — Out, Serverless — In</strong></h3><p>As Spark was out of the question, we decided to implement our application over Serverless, and specifically, <a href="https://aws.amazon.com/lambda/">AWS Lambda</a> (hereinafter “Lambda”), which is a Serverless computing platform provided by AWS.<br>Again, our application processes files containing data we generated earlier in the pipeline (see the <em>‘Incoming files’</em> box in the diagram below).<br>Every file contains multiple records we call <strong>events</strong>.<br>Each file is processed via a single Lambda invocation (see the <em>‘Uploader’</em> box), that sends its data to our partners (see the<em> ‘Ad Networks’</em> box).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FUKudM6ocXjiy_tM" /><figcaption>Simplified overview of the architecture</figcaption></figure><p>As the number of files we receive every moment is not fixed, so is the amount of Lambda invocations that are being executed, and here’s how the scalability of the application comes into play.<br>This allows our application <strong>to</strong> <strong>grow and shrink throughout the day by a factor of 3</strong>, uploading a total size of anywhere between 0.3TB/hour and 1TB/hour to our partners.<br>This is not a hard-limit, it’s just what we actually need. Theoretically, it’s limitless.</p><p>And the best thing is — <strong>we didn’t have to write a single line of code to support it</strong> — the fact that our application is <strong>Serverless-based</strong> <strong>makes this amazing capability possible</strong>.<br>On top of that, <strong>Serverless infrastructure reduces our time to market</strong> — when scalability comes out-of-the-box, the development team can focus on business needs instead of infrastructure considerations.</p><h3><strong>Show me the money!</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iX1nS_g698MRnZlP" /></figure><p>The fact that the application’s cost is linear to the computation power it uses, has both negative and positive sides.</p><p>On the negative side, you have to be very careful with costs — if your resource consumption increases (even due to a bug), the cost can skyrocket.<br>Moreover, until you discover the bug and deploy a fix, the meter is running.<br>To overcome this problem we are using alerts to detect such issues as early as possible. We are collecting metrics from the Lambda invocations to a central monitoring application, and send alerts to Slack when we have more invocations than expected, when the average duration dramatically increases, or when the failure rate is too high.</p><p>On the positive side, Serverless opens the door to cost reduction — <strong>if you will optimize your resource consumption, you will save money</strong> — this is a huge incentive. This is not the case with other architectures — if you will optimize a code that is executed on a server, you will improve the performance but not the necessarily cost (at least not as linear as with Serverless).<br>So <strong>Serverless puts a mirror in front of you, that pushes you to optimize your code</strong>.</p><h3><strong>From $7 to $3 (per billion events) — 60% COST REDUCTION!</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SBChOBGM0w5dI-qJ" /><figcaption>The optimized code was deployed on July — notice the significant cost reduction</figcaption></figure><p>For every Billion events we send to our partners, we are paying around $3. However, in the first months after deploying our application to production, we were paying around $7.</p><p>How did we achieve that?<br>First, <strong>let’s understand how the pricing model of Lambda works</strong> — the price is determined by <strong>two factors</strong>:</p><ol><li>The <strong>amount of memory</strong> that was allocated to the function (this part is static and configured once, when the function is deployed);</li><li>The <strong>duration of the invocation</strong> in 100 milliseconds’ resolution.</li></ol><p>For each memory setting (for example 128MB or 512MB) there is a price for 100 milliseconds (see <a href="https://aws.amazon.com/lambda/pricing/">here</a>).<br>This formula has <strong>two pitfalls</strong>:</p><ol><li>Let’s say I’ve changed the function’s configuration and reduced the allocated memory from 512MB to 128MB. <br>The new duration may be longer since my code has less memory to use. <br>So in total, I won’t necessarily pay less.</li><li>Unofficially, the “strength” of the CPUs allocated to your function invocation, depends on the memory you’ve allocated. Let’s say we’ve increased the memory setting from 512MB to 1024MB — we might get stronger CPUs and our code will run faster (but we don’t have a way to know the relation between memory and CPU strength).</li></ol><p>So the challenge is to <strong>find an optimal combination of memory and duration</strong>.</p><p>To achieve this, we’ve built a tool that executes many Lambda invocations with different settings. A setting can be the memory allocated for the invocation, but it can also be an applicative configuration, such as the size of the connection pool to the database (assuming our application uses a database). <br>For each setting, our tool executes multiple invocations to cancel out non-deterministic behaviors like momentary slowness of the network or warm-up time (which is the time it takes to spin up a new container to run your code in).<br>The output of the tool is the cost per invocation for each setting, and thus we could choose the optimal setting that reduced our cost-per-billion from $7 to $3.</p><h3><strong>Unexpected consequences of using Serverless infrastructure</strong></h3><p>We saw that <strong>thanks to using Serverless infrastructure</strong>, our application is <strong>highly scalable</strong> and can handle any kind of load.<br>However, unfortunately, our partners may not.<br>To avoid flooding them with too much data, we were asked to add a rate limit mechanism to control the amount of data we send them.</p><p>In the next blog post, I will elaborate on how this mechanism works.</p><h3><strong>Key takeaways — why Go Serverless?</strong></h3><ol><li>It allows you to focus on the business logic, rather than infrastructure considerations</li><li>It can scale out and in very fast</li><li>You get almost instant feedback about costs, which motivates you to optimize your code</li><li>Not everyone is as scalable as we are ;)</li></ol><h3><strong>Summary</strong></h3><p>Serverless infrastructure gives you great power and, with a few custom additions (such as alerts for early detection of unexpected behavior), you can have a very sophisticated and impressive application in a very short period of time.</p><p>I highly encourage you to adopt Serverless infrastructure in your organization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e40e80a2a9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Going Serverless]]></title>
            <link>https://medium.com/@ilaimalka/going-serverless-c334ae242ca6?source=rss-7c94c5b678aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/c334ae242ca6</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Ilai Malka]]></dc:creator>
            <pubDate>Sun, 21 Jul 2019 18:57:08 GMT</pubDate>
            <atom:updated>2019-07-22T07:43:58.641Z</atom:updated>
            <content:encoded><![CDATA[<h4>Computing’s journey from ownership TO short-term-rental</h4><p><em>By: </em><a href="https://medium.com/@ilaimalka"><em>Ilai Malka</em></a><em>, </em><a href="https://medium.com/@opherd"><em>Opher Dubrovsky</em></a><em> and </em><a href="https://medium.com/@itai.yaffe"><em>Itai Yaffe</em></a></p><p><em>At Nielsen Marketing Cloud, we use Serverless computing and cloud storage as a core component of our data processing platform. In this blog series, we will share what we believe to be high-value insights on how the computing world is changing and how you can leverage that to build incredible systems.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dMLhnHcmioAumIj3" /><figcaption>Photo by <a href="https://unsplash.com/@davealmine?utm_source=medium&amp;utm_medium=referral">Dawid Zawiła</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Specifically, we’ll explore the computing world’s journey from an <strong><em>ownership</em></strong> model TO a <strong><em>leasing</em></strong> model and eventually TO a <strong><em>short-term-rental </em></strong>model.</p><p>The change is a <strong>ground-breaking shift</strong> equivalent to the move from propeller airplanes to jets. <br>In some ways, it’s analogous to the move from buying an office, to renting an office, to renting office-space per day from WeWork and only when that space is needed.</p><p>As we will show, the change is even more profound in the computing world. Due to the fact compute requirements of most systems go up and down over time periods by orders of magnitude, the very short-term-rental model is extremely economic while at the same time very powerful.</p><p>The economic model change has immense implications to software design. The benefits it unleashes are:</p><ul><li>Unbelievable cost reduction</li><li>Infinite scalability</li><li>Reduction in processing times</li><li>New services can be implemented in a cost-effective way, which for some was not possible in the past.</li></ul><p>Benefiting from the above requires<strong> rearchitecting your systems</strong> to take advantage of these new capabilities. We’ve already done it in our systems, and we’ll show you how.<br>We’ll discuss the approaches and the benefits to the cost and performance.</p><p>We’ll show you how we evolved our systems using this new paradigm and achieved<strong> 10x performance gains with simultaneous 10x cost reductions</strong>.</p><h3><strong>Ownership model problems — performance, performance, performance</strong></h3><p>Just a few years ago, the computing world was based on the <strong>ownership model</strong>. To run your software, you had to <strong>purchase machines</strong> with computational power and storage, install your software on them and run it. <br>The software was tied to the available computational power and storage.</p><p>In this model, if you installed a database that you predicted will eventually need 400GB of storage (in a few years) but only needed 50GB initially, you would have purchased a machine with 400GB or more. Your machine would have been utilized in the first year by 16% (50/400). In the second year if your data went up to 120GB it would have been utilized by 30%.</p><p>By the time your machine would have gotten close to 100% utilization (probably even before when it reached about 80% utilization) you would have gone out and ordered a new, bigger machine to support the increased load.</p><p>As a consequence, the storage on that machine was <strong>never</strong> 100% utilized — on average it would have been utilized at around 40% over the life of that machine.</p><h3><strong>The leasing model solution is just a few clicks away...</strong></h3><p>In today’s world, the cloud allows one to work using a <strong>leasing model</strong>, i.e <strong>lease machines easily and quickly and return them when done.</strong> This ability to scale up and out fast, opens the door to amazing opportunities but introduces a new problem: <strong>runaway costs</strong>.</p><p>Here is a true story about how an application that initially cost us <strong>$1,500</strong> a month, <strong>ended up costing $15,000</strong> a month without us even noticing.<br>A few years ago we had a Spark application running on an <strong>on-premise</strong> cluster.<br>Over time the volume of the incoming data grew significantly and the app execution time got longer.<br>Scaling the cluster up or out in an on-premise cluster is a real hassle — you need to order new machines, physically set them up, install all relevant software, etc — this usually takes months.<br>This wasn’t a reasonable option, so we made an effort to find ways to make the application more efficient and continue to run on the same cluster. We succeeded and since the hardware stayed fixed, the application costs obviously stayed constant.</p><p>But, when we had <strong>a similar problem</strong> with another application <strong>running in the cloud</strong> on a <strong>40 machine r3.4xlarge</strong> EMR cluster on AWS, we acted differently.<br>On the cloud, it’s very easy to scale the machines up or out — all it takes is a few clicks.<br>Instead of “wasting” time on brainstorming, implementing and testing new ideas, we did what most developers would have done and simply <strong>increased the cluster size. </strong>That was the quickest and easiest choice to make. The consequences followed, slowly. <br>We increased the cluster to 45 machines and the costs went up from $1.5K to $1.7K a month — “no big deal” we thought.<br>After a few weeks, we had to increase the cluster to 60 machines and the costs went up again — to $2.4K.<br>Iteratively applying this method, our cluster grew eventually to <strong>150 machines</strong> and costs reached <strong>$15K</strong> a month — <strong>10X the initial cost!</strong></p><p>Notice how in these <strong>two examples</strong> we had <strong>the same initial problem</strong>. The difference was the setting we were operating in. One was on an owned cluster and the other one was on a cluster in the cloud. <br>The different settings caused us to take an entirely different approach solely due to psychological reasons: in the cloud, it’s easy to scale-up a cluster. In an on-prem cluster, it’s not!<br>The core difference between the 2 situations <strong>dramatically affected our judgment</strong> and the effect on the costs was resounding.</p><h3><strong>The opportunity of the short-term-rental model — cutting 90% off of costs</strong></h3><p>The best way to use the cloud is to<strong> alter your architecture</strong> to take advantage of the benefits the cloud offers.<br>The cloud lets you <strong>break down</strong> your system into <strong>functions</strong> and you can run each function on a <strong>container</strong> specifically suitable for it. <br>This in effect is a <strong>short-term-rental model</strong><em>. </em>You only use the functions when they are needed. You only pay for the functions when they are used…<br><em>You can see where we are going with this….</em></p><p>Let’s explain this with a simple analogy — a<strong> bus </strong>example:<br>In this example, we have two kinds of vehicles —<strong> </strong>a<strong> bus </strong>and a<strong> taxi</strong>. Each one is better optimized for transporting a different amount of riders. Each one costs a different amount:</p><ol><li>The bus is expensive at $200/hour and can carry 50 people. This works out to <strong>$4 per rider</strong>, if the bus is full.</li><li>The taxi is cheaper overall at $20/hour. But can only carry 4 people. It costs <strong>$5 per rider </strong>when the taxi is full.</li></ol><p>As we shall see, if we use a system that mixes buses and taxis we can reach a lower cost of ridership even though we are adding the use of taxis, which have a higher cost per rider than a bus. The overall costs still come out much lower.</p><p>The daily transportation costs come out to:</p><ul><li><strong>Bus only</strong> — <strong>$1200/day</strong> for carrying 88 people. That comes out to <strong>$13.6 per rider</strong>.</li><li><strong>Bus and Taxis</strong> — <strong>$480/day</strong> per 88 people. That works out to<strong> </strong>just <strong>$5.5 per rider.</strong></li></ul><p>The reason the mixed model is so much cheaper (a savings of<strong> $720/day, 60% cheaper</strong>) is that we use the right vehicle for the number of riders at each hour of the day. As a result, we are able to achieve much better efficiency and better costs.</p><p>This table shows an example of this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_1c0Pq2GwT32tzmFiUL04Q.png" /></figure><p>The costs over the whole day can be easily viewed in the graph below. <br>Notice the waste (in red) occurring in the bus model during most of the hours of the day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x4-XGS_qfXJL-0lMS11fHA.png" /></figure><h3>Scalability - t<strong>he most important feature of the cloud</strong></h3><p>The computing solutions that the cloud offers allow us to take advantage of the same characteristics as in the short term rental model and as we’ve seen in the bus/taxi example.<br>Let’s assume we have a service that process files. Files are being streamed to the service with varied volume throughout the day and the service has to process them.<br>In the “old world”, we probably would have set up an on-prem cluster.<br>The cluster would have contained a predetermined number of machines, based on the maximum load we would have expected to handle (or a bit less if we were willing to compromise on performance).<br>In this architecture, it’s very likely that the cluster would have been nearly idle most of the day — as in the database example above.<br><strong>However, just switching to the cloud with the same architecture wouldn’t have reduced the system’s costs. We would still have had to pay for the idle time of the machines.</strong></p><p><strong>Possible solutions</strong> that would drive the costs down in this kind of a system are:</p><ul><li><strong>Using Auto-Scale capabilities</strong> which allow us to define policies to automatically increase or decrease the number of machines in the cluster.</li><li><strong>Using serverless computing</strong> which is scalable by nature.</li><li><strong>A combination of the 2 solutions</strong>, for example: have a few machines that are constantly at high utilization by having them process a <strong>fixed</strong> and steady volume and use serverless computing to handle additional traffic spikes when they occur.</li></ul><p>Using such solutions, allows us to avoid paying for idle machines — and gets us closer to paying for computing power as needed.</p><p>The full potential of the cloud doesn’t end with mere scalability.<br>A cloud architecture can also be used to deal with<strong> outliers</strong>. Going back to the file processing service example above, we can leverage the cloud to process special cases. For example, if we mostly get files with a similar size (~50MB each), but once in a while receive an outlier — a huge file (of over 5GB).<br>In addition to the standard handling service “normal-size” files, we can have a separate service (also based on a serverless function) which will be dedicated to deal with extremely large files, and will only be invoked (and paid for) when it is needed.<br>An addition like this can make our system more flexible, predictable and cost-effective.</p><h3>Summary</h3><p>If you have read this far, we assume that you either have cloud-based systems and are concerned about their costs, or you are considering moving to the cloud (and are still concerned about the costs…).</p><p>If that is the case, you are not alone. We too had several pricey cloud-based systems and managed to dramatically reduce their costs.</p><p>By now we have done this on multiple systems we run, saving Nielsen over<strong> <br>2 million dollars a year!</strong></p><p>In most of our projects, we managed to <strong>achieve 80%-95% cost reduction </strong>while at the same time <strong>improving the latency and speed!</strong></p><p>We’ve found there is <strong>a common pattern </strong>in these projects, which can be <strong>easily reproduced</strong>.</p><p>Check out our next posts in the series to find out how you too can achieve significant system improvements and huge cost savings by applying the same techniques to your projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c334ae242ca6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>