<?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 Daniel Fratte on Medium]]></title>
        <description><![CDATA[Stories by Daniel Fratte on Medium]]></description>
        <link>https://medium.com/@drfratte?source=rss-77e223cd8439------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*p7ZcxgG4QsGgY6PSRwEchw.jpeg</url>
            <title>Stories by Daniel Fratte on Medium</title>
            <link>https://medium.com/@drfratte?source=rss-77e223cd8439------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 23:47:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@drfratte/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[Understanding Your Cloud Cost Data for Better Decision Making]]></title>
            <link>https://medium.com/better-programming/understanding-your-cloud-cost-data-for-better-decision-making-f6925ec05e3d?source=rss-77e223cd8439------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6925ec05e3d</guid>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[efficiency]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cost]]></category>
            <dc:creator><![CDATA[Daniel Fratte]]></dc:creator>
            <pubDate>Wed, 21 Dec 2022 19:49:32 GMT</pubDate>
            <atom:updated>2022-12-21T19:49:32.841Z</atom:updated>
            <content:encoded><![CDATA[<h4>You can’t optimize what you can’t measure</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cageouN1Dz-O_0oM" /><figcaption>Photo by <a href="https://unsplash.com/@jeshoots?utm_source=medium&amp;utm_medium=referral">JESHOOTS.COM</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>There have been many business challenges as we transitioned out of the pandemic and approach a potential recession for the upcoming year or so. Many companies are focused on efficiency on several dimensions, one of them being costs. Beyond cost, it is critical to understand that optimizing anything requires the first stage of deep understanding of what you’re trying to make more efficient. This aligns with the <a href="https://www.finops.org/framework/phases/">lifecycle of FinOps</a>, a practice that emerges as we try to make the best of our buck in cloud computing.</p><p>The <a href="https://www.finops.org/introduction/what-is-finops/">FinOps Foundation</a> defines FinOps as <em>“an evolving cloud financial management discipline and cultural practice that enables organizations to get maximum business value by helping engineering, finance, technology, and business teams to collaborate on data-driven spending decisions.”</em></p><p>In a nutshell, we’re talking about cloud cost management or cloud economics. In most cases, long are the days in which tech, procurement, and financial teams had to (or aim to) optimally plan the purchase of hardware for powering up their digital products and services. The cloud computing industry disrupted this as we entered an era in which a click of a button and a pay-per-second model made infrastructure readily available in the blink of an eye.</p><p>One problem, though, is that the maturity needed for agile and effective management of costs in the cloud is hard to achieve. As you walk this path iteratively and incrementally, there are multiple cultural and technological challenges to address. One of them is data visibility and accountability.</p><h3><strong>Data Visibility and Accessibility</strong></h3><p>Undoubtedly you can’t optimize what you don’t have visibility of. So, I thought I could show in a few steps how I would tackle landing on a particular team to get a first impression of what the cloud financial landscape looks like.</p><p>First, a couple of disclaimers. What we are trying to achieve here is to identify cloud cost de-aggregated by another aspect, e.g., by service, and have a first impression of overall spending. I’m using AWS in this example, but the same or an analogous version of it can be achieved in other clouds.</p><p>Moreover, you also have multiple ways of achieving the same with some out-of-the-box solutions or services provided by cloud vendors themselves. Regardless of any technical solution, it is always a good methodological approach to collaborate closely with folks owning the infrastructure, i.e., platform teams, FinOps teams, etc.</p><p>If you are in a somewhat mature state and have access to the cloud account in which you run your resources, you should check the cost explorer solution of your vendor (or any other solution made available to you) and keep it handy as you deliver new functionality. They are pretty good at telling you what your spending is and allowing you to filter by many aspects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WbVBSPqFglrE_yMn" /><figcaption>AWS Cost Explorer showing EC2 costs by instance type</figcaption></figure><p>​These managed tools are not just great at showing you what your current spending is, but they are also useful for making actionable recommendations on your infrastructure. <a href="https://aws.amazon.com/compute-optimizer/">AWS Compute Optimizer</a>, <a href="https://docs.aws.amazon.com/cost-management/latest/userguide/ce-rightsizing.html">AWS Rightsizing Recommendations</a>, among others, are good examples of cloud vendor services that effectively provide these insights and tell you exactly what to do to save money.</p><p>These also apply to purchasing specific compute products, i.e., cloud vendors can analyze the utilization of their services based on historical data to suggest how much <a href="https://www.incredibuild.com/blog/whats-the-difference-between-on-demand-reserved-and-spot-instances">committed and preemptive usage</a> you could buy. These significantly reduce your cloud spending as the rate you’re charged is much lower.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c6u88y6kNceZbPght9ZKmA.png" /><figcaption>AWS Compute Optimizer recommendations for over-provisioned EC2 instances</figcaption></figure><h4><strong>A custom-made technical solution</strong></h4><p>Supposing we wanted a more tailored solution to our needs, we would still have several ways to achieve this. In this particular case, I am describing a solution that involves <a href="https://docs.aws.amazon.com/cur/latest/userguide/what-is-cur.html">Cost and Usage Reports</a> (CUR) data hosted on AWS S3 and AWS QuickSight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rmL15HdM8gZsE2Ct" /><figcaption>A simple cost intelligence solution using AWS S3 and AWS QuickSight</figcaption></figure><p>First, you must ensure that you <a href="https://docs.aws.amazon.com/cur/latest/userguide/cur-create.html">enable and create the Cost and Usage Reports</a> feature of AWS. When you do that, you get to choose the format in which you want to host the data in S3. In this case, I selected AWS QuickSight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nIXdu4lGePNIhr4a" /><figcaption>Creating an AWS S3 CUR report</figcaption></figure><p>After you’ve gone through this process, you’ll have the CUR data available in the specified S3 Bucket (it might take a day or two to be delivered). What follows is to fire up AWS QuickSight to visualize and analyze that data.</p><p><a href="https://docs.aws.amazon.com/quicksight/index.html">AWS QuickSight</a> is a business intelligence tool that allows for quick and ad-hoc analysis of your data, which fits perfectly for our purpose. The process to set it up is quite straightforward. First, you need to open up the service and make sure it has access to other relevant AWS services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oIpBANwNpYYwzTkU" /><figcaption>Enabling permissions for AWS QuickSight</figcaption></figure><p>In my case, I’ve set it up so QuickSight has access to S3 and Athena. Next, you will create a new dataset from the data hosted on S3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ptCq0edn3JjxPGqL" /><figcaption>Creating a datasource/dataset in AWS QuickSight</figcaption></figure><p>You will enter a data source name and the URI for the S3 bucket where the CUR data lives. Once you’ve created the dataset, it’ll be readily available for creating an Analysis and a Dashboard. Below is one example of an analysis in which I break down the <a href="https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/con-bill-blended-rates.html">blended cost</a> by service. You can add multiple ones like this to publish as a Dashboard later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v2I8ChBwgPBc3s5V" /><figcaption>A simple data analysis showing a blended cost / service name breakdown</figcaption></figure><p>This is the first step towards Cost Intelligence, and ultimately more advanced solutions could look like <a href="https://aws.amazon.com/blogs/aws-cloud-financial-management/a-detailed-overview-of-the-cost-intelligence-dashboard/">this</a>.</p><p><strong>Note:</strong> please be aware that you need to <a href="https://docs.aws.amazon.com/quicksight/latest/user/managing-spice-capacity.html">manage your SPICE capacity</a> accordingly as you go by working out with AWS QuickSight.</p><h3><strong>Conclusion</strong></h3><p>Cloud cost management is a discipline that emerges in the context of global uncertainty and financial optimization of IT infrastructure. There are several tools available to shed some light on this issue. Some of them are readily available, and it’s a matter of incorporating them when creating and maintaining digital products. On the other hand, cloud vendors provide a rich set of tools that can enable further analysis and investigation of your cloud usage data.</p><p>In the end, and as usual, the technology is ready to be used. More importantly, a cultural change of accountability should be encouraged across any team topology and level of a modern digital business. That, I believe, is where the challenge lies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6925ec05e3d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/understanding-your-cloud-cost-data-for-better-decision-making-f6925ec05e3d">Understanding Your Cloud Cost Data for Better Decision Making</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Last one out, turn off the lights]]></title>
            <link>https://medium.com/better-programming/last-one-out-turn-off-the-lights-9647c8b3f52d?source=rss-77e223cd8439------2</link>
            <guid isPermaLink="false">https://medium.com/p/9647c8b3f52d</guid>
            <category><![CDATA[sustainability]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Daniel Fratte]]></dc:creator>
            <pubDate>Tue, 06 Dec 2022 19:27:38 GMT</pubDate>
            <atom:updated>2022-12-12T14:16:30.131Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong><em>How to automate cloud resources provisioning for dev and test environments</em></strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RQgJV9uoTzUHkQwh" /><figcaption>Photo by <a href="https://unsplash.com/es/@cdubo?utm_source=medium&amp;utm_medium=referral">Christian Dubovan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the context of making information and cloud technology more sustainable, there is plenty of room for tooling, techniques, and principles that enable optimal usage of cloud infrastructure.</p><p>With that in mind, I was playing around with the simple idea that development and testing environments might not be needed when engineers, quality analysts, etc. are not around to use them. Thus, the name of this article got me thinking…if I’m working at my office and I’m the last one out, I’m likely instructed (logically) to turn off all lights.</p><p><strong>Why wouldn’t I turn on and off cloud environments that I’ll not be around to use during off hours or weekends?</strong></p><p>Lambda saver is a simple experiment that aims to fulfill this use case (and my internal need to understand more about the nuts and bolts of “the cloud”). It is a function that can be invoked to turn on and off development and testing environments according to a specific schedule.</p><p>The solution basically consists of creating an <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-what-is.html">AWS EventBridge</a> rule for 9.00 a.m. and 6:00 p.m. This would trigger the execution of an <a href="https://docs.aws.amazon.com/lambda/latest/dg/welcome.html">AWS Lambda</a>, which will start/stop dev and test environments accordingly based on the tags associated with those compute instances.</p><figure><img alt="Architectured diagram for lambda-saver" src="https://cdn-images-1.medium.com/max/1024/0*65Z6rBsH78Gxbaxb" /></figure><p>This solution abstracts details such as the periodicity of the event rule, the underlying infrastructure and cloud service used for hosting these environments, the initial state of those instances when the function is invoked, the technique used to identify them, the path to production and testing strategy utilized, among others that are disregarded due to the experimental nature of a proof of concept.</p><p>The lambda code itself has embedded the necessary tags through which I want to filter these environments.</p><p>In this case, these are Env=dev and Env=test. At first, I tried the lambda invocation to include the tags as part of the payload in the call, but couldn’t find a reliable way to trigger a scheduled event for a lambda invocation with such a payload. Thus, I decided to keep them within the codebase for now, even though it poses a constraint in terms of which tags you would like to filter on.</p><p>Moreover, there are other ways to achieve the same functionality. <a href="https://aws.amazon.com/premiumsupport/knowledge-center/stop-start-instance-scheduler/">AWS Instance Scheduler</a> might be a very good alternative. This also requires that the instances you are targeting are tagged, and that you define the period, schedule, among other resources.</p><p>The takeaway is that cloud inefficiency usually takes the form of small scattered issues that altogether account for a very big impact in our cloud bill (and in terms of carbon emissions as well).</p><p>You can start addressing them in a pragmatic way by analyzing your current team context and challenging your own assumptions about <strong>why you do what you do in the way you do.</strong> More on this process for detecting inefficiencies in a follow-up entry.</p><p>As usual, the code is available <a href="https://github.com/dfratte/lambda-saver">here</a> and all feedback and improvements are welcome.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9647c8b3f52d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/last-one-out-turn-off-the-lights-9647c8b3f52d">Last one out, turn off the lights</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What on Earth is embodied carbon?]]></title>
            <link>https://medium.com/@drfratte/what-on-earth-is-embodied-carbon-f4615d8c584f?source=rss-77e223cd8439------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4615d8c584f</guid>
            <category><![CDATA[sustainability]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[carbon-emissions]]></category>
            <category><![CDATA[hardware]]></category>
            <category><![CDATA[cleantech]]></category>
            <dc:creator><![CDATA[Daniel Fratte]]></dc:creator>
            <pubDate>Tue, 22 Nov 2022 17:01:26 GMT</pubDate>
            <atom:updated>2022-11-22T17:01:26.404Z</atom:updated>
            <content:encoded><![CDATA[<p>When we talk about the carbon emissions of anything it is easy to overlook one of the most important aspects of the impacts of human activity in the modern economy. <a href="https://principles.green/principles/embodied-carbon/">Embodied carbon</a> <strong>refers to the carbon that is emitted during the manufacturing, packaging, distribution, among different other stages, of certain physical products.</strong> It is also one of the Green Software Engineering principles we like to talk about and encourage across the IT industry.</p><figure><img alt="A laptop computer image" src="https://cdn-images-1.medium.com/max/1024/0*aS1oITipvw3XzFDl" /></figure><p>For example, <a href="https://www.apple.com/environment/pdf/products/notebooks/15-inch_MacBookPro_PER_may2019.pdf">the device</a> which I normally use to work and write these articles has a footprint of supposedly 350 kgCO2eq (for its entire lifecycle). As I might have mentioned previously, the unit of measurement is <a href="https://ec.europa.eu/eurostat/statistics-explained/index.php?title=Glossary:Carbon_dioxide_equivalent">kgCO2eq</a> which stands for kilograms of CO2 equivalent, aiming to measure CO2 or any equivalent <a href="https://en.wikipedia.org/wiki/Greenhouse_gas">GreenHouse gas (GHG)</a> released into the atmosphere. <strong>This unit is used both to measure embodied emissions, and also operational emissions i.e. the ones that are released by using a product/device.</strong></p><p>Some products are controversial in how their companies address this matter. We have all (probably) heard of <a href="https://en.wikipedia.org/wiki/Planned_obsolescence">programmed obsolescence</a>. There are products nowadays which have come a long way in terms of software and hardware engineering. Nonetheless, companies push for a new release every year, and consumer behaviour follows by replacing them with the same cadence. It’s hard to think of a mobile phone nowadays with a lifespan of more than 3 years. I’m arguing that if given proper use and care, that can be doubled in a best case scenario. I’ve seen 10 year old laptop computers being used for very day to day use cases, refurbished servers being used to serve traffic coming to simple websites, and repaired tablets having a perfectly usable second life after a change of battery. This holds true most of the time, unless you need very dedicated hardware/software there is absolutely no need for incurring in the endless cycle of creating new products every year, thus emitting more carbon in doing so.<strong> The hardest problem is to fight the paradox of having a state of the art technology device that can factually last for more than what marketing and social media tells us it should.</strong></p><p>I bring this up because a good rule of thumb is to <strong>extend the lifespan of computing devices as much as possible. This is known as carbon amortization.</strong> Suppose it takes 1000 kgCO2eq to build a server. If you use it adequately over a period of 4 years. You can assume that you’re emitting 250 kgCO2eq per year. Now, if you extend its lifespan by a year, then you’d be reducing emissions to 200 kgCO2eq per year. This way you’d be avoiding retiring existing, functional equipment in order to get new one, which will again come with an embodied figure itself.</p><figure><img alt="A person repairing a desktop computer" src="https://cdn-images-1.medium.com/max/1024/0*cjMgBV3jYd0ivmdJ" /></figure><p>Relying on used and refurbished hardware is also a good measure to contribute towards this principle. There is a good and healthy market for these kinds of devices and engaging in it <strong>fosters a culture of repair and reuse instead of single use products.</strong></p><p>Another typical approach for<strong> thinking of embodied carbon is when we design digital products.</strong> Say you’re part of a product team building a mobile banking application. In this particular domain and industry you would have a lot of reach, maybe international. So your user base is pretty significant. The design decisions that you make when creating your software will have an impact on the devices in which it runs. If you only target the latest operating systems, use libraries unavailable to some OS platforms, implement features without accounting for constraint of resources, etc. you’ll be contributing to the cycle of hardware purchase we are trying to avoid in the first place. Thus, by ensuring backwards compatibility with a few versions of OS platforms, and by being inclusive in terms of brand, model, device type, etc., you are already doing something aligned with this cause.</p><p>The takeaway here is that <a href="https://www.ifi.uzh.ch/dam/jcr:fa4e956e-7a53-4038-98a5-00e09e2f4303/Study_Digitalization_Climate_Protection_Summary_Oct2017.pdf">embodied emissions account for much more than their operational counterpart</a> i.e. <strong>using a device emits a tiny fraction of carbon in comparison to how much it’s emitted in its production.</strong> So as technologists but also as consumers, there are some things that we can do to influence this matter in the right direction. Business as usual can’t continue in this defining moment for human society.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4615d8c584f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Carlo: carbon-aware load balancing]]></title>
            <link>https://medium.com/@drfratte/carlo-carbon-aware-load-balancing-f02982999b75?source=rss-77e223cd8439------2</link>
            <guid isPermaLink="false">https://medium.com/p/f02982999b75</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[sustainability]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Daniel Fratte]]></dc:creator>
            <pubDate>Mon, 17 Oct 2022 08:53:21 GMT</pubDate>
            <atom:updated>2022-10-18T08:29:48.146Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://principles.green/principles/demand-shaping/#heading-carbon-aware-vs.-carbon-efficient">Carbon awareness</a> is an emergent concept gaining traction in the tech community. It is one of those concepts that sits at the convergence of Sustainability and Information Technology. This convergence is being referred to as <a href="https://principles.green/">Green Tech</a> or Sustainable Tech, and it provides a model as to how technology can develop a more environmentally sustainable approach to meeting business needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-BM6KgnS8fJ-zyJwRvVRlw.png" /><figcaption>Sustainability and IT intersection</figcaption></figure><p>One of the fundamental components of modern distributed architectures is a <a href="https://en.wikipedia.org/wiki/Load_balancing_(computing)">load balancer</a>. A load balancer is <strong>a layer of software + hardware that sits in front of a pool of servers</strong>. Its main use case is to efficiently distribute incoming client requests to available backend servers. To do so, it executes different types of algorithms to determine which server should serve which request next.</p><p>In the basic diagram below, you can see how client requests arrive at the load balancer and how it acts as a proxy to nodes sitting behind which will ultimately handle those requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GBu7ix4qaNRQI5oq" /><figcaption>Fundamental load balancer architecture</figcaption></figure><p>Under the hood, the load balancer runs an algorithm to determine which is going to be the next available server to which it should forward a request. One of the most commonly known is <a href="https://en.wikipedia.org/wiki/Round-robin_scheduling">round robin</a>, a technique where the load balancer will route requests to each server sequentially and then loop back to the first server.</p><p>The premise for this work is that <strong>replacing such a load balancing algorithm could be a starting point for developing a carbon-aware approach to routing traffic. </strong>Instead of determining server availability using round robin, <em>carlo</em> would rely on an external service to determine the carbon intensity of the different regions hosting available servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kxLau9phyC4-RPUx" /><figcaption>Carbon-aware approach for load balancing</figcaption></figure><p>This way, the load balancer can select the server with the lowest <a href="https://principles.green/principles/carbon-intensity/">carbon intensity</a> i.e. the region which is using the greenest electricity to power their cloud servers.</p><p><em>Carlo</em> is a reference implementation for achieving this use case. It’s built in an experimentally naive way, abstracting away complex networking and cloud implementation details to allow for a main goal: <strong>understanding the concept of carbon-awareness in this particular niche of distributed computing</strong>.</p><p>It relies on the simplicity of <a href="https://go.dev/">Go</a> language for its implementation and uses the <a href="https://pkg.go.dev/net/http#pkg-overview">net/http</a> package to simulate load balancing while running the code locally. If you start from <em>main.go</em> you will see that it defines <strong>three different regions that will be initialized with an arbitrary number of servers running on them.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xmvmuwGc9sY1Lttt" /><figcaption>Initial setup for carlo</figcaption></figure><p><strong>Architecture</strong></p><p>Both the <em>region</em> and the <em>server</em> are part of the domain of this problem, and the relationship between them has been modeled as a region hosting <strong>N</strong> number of available servers running on it. In terms of Go language constructs, it defines a <em>server</em> interface that is implemented by a type <em>backend</em>. Moreover, the <em>region</em> represents yet another type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B0uWNU_iX8bDSg7wV58y8g.png" /><figcaption>Main types</figcaption></figure><p><em>Latency</em> and <em>carbon intensity</em> are the main aspects to implement a carbon awareness algorithm. This naive algorithm approaches the task of selecting the optimal server as follows: <strong>it retrieves all available regions and chooses the one with the lowest carbon intensity.</strong> In real life this is what supposedly could be consumed from an external service, in the context of this experiment it is just a randomly generated <em>int</em><strong>. Once <em>carlo</em> selects the region with the lowest carbon intensity, latency becomes the most important aspect, and the application chooses the server with the smallest latency in that particular region</strong>. Latency is also implemented as a randomly generated number.</p><pre><strong>search</strong> lowest carbon intensity (LCI) region from available regions<br><strong>search</strong> smallest latency server (SLS) from the LCI<br><strong>forward</strong> request to SLS</pre><p>Since I am running this simulated distributed environment locally on my laptop, I needed a way to deploy different instances of this <em>server</em> interface implementation. For that, <em>carlo</em> relies on the <a href="https://pkg.go.dev/net/http#ServeMux">HTTP server multiplexer type</a> that allows it to run multiple HTTP servers at the same time on different ports. Each local server is analogous to a cloud server deployed in a region.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KFSw_RjnLOF9DkyY5iaaJA.png" /><figcaption>Main function</figcaption></figure><p>After servers are initialized and assigned a specific region, the load balancer itself starts with the appropriate handler to forward requests to the different servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ykdbhmH6VVccFuQSJjz2BA.png" /><figcaption>Load balancer initialization</figcaption></figure><p>The code is available<a href="https://github.com/dfratte/carlo"> here</a> where you can find more information and provide feedback on the design decisions made for this project. The result of executing this application turns out to be a simple representation of what real load balancing could look like.</p><p>If I start it up, I’ll see first a message that the load balancer is listening on <a href="http://localhost:8000/">http://localhost:8000</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*s6U1wrE2OD3w2KK2n54hXw.png" /><figcaption>Starting the application</figcaption></figure><p>Everytime that I hit that URL with curl, the load balancer will execute its intended carbon-aware algorithm and forward the request to the optimal server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/0*mE8FTda-dXxuyvVp" /><figcaption>Carbon-aware server response</figcaption></figure><p>In the terminal tab running the load balancer, I will also get some output regarding the current state of regional carbon intensity and server latency. Thus, you can verify the choices the algorithm makes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aP67FogiQ9qyGin2pzCkOQ.png" /><figcaption>Console output for selecting lowest carbon intensity</figcaption></figure><p>If you hit it again, you are going to get different (random) results, accounting for the changing nature of varying carbon intensity in real world electricity grids powering data centers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EbwM67vhx9ajT_Ee_VFExw.png" /><figcaption>Console output for selecting lowest carbon intensity, and latency</figcaption></figure><p>In this last case, the lowest carbon intensity region has two available servers, therefore <em>carlo</em> will select the one with the smallest latency, and you’ll get the same response in the client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/0*myvuyf4CLXWQPKB9" /><figcaption>Carbon-aware response in client</figcaption></figure><p><strong>Assumptions and trade-offs</strong></p><p>Like I mentioned before, the intended goal is <strong>to bring a better understanding of carbon-awareness to the tech industry</strong>. That being said, there are some considerations to take into account.</p><p>Load balancing usually takes place among nodes within the same region, but different availability zones. I’m abstracting away from this aspect, but it is clearly a challenge. On top of that, regional carbon intensity varies more widely between country states, and significantly less within them. Therefore, one could make an argument that it’d be quite challenging to be carbon aware in this space with such limitations.</p><p>The algorithm can definitely be further improved. For example, responses from a carbon intensity API could be cached given that regional intensity might not change too frequently.</p><p>It could also be the case that the lowest carbon intensity region selected might have the least available servers to cope with current load. This is something to iterate upon as it’s a clear trade-off between sustainability as an architectural characteristic and server availability.</p><p>Moreover, relying on external services adds another layer and dependency to a software/hardware component that usually has a very demanding requirement in terms of availability and responsiveness. This is certainly an aspect to consider, regardless of how carbon awareness is implemented in distributed load balancing systems.</p><p>On a personal level, I am not an expert in Go language (heads up for some smells), but its simplicity allows me to understand and hopefully make people understand how the concept of carbon awareness and load balancing could be explored in the future.</p><p><strong>Conclusion</strong></p><p>Carbon awareness is critical for software intensive systems to tackle the growing energy consumption of IT infrastructure. There are multiple aspects to address carbon accountability in modern tech teams, like Chris Ford and I describe in our <a href="https://www.thoughtworks.com/insights/blog/sustainability/green-team-topologies">Green Team Topologies article</a>.</p><p>Particularly, in the tech space it is not trivial how to solve some of these questions. However, I personally hope that this baseline implementation aids in shaking some ideas out of the community: both in building technically on top of it, but also in highlighting the importance of advocacy in the IT industry.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f02982999b75" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>