<?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 Michael Pearce on Medium]]></title>
        <description><![CDATA[Stories by Michael Pearce on Medium]]></description>
        <link>https://medium.com/@rootofpi?source=rss-9c16786bb900------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*rnJD5hz9yJj6YBLZQMYSDA.jpeg</url>
            <title>Stories by Michael Pearce on Medium</title>
            <link>https://medium.com/@rootofpi?source=rss-9c16786bb900------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 02:34:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rootofpi/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[Demystify DevOps with Haiku]]></title>
            <link>https://rootofpi.medium.com/demystify-devops-with-haiku-231237bcad3e?source=rss-9c16786bb900------2</link>
            <guid isPermaLink="false">https://medium.com/p/231237bcad3e</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[haiku]]></category>
            <category><![CDATA[culture]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Michael Pearce]]></dc:creator>
            <pubDate>Wed, 23 Jun 2021 17:14:31 GMT</pubDate>
            <atom:updated>2021-06-23T17:14:31.722Z</atom:updated>
            <content:encoded><![CDATA[<h3>Demystify DevOps with Haikus</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z_hIDAeJjhwTgFcW" /><figcaption>Photo by <a href="https://unsplash.com/@manucosen?utm_source=medium&amp;utm_medium=referral">Manuel Cosentino</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What Is a Haiku?</h3><p>Haiku is a form of Japanese poetry made up of short lines of text following a specific <a href="https://www.dictionary.com/browse/syllable">syllable</a> structure. Although the syllable structure can vary, the most common pattern is 5–7–5. Each line of text is composed of the specified number of syllables — in this pattern line 1 has 5 syllables, line 2 has 7 syllables and line 3 has 5 syllables, totalling 17 syllables.</p><p><strong>Example</strong></p><p>line one example (5)<br>line two is a bit longer (7)<br>line three to finish (5)</p><p>Traditionally Haiku may evoke images of the natural world. The theme for todays Haiku is an aim to demystify the true aims and objectives of the DevOps model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ahTxeZ4MqqEndCHP" /><figcaption>Photo by <a href="https://unsplash.com/@marvelous?utm_source=medium&amp;utm_medium=referral">Marvin Meyer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>So What Is DevOps?</strong></h3><p>(<em>This is where the Haikus start</em>)</p><p>What is this DevOps?<br>Culture, mindset, way of life<br>Not just Dev plus Ops!</p><p><em>[Culture, philosophies &amp; practices — not just an amalgamation of team names]</em></p><p>Silos everywhere?<br>Let me give you some access<br>Now do it yourself!</p><p><em>[Autonomy, Self sufficiency, Breaking down silos]</em></p><p>Templates in code<br>Repeatable, not unique<br>Keep Version controlled</p><p><em>[Transparency, Repeatability, Collaboration — It is not repeatable if it is only in someones head!]</em></p><p>Clean, maintainable<br>automation instinctive<br>Less human error!</p><p><em>[Good practices, Rapid delivery, Stability]</em></p><p>Make it Resilient<br>Build in Reliability<br>Fail fast, fail often</p><p><em>[Innovation, Reliability &amp; Resilience — Keeping things identical (using templates) allows you to build accurate test environments. Automation, failover, auto scaling can manage failures automatically making more room for innovation early in the software development lifecycle]</em></p><h3>Summary</h3><p>I didn’t want to spoil the surprises before getting creative, but in case you are looking for more definition…</p><p>The DevOps model is a combination of philosophies and practices that help technology (most commonly, software development) teams to deliver value quicker and more effectively. It aims to enhance collaboration and communication to develop and deploy reliable software rapidly in a scaleable and secure way.</p><p><strong>Not <em>just</em> Dev + Ops.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=231237bcad3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time Management For Your Mind]]></title>
            <link>https://rootofpi.medium.com/time-management-for-your-mind-f1957728d923?source=rss-9c16786bb900------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1957728d923</guid>
            <category><![CDATA[seneca]]></category>
            <category><![CDATA[philosophy]]></category>
            <category><![CDATA[time-management]]></category>
            <category><![CDATA[7-habits]]></category>
            <category><![CDATA[meditation]]></category>
            <dc:creator><![CDATA[Michael Pearce]]></dc:creator>
            <pubDate>Sun, 19 Jul 2020 23:42:21 GMT</pubDate>
            <atom:updated>2020-07-19T23:43:44.385Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc/4.0/</cc:license>
            <content:encoded><![CDATA[<h4><strong>Bringing philosophies and meditation practices together for a greater sense of mental clarity</strong></h4><h4><strong>Putting the first things first</strong></h4><p>The 7 habits of highly effective people, coined by Steven Covey demonstrates a time management principle reminding us to focus on putting the first things first. Organize and execute around the highest priorities. Be driven by the principles you value most, not by the forces surrounding you.</p><p>See the quadrant of Important &amp; Urgent VS Unimportant &amp; Not Urgent. To make your vision a reality you should try to focus on what <em>really</em> matters, rather than the short term benefits (and potentially damaging long term effects) of procrastination. This quadrant guides us to:</p><ul><li>Manage critical issues, but be quick to delegate</li><li><strong>Focus on the things that matter, keep critical thinking and consider the macro</strong></li><li>Avoid ‘busy work’</li><li>Limit (if not outright remove) trivial and wasteful activities.</li></ul><figure><img alt="Time Management Quadrant. Important Urgent, Important Not Urgent, Not Important Urgent, Not Important Not Urgent." src="https://cdn-images-1.medium.com/max/937/1*uiUI8i57dw9fICSh6BF6iA.png" /><figcaption><strong>Putting the first things first — </strong><a href="https://www.convenenow.com/blog/developing-focus-and-how-to-put-the-first-things-first">https://www.convenenow.com/blog/developing-focus-and-how-to-put-the-first-things-first</a></figcaption></figure><h4><strong>Don’t invest too much time preparing for life</strong></h4><p>On a similar theme Seneca in his stoic ways, taught that we should refrain from investing too much time in preparing life. After all, we should treat time as a commodity as it is the least renewable of all things. Life is too short to spend worrying about the future we can’t predict or regretting the past.</p><p>However, our minds often think of the future, perhaps out of impatience; such as imagining a conversation you’ll have or worrying what you’ll do about something. We spend time reflecting on past occasions (which selected well, in the right circumstances we should), these things are often irrelevant, have little value and may even be damaging to our focus, clarity, and mental health.</p><p>The relevant and important matters can most often be considered at a later and more appropriate time, such as the time of action.</p><p>Too often we allow ourselves to be preoccupied with thoughts that don’t yet need to be considered, if at all! This clouds up the mind, taking away time and focus away from the things that <em>do</em> matter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pXzpKFAjYdFjuBl4YFyGcw.jpeg" /></figure><h4><strong>Meditation</strong></h4><p>Consider a lake; the calm stillness of the lake is placid until minor disturbances such as wind or light raindrops create ripples and distract from tranquillity. Usually, we just wait for the ripples to settle.</p><p>On the other hand, when thoughts and feelings create ripples in our mind we tend to try to force ourselves to try to get rid of them.</p><p>During guided meditation we are reminded that feelings and thoughts are okay, let them come ago, and try to avoid putting effort into resistance. One common technique is to simply note the thought for later, and let it go. <em>Now</em> <em>gently bring your thought back to the breath</em>.</p><h4><strong>Slow down, to speed up</strong></h4><p>Sometimes you have to take it slow for a while to enable yourself to go fast later on. Slow doesn’t mean lazy or indecisive but intelligently balanced emphasising the right process and choices. It can be said that it even facilitates deeper relationships.</p><p>Meditation often becomes a useful way to practice the management and cultivation of calm when initially your thoughts are not, leading to more efficient responses and more effective decisions.</p><h4>Closing Questions</h4><p>So what if we applied these time management principles and medication practices together? Perhaps we could improve our focus and concentration, foster calm and reduce stress. Maybe we would hit our deadlines early while maintaining high efficiency and quality at work, collaborating well with others as a cohesive team, and even strike a better work/life balance as a positive consequence.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1957728d923" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A whale of a time with Docker]]></title>
            <link>https://medium.com/peak-product/whale-of-a-time-with-docker-6c01c000b5b4?source=rss-9c16786bb900------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c01c000b5b4</guid>
            <category><![CDATA[peak-ai]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[intro]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Michael Pearce]]></dc:creator>
            <pubDate>Wed, 16 Oct 2019 12:29:50 GMT</pubDate>
            <atom:updated>2019-10-16T12:29:50.199Z</atom:updated>
            <content:encoded><![CDATA[<p>A quick introduction to getting started with Docker</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*LX1d1m8Tnk2O2wHxZUgrrw.png" /></figure><p>It’s time to dive into Docker! This will just be an introduction to getting started with Docker, we’ll go through the following -</p><p>🐳 Building</p><p>🐳 Tagging</p><p>🐳 Running</p><p>🐳 Testing / Debugging</p><p>🐳 Layers / Caching / Benchmarking</p><p>🐳 Use cases</p><p>🐳 Cleaning up</p><h3>Vision</h3><p>By the end of this article, we’ll be able to add a docker to our development toolset, enabling us to <em>create, deploy, run and test applications using containers.</em> This should help us enhance our workflow by introducing <em>Consistency, isolation, and speed.</em></p><p>Turning this…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/0*BBoZhhUmFPsns398" /></figure><p>Into this!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*dQ6kQebRIzTa237d" /></figure><p><strong><em>Disclaimer: No whales were harmed in the production of this article.</em></strong></p><h3>What is Docker?</h3><p>Docker allows you to containerise a working environment, insert dependencies, automate the setup, etc. You do this using structured files with standardised commands.</p><h3>What are Containers?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xioGkeXYO5KVzHHF" /></figure><p>Containers are a standardised unit of software. We package software into standardised units for development, shipment, and deployment.</p><p>One machine such as a virtual server or even your laptop may host multiple containers. Not to <a href="https://blog.docker.com/2016/03/containers-are-not-vms/">be mistaken with a ‘lightweight VM</a>’! Containers and virtual machines have similar resource isolation and allocation benefits but function differently because containers virtualize the operating system instead of hardware. Containers are more portable and efficient.</p><p><em>Reference: </em><a href="https://www.docker.com/resources/what-container"><em>https://www.docker.com/resources/what-container</em></a></p><h3>What is it good for?</h3><p>Docker is good for many things! Let’s break down a few reasons -</p><p><strong>Consistency</strong></p><p>You may have heard the phrase “it works on my machine”, by scripting the instructions for building the image we form some repeatability. if it works on my machine, it should work on yours too! Although this isn’t always that easy, we can still get issues with discontinued package versions, dependencies etc. there are some ways to aid with that which we’ll cover later on.</p><p><strong>Isolation</strong></p><p>Docker allows you to isolate your application and the packages, dependencies etc. within the container, generally unaffected by the host machine. You should be able to run your app and test it the way it will later deploy on a production server, for example. This also provides some security benefits as a side product.</p><p><strong>Automation</strong></p><p>When your app is repeatable and isolated, a well-scripted environment is a lot easier to build and run autonomously minimal configuration. This often goes hand in hand with things like CI/CD (Continuous Integration and Development).</p><p><strong>Speed</strong></p><p>I’m sure you’re getting the point here, and how the previous points come together. Docker makes it simpler for developers and engineers to quickly create containerised applications that are ready to run. Managing, testing and deploying them gets a much-welcomed speed boost with its efficiencies.</p><h3>But…</h3><p><strong>It is often still hard to repeat.</strong></p><p>From experience, I’ve had various frustrating issues rebuilding Docker images with versioning, usually of packages or libraries. I think this stems from the desire for consistency prompting one to create an environment from a particular version of the base image e.g.</p><blockquote><strong>FROM ubuntu:17.10</strong></blockquote><p>Rather than just taking what is the latest at the time of build. The issue here is that ubuntu version 17.10 has reached the end of life and been discontinued, and therefore the repositories have been closed and withdrawn. When we try to run <strong><em>apt-get update</em></strong> we cannot reach the repositories. We get 404 errors and the build fails.</p><blockquote><em>Err:8 </em><a href="http://security.ubuntu.com/ubuntu"><em>http://security.ubuntu.com/ubuntu</em></a><em> artful-security Release</em></blockquote><blockquote><em>404 Not Found [IP: 91.189.91.23 80]</em></blockquote><blockquote><em>Reading package lists…</em></blockquote><blockquote><em>E: The repository ‘http://archive.ubuntu.com/ubuntu artful Release’ does not have a Release file.</em></blockquote><p>This is done purposefully by Ubuntu, and for good reason — security. To avoid this happening so often most popular operating systems have Long Term Support (LTS) options available for download and use.</p><p>A similar issue may occur when installing particular versions of packages or system libraries. If that package version was available with a repository from particular base image (operating system version) and that base image changes (it is discontinued, for example) the version of that package may not exist. You could just get the latest version of that package, but the code changes in that package may or may not work as expected when your app is run (think breaking changes).</p><p><strong>Networking can be challenging</strong></p><p>A considerable contingent of the Docker community would say they consider networking with containers can be complex and confusing. Things like which Network Drivers I should use, Single Host or Multi-Host Networking, load balancing traffic via a proxy layer and so on.</p><p>For a single non-production container you usually don’t have to worry too much and when you’re getting started you probably won’t encounter the issues too soon, but when you do there are a few things that can help with these issues -</p><ul><li><a href="https://docs.docker.com/compose/">docker compose</a></li><li><a href="https://docs.docker.com/engine/swarm/">docker swarm</a></li><li><a href="https://kubernetes.io/">kubernetes</a></li></ul><p><strong>Upload / Download</strong></p><p>Depending on your network connection the time taken to download and upload images can be frustrating, especially when you add more packages, code, etc. and the images get bigger in size and take up more disk space. This can particularly affect things like application deployments (like in CI/CD) if it takes a long time to pull down either the base image for the build or the entire image itself. When you are building the image then pushing it back to a repository it is rare that your networks upload speed is the same as your download speed, it is almost always much slower!</p><h3>Quick Review</h3><p>Docker provides a way to run applications securely isolated in a container, packaged with all its dependencies and libraries.</p><p>A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.</p><p><em>Remember…</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*7ZBJHAQJI0N2eHRI" /></figure><h3>Build it</h3><p>Start with a Dockerfile with some simple commands and structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E11HlNO0w4nZ9OAm" /></figure><p>The name of the file is simply <strong>Dockerfile</strong>. We have some instructions — FROM, RUN, ADD, ENV, CMD.</p><p>Most are quite self-explanatory -</p><p>FROM pulls another image, to use as a base.</p><p>RUN runs a command.</p><p>ADD adds files into the image</p><p>ENV sets environment variables</p><p>CMD sets the command to run when the container is started.</p><h3>Instructions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*hqAxYdZlG6DefaLXaulhZA.png" /></figure><p><strong><em>Reference — </em></strong><a href="https://docs.docker.com/engine/reference/builder/"><strong><em>https://docs.docker.com/engine/reference/builder/</em></strong></a></p><h3>Commands</h3><p>There are graphical interfaces you can use to control docker, but as a command-line advocate we want to speed right? I’m going to provide a few useful commands you can use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*NtWw8AgWh1DAJLAKke3pNg.png" /></figure><p><strong><em>Reference — </em></strong><a href="https://docs.docker.com/engine/reference/commandline/cli/"><strong><em>https://docs.docker.com/engine/reference/commandline/cli/</em></strong></a></p><h3>Build it</h3><p>Here is an example of a simple docker build, give the image a name and using the Dockerfile from the current working directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DbUtXvr_vqItLn21" /></figure><p><strong>Result</strong></p><p>We can use the Docker images command to see the result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YyJx9tm_S4UlXCRl" /></figure><p>Note the repository name, the tag, image id, created time and size.</p><h3>Tags</h3><p>You saw the <strong>-t</strong> flag used there to identify the tag. I also mentioned <strong>ubuntu:17.10</strong> earlier too, this is an example of a tag where ubuntu is the repository and 17.10 is the tag.</p><p>‘latest’ is implied. If no tag is provided then the latest tag is added to imply that it is the latest build of that image.</p><p>We can have many versions (tags). You may give the same image multiple tags such as a version number, a date, a development status. We can also use tags in the same way to identify different versions of the image. For example I build an image and tag it <strong><em>myimage:1.0</em></strong> then make some additions but this time when I build it I tag it <strong><em>myimage:2.0</em></strong>.</p><p>The format is like this -</p><blockquote><em>&lt;Image Name&gt;:&lt;Tag&gt;</em></blockquote><p>And you can also retag at image too!</p><blockquote><strong><em>docker &lt;Image Name&gt;:&lt;Existing Tag&gt; &lt;Image Name&gt;:&lt;New Tag&gt;</em></strong></blockquote><h3>Building a base</h3><p><strong>*Insert pizza analogy here!*</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*31ItmTbVOYm3L5BZ" /></figure><p>This is a concept that often helps get around those versioning, or repeatability problems that we considered earlier.</p><p>Build a docker file with everything (but only what) you need, installing core packages etc. then push it to a repository to not be overwritten again. Most image repositories such as Dockerhub or AWS ECR have a feature to make images immutable.</p><p>Then when you create any other new images, you use your base image as the base.</p><blockquote><strong>FROM mybaseimage:stable</strong></blockquote><p>This makes the base image predictable, rather than rebuilding and getting different package and library versions etc.</p><h3>Run it</h3><p>Running the image as a container generally depends on what your image does.</p><p>It might run a script that just returns ‘hello world’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Vq4grgHsuHvn_Mjy" /></figure><p>It might be a linux based container that you can pass in a command to run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yKScGSoFqNdO7WPs" /></figure><p>You might execute a command interactively and keep it going!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/0*SzYiF31zEVV8lXAh" /></figure><p>It might be something that starts up a local webserver or proxy so that you can view the result in a web browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JgnGNdVM_zud2kBn" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A1vWT_aYKxL63kTN" /></figure><h3>Debug it</h3><p>Rarely does any script, program or application go as planned first time so key part of development is debugging. The good thing about the isolation docker provides is that running the container image locally should produce the same result as running on someone else’s machine, or even a production server of some kind.</p><p>When you run the container image locally (on your computer) you get to see the standard output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p7-K4Nmt4jbDwdW4" /></figure><p>You can also use the docker logs command to see system output, any console logging from your application etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pXD_CdLnnvALjH1z" /></figure><p>You can find similar information with the Docker inspect command. You may even choose to run the container, and execute commands interactively in the running container to investigate.</p><p>See the example below where I’ve used the <strong>docker ps</strong> command to view the running docker processes, then the <strong>docker exec</strong> command to run a bash shell in the running container. Then when I’m ‘in’ I can run Linux commands like the <strong>ls</strong> command to check all the expected files exist as part of the container image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Cy1GWf6xiOBn8VIj" /></figure><h3>Layers</h3><p>Like an onion, a docker image is made up of layers!</p><p>To answer the question, how does a Docker image work? Each image consists of a series of layers. Docker makes use of union file systems to combine these layers into a single image. Union file systems allow files and directories of separate file systems, known as branches, to be transparently overlaid, forming a single coherent file system.</p><h3>One step at a time</h3><p>Watching the build process helps us to visualise those layers as each step is run to form the final image. Luckily I already had the `rocker/r-base` image stored locally on my file system, so the first step was quick.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RwnSezhDuJQO9ux8" /></figure><h3>Inspecting the build steps</h3><p>Try not to cry while we un-peel the onion and look at the layers in the docker image. We can use the <strong>docker history</strong> command to look at the layers that made up the image. Here is a simple example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hZr5WvX1AyPFcGf6" /></figure><p>Here is quite an insightful view of the build steps for the popular python:3.6 image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SxP96C4u1stpYZpg" /></figure><h3>Caching</h3><h3>Image caching vs Layer caching</h3><p>Let us first separate the thinking between image caching and layer caching.</p><h3>Layer caching</h3><p>At each occurrence of a RUN command in the Dockerfile, Docker will create and commit a new layer to the image, which is just a set of tightly-coupled directories full of various file structures that comprise a Docker image.</p><p>During a new build, all of these file structures have to be created and written to disk — this is where Docker stores base images. Once created, the container (and subsequent new ones) will be stored in the folder in this same area.</p><p>This makes cache important. If the objects on the file system that Docker is about to produce are unchanged between builds, reusing a cache of a previous build on the host is a great time-saver. It makes building a new container really, really fast. None of those file structures have to be created and written to disk this time — the reference to them is sufficient to locate and reuse the previously built structures.</p><p>This is an order of magnitude faster than a fresh build. If you’re building many containers, this reduced build-time means getting that container into production costs less, as measured by compute time.</p><h3>Image Caching</h3><p>The caching can be done to pull down a previous version of the image, then use that instead of rebuilding it all again. If the image exists locally on the system you can use the <strong>— cache-from flag</strong> to use that image as a cached version and avoid any rebuilding or pulling etc.</p><p><strong><em>Beware: the cache-from flag will fail if the image is not found locally so you may need to put some logic in place to check.</em></strong></p><p><em>Here is the one I made earlier…</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jajs5vAhIBaLo_OF" /></figure><h3>Benchmarking</h3><h3>TLDR;</h3><p><strong><em>~50% difference in time to build images with either big long RUN commands or many small RUN commands</em></strong></p><p><strong><em>but with ~1gb size difference!*</em></strong></p><p><em>*result from a quick benchmarking experiment, using a fairly large image (~5–6GB that usually took 40+ minutes to build..</em></p><h3>Speed vs Size</h3><p>When building and image with a docker file, the more RUN, ADD and COPY commands you use, the more <em>layers</em> the image has when being created. This results in a larger image size, and longer initial build time. But it is more likely that so many of those steps will be affected by changes and will be rebuilt in subsequent builds.</p><p>However, by reducing the number of RUN commands, and grouping package install into one big command this takes less time to build (initial) and results in smaller image size. But one change to this long command would result in the whole thing being re-run when you need to change and rebuild the image.</p><p>When you using a cached Docker image (docker pull the latest first, then docker build — cache-from ..) updating a Dockerfile with many RUN commands is usually quicker because you only change one layer. Updating a Dockerfile that has one big RUN command takes longer because it only detects a difference in the command itself so re-installs all of the packages.</p><p>So what I’m getting at is that for <strong>base images (or images that generally don’t change</strong> frequently) we should use <strong>fewer RUN commands</strong>, and have more package installs, etc. together. Then we get a smaller image that is quicker to pull.</p><p>It is still worth having build caching in case of rebuilds. But be careful of chaining commands, with commands that would force a rebuild of that layer, e.g. installing packages and then cleaning up temp files are better off in separate layers.</p><p>For images that <strong>change frequently</strong> (and need to quick rebuilds) we should make sure we use build caching and use <strong>more RUN commands</strong> and keep each package/module installation to its own step/layer.</p><h3>Use Cases</h3><p>Hopefully, you’ve started considering some use cases for using Docker already. But some simplified examples for inspiration maybe -</p><p><strong><em>Running jobs on Jenkins</em></strong> (or a similar automation server), making sure that your package versions, etc. are always as you expect and not impacted by changes in the system.</p><p><strong><em>Creating and deploying visual and analytic dashboards</em>.</strong> You can interact with other services such as data warehouses from your container, you can version control your code with git so others can collaborate, and hopefully running it locally should produce the same results as when it is hosted online!</p><p><strong><em>Web applications</em> or <em>API endpoints</em></strong> are often hosted online and receive variable amounts of traffic. One of the many joys that cloud computing has brought is the ability to ‘auto-scale’ the amount of servers provisioned in and out to handle the traffic while staying cost-efficient. This, however, requires applications to be quick to deploy and repeatable.</p><h3>Taking out the trash</h3><p>When are done, we probably need to clean up! Docker images are notorious for sticking around and hogging disk space and running ports. Here are some useful commands, in order of general impact (low to high).</p><blockquote><strong><em>docker stop &lt;container id&gt;</em></strong></blockquote><blockquote><strong><em>docker rmi &lt;image id&gt;</em></strong></blockquote><blockquote><strong><em>docker system prune</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c01c000b5b4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peak-product/whale-of-a-time-with-docker-6c01c000b5b4">A whale of a time with Docker</a> was originally published in <a href="https://medium.com/peak-product">Peak</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sage Advice — Deploying Machine Learning models with Amazon SageMaker]]></title>
            <link>https://medium.com/peak-product/deploy-sagemaker-models-on-aws-adf41e1a1853?source=rss-9c16786bb900------2</link>
            <guid isPermaLink="false">https://medium.com/p/adf41e1a1853</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[sagemaker]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Michael Pearce]]></dc:creator>
            <pubDate>Thu, 15 Aug 2019 07:53:40 GMT</pubDate>
            <atom:updated>2019-11-15T11:51:28.206Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sage Advice — Deploying Machine Learning models with Amazon SageMaker</h3><figure><img alt="Intro Image: Endpoint deployment abstraction layer infrastructure" src="https://cdn-images-1.medium.com/max/1024/1*4HzLIrwUc4H7_sK3kS-NTw.png" /></figure><p>Amazon SageMaker is a powerful managed service that enables data scientists and developers to build, train, and deploy machine learning workloads at scale, and there is a growing array of modules that make up the SageMaker platform.</p><p>AWS Machine Learning competency partner, Peak don’t just build and deploy AI by hand — they script the infrastructure so that it is repeatable, autonomous and fits seamlessly into the enterprise AI System (AIS). AIS demonstrates a user friendly way to deploy and host SageMaker API endpoints, while behind the scenes automating the authentication, packaging the model, and configuring the endpoint using key services such as API Gateway, Lambda, DynamoDB, Code build, Cloud Formation as well as Amazons SDKs.</p><h3>What is SageMaker?</h3><p>Amazon SageMaker is a managed Machine Learning (ML) service that enables you to build, train and deploy ML Models on the AWS cloud. You can use off the shelf algorithms or build your own. It really does simplify and speed up the process of provisioning the infrastructure needed for ML. A few things help with this including the use of pre-baked images, off the shelf algorithms (or the simple process of selecting your own), and of course the fact that you don’t need to provision, manage or maintain the infrastructure the way you would with traditional EC2 instances.</p><p>SageMaker really is developing rapidly. When we at Peak got started with SageMaker shortly after the release at Re:Invent 2017 there are merely 5 features, now nearly 2 years later there are 15 and growing! We’ve always been able to communicate honestly with AWS giving feedback and advice as a Machine Learning competency partner, along with ours and other feedback from customers we’ve seen a wide range of enhancements and feature requests fulfilled.</p><p>All of the potential talking points considered we won’t cover all the details of SageMaker here. We will focus on deploying ML.</p><p>To help understand the concept of deploying a ML model in the cloud try thinking of the SageMaker Endpoint you create as an API — you make a call to the endpoint, probably with a set of variable parameters, the model may make some calculations etc. then return a response in the form of a json payload. The response from the endpoint can then be integrated with other external systems to help you do great things with data.</p><h3>Deploying with SageMaker</h3><h3>The Development</h3><p>Depending on where you are in your Machine Learning journey, or indeed your use case you may choose to develop your own ML model rather than an off the shelf model. The next (also optional) step is to train the model. You can save any resulting model files to S3 for later use. You then need to write the inference code to build your API endpoint, that will serve the requests made to the model. This article won’t go into the details of building and API, but to make it scalable and production ready I would personally recommend working on a robust template that you can re-use to quickly create new APIs later, and be ready to containerise it (you’ll need to build a Docker image and push it to ECR later on).</p><p>To speed up future development, as well as make it consistent and repeatable you may choose to create a ‘base’ docker image with everything (but only what) you need for each project and use that as the base for each new Dockerfile. Docker compose also comes in handy, especially for building and running locally to test before deploying.</p><p>Reference: There is some useful documentation that AWS provides detailing how SageMaker interacts with docker so that you can run your own inference code — <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-inference-code.html">https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-inference-code.html</a></p><h3>Setting up the Endpoint</h3><p>When you’re ready to expose your model to the world there will be three main steps to deploying your model with SageMaker — Configure the (SageMaker) Model, the Endpoint Configuration and configuring the Endpoint itself.</p><h3>Create the Model</h3><p>As we configure the Model in SageMaker we provide the location of the model artefacts (where applicable, remember the output from the model training that we put in S3 earlier?) and then the location of the inference code (remember how we containerised this in a Docker image and pushed it to ECR).</p><p>This might seem like a lot of work, a little laborious and likely to be error prone so in true DevOps style let’s automate that!</p><figure><img alt="Automating the build and packaging of a SageMaker model" src="https://cdn-images-1.medium.com/max/842/1*GZhOmhqcPpbmfVXPEP-FDA.png" /></figure><p>Here we see the developer writing their inference (API) code locally and pushing it to source control, in this case Github. They may also be generating model files and pushing them to S3 for storage and retrieval later.</p><p>The git commit triggers a CodeBuild project to start a job to package up the code as part of a docker image, you could include the Dockerfile as part of the developers code repository or fetch a standardised one from somewhere else.</p><p>Once that is successfully created we push it to Elastic Container Registry (ECR).</p><p>The same CodeBuild project can even be used to make SageMaker SDK calls to configure the model in SageMaker, create the endpoint configuration and create the endpoint. You may also choose to specify where the model artefacts are located in S3 as part of the SageMaker configuration steps, instead of packaging them up in the docker image.</p><h3>Create the Endpoint Configuration</h3><p>This is where we start to do a bit more dynamic configuration — the Production variants. This means firstly selecting the model that we just configured, you can even select multiple models as variants and apply weightings for A/B testing. Continue by selecting the Instance Type to use, deciding how many instances to deploy, choose whether or not to enable elastic inference, and a few other small details.</p><p>Let’s break those down a little.</p><h4>Instance types</h4><p>This is the compute instance type to use, not dissimilar to launching a regular EC2 instance. Instance types are grouped into families based on core capabilities of the host computer hardware such as compute, memory, storage, etc. Valid options can be found in the online documentation or the drop down list in the console. As of the current date the available types include t2, m4, c4, c5, p2 and p3 instance classes each of varying capacity.</p><p>The p2 and p3 instances come under the Accelerated Computing family, launched with an attached GPU by default — useful for use cases such as deep learning.</p><h4>Initial instance count</h4><p>How many instances to launch initially, unfortunately the default and minimum value is 1 so you can’t terminate all the instances in the group to save on cost. Launching more instances would be useful if you have high volumes of traffic or the instances are generally getting well utilised, increase the number of instances to spread the load.</p><h4>Elastic inference</h4><p>You may have some workloads that can benefit from the abilities of a GPU, but not require their use 24/7. Provisioning them anyway is financially inefficient, luckily AWS introduced something called Elastic Inference (EI). The EI provides acceleration when only when required, and is automatically started when the supported frameworks are being used.</p><p>Latest supported frameworks can be found in the usual documentation but as of today some include EI-enabled versions of TensorFlow and MXNet. Although using a different deep learning framework, simply export your model by using ONNX, and then import your model into MXNet — use your model with EI as an MXNet model!</p><h3>Configuring the Endpoint</h3><p>The last step in the process is to create an Endpoint in SageMaker and apply the Endpoint Configuration you just created to it. You can reconfigure your Endpoint later by creating new Endpoint Configuration and applying that to your Endpoint instead.</p><h3>Making it scale</h3><p>SageMaker does do a lot of the heavy lifting for us already, but you may have noticed there are quite a few steps involved in the processes so far. To build a platform that enables users to be autonomous and self sufficient we should probably abstract some of that away, so that they can focus on their domain knowledge (such as ML!).</p><p>Firstly we noticed that most of the input values are fairly static or implied i.e. network configuration, encryption key, variables, tags etc. Other values may be provided by the user but mapped to more understandable key/values -</p><h4>Instance type</h4><p>regular/medium/large/extra large</p><h4>Instance count</h4><p>expected traffic (low/medium/high)</p><h4>Elastic inference</h4><p>model type (regression/decision tree/KNN/deep learning)</p><h4>Autoscaling</h4><p>Set conditionally based on the instance types (T family instances aren’t compatible with SageMaker autoscaling).</p><h3>But how do we achieve this?</h3><p>Amazons Software Development Kit (SDK) is ideal for this! AWS provides an SDK for several languages such as javascript, go, python and more. We can use the SDK to help us automate the process as we saw earlier on in the article, and build that into a user friendly interface.</p><p>Below is an early example of Peaks AI System (AIS), demonstrating how easy it can be to deploy a machine learning model with SageMaker. As you can see the technical detail of the infrastructure etc. is abstracted away, so that the user can focus on their domain knowledge and quickly deploy a model. All they need to input is the locations of the inference code (API), model files (artefacts), instance count and type (size).</p><figure><img alt="early example of Peaks AI System (AIS), demonstrating how easy it can be to deploy a machine learning model with SageMaker" src="https://cdn-images-1.medium.com/max/1024/1*qTIuKkGzTq-_Qz94eCKo8g.png" /></figure><h3>Hosting the endpoint</h3><p>When you configure a model in SageMaker, create an endpoint configuration and then apply that to an endpoint we have successfully started hosting our ML model on the cloud!</p><p>There are some Pros and Cons of hosting your ML models on SageMaker in my opinion.</p><h4>Pros</h4><ul><li>Provides Scalability, High throughput, High reliability</li><li>Enables A/B Testing</li></ul><h4>Cons</h4><ul><li>Long convoluted endpoint to call with AWS service proxy or SDK (see next section on automating this abstraction layer)</li><li>Lots of moving parts</li><li>It’s expensive!</li></ul><h3>Architecture</h3><p>We can build an interesting Infrastructure stack to abstract away the moving parts and make your project production ready.</p><figure><img alt="Endpoint deployment abstraction layer infrastructure" src="https://cdn-images-1.medium.com/max/1024/1*4HzLIrwUc4H7_sK3kS-NTw.png" /></figure><p>So our favourite, most stylish AWS CTO &amp; VP Verner Vogels is looking for t-shirt recommendations ahead of the next big conference, so he makes a call to our endpoint.</p><p>Thanks to the Route53 service we are able to provide a nice (short) user friendly domain name, we can manage caching and distributed content delivery for high transfer speeds and low latency to the edge using CloudFront CDN. CloudFront also helps us protect our endpoint from Layer 7 attacks, and integrates seamlessly with AWS Shield for DDoS mitigation.</p><p>The call goes to API Gateway and triggers a Lambda.</p><p>Lambda communicates with DynamoDB and KMS to check metadata and authentication before making the SDK call to SageMaker (notice the long convoluted endpoint that we are provided with).</p><p>We use the Identity Access Management (IAM) service to configure the permissions via roles — this can allow use to do things like access specific buckets or objects in S3, communicate with different services etc.</p><p>Of course as good practice we include CloudWatch alarms to monitor performance metrics and potential errors. We can also send logs to CloudWatch and/or the ElasticSearch service as appropriate.</p><p>SageMaker crunches the numbers, does the computation, outputs a recommendation etc. using the ML model we deployed earlier, and sends it back to lambda, through API Gateway and back to the end user. This may seem like a lot of steps, but can all happen in a matter of seconds!</p><p>—</p><h3>TL;DR — Overview</h3><h3>SageMaker is…</h3><ul><li>A managed service to Build, Train, and Deploy machine learning on AWS</li><li>Moving fast!</li></ul><h3>We looked at…</h3><ul><li>Packaging your ML model</li><li>Setting up SageMaker Endpoints autonomously</li><li>With a friendly User Interface</li><li>Hosting the models on the Endpoints</li><li>Making it Production ready</li><li>Abstracting away the complicated moving parts</li></ul><p>View more articles like this in the <a href="http://www.peak.ai/hub">Peak Content Hub.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adf41e1a1853" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peak-product/deploy-sagemaker-models-on-aws-adf41e1a1853">Sage Advice — Deploying Machine Learning models with Amazon SageMaker</a> was originally published in <a href="https://medium.com/peak-product">Peak</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>