{"id":732,"date":"2018-10-31T02:40:29","date_gmt":"2018-10-31T02:40:29","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw93\/?p=732"},"modified":"2018-10-31T02:41:17","modified_gmt":"2018-10-31T02:41:17","slug":"5-tips-for-making-containers-faster","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/10\/31\/5-tips-for-making-containers-faster\/","title":{"rendered":"5 Tips for Making Containers Faster"},"content":{"rendered":"<h5>Take a deep dive into Best Practices in Kubernetes Networking<\/h5>\n<p>From overlay networking and SSL to ingress controllers and network security policies, we&#8217;ve seen many users get hung up on Kubernetes networking challenges. In this video recording, we dive into Kubernetes networking, and discuss best practices for a wide variety of deployment options.<\/p>\n<p><a href=\"https:\/\/rancher.com\/events\/2018\/kubernetes-networking-masterclass-june-online-meetup\/\" target=\"blank\">Watch the video<\/a><\/p>\n<p>One of the selling points of containers is that containerized<br \/>\napplications are generally faster to deploy than virtual machines.<br \/>\nContainers also usually perform better. But just because containers are<br \/>\nfaster by default than alternative infrastructure doesn\u2019t mean that<br \/>\nthere are not ways to make them even faster. You can go beyond the<br \/>\ndefaults by optimizing Docker container image build time, performance<br \/>\nand resource consumption. This post explains how.<\/p>\n<h2>Defining \u201cFaster\u201d<\/h2>\n<p>Before we delve into Docker optimization tips, let me first explain what<br \/>\nI mean when I write about making containers \u201cfaster.\u201d Within the context<br \/>\nof a conversation about Docker, the word <em>faster<\/em> can have several<br \/>\nmeanings. It can refer to the execution speed of a process or an<br \/>\napplication that runs inside a container. It can refer to image build<br \/>\ntime. It can refer to the time it takes to deploy an application, or to<br \/>\npush code through the entire delivery pipeline. In this post, I\u2019ll<br \/>\nconsider all of these angles by discussing approaches to making Docker<br \/>\nfaster in multiple ways.<\/p>\n<h2>Make Docker Faster<\/h2>\n<p>The following strategies can help make Docker containers faster.<\/p>\n<h3>Take a Minimalist Approach to Images<\/h3>\n<p>The more code you have inside your image, the longer it will take to<br \/>\nbuild the image, and for users to download the image. In addition,<br \/>\ncode-heavy containers may run sub-optimally because they consume more<br \/>\nresources than required. For all of these reasons, you should strive to<br \/>\nkeep the code that goes into your container images to the bare minimum<br \/>\nthat is required for whatever your image is supposed to do. In some<br \/>\ncases, designing minimalist container images may require you to<br \/>\nrearchitect your application itself. Bloated applications will always<br \/>\nsuffer from slow deployment and weak performance, whether you deploy<br \/>\nthem in containers or in something else. You should also resist the<br \/>\ntemptation, when writing your Dockerfile, to add services or commands<br \/>\nthat are not strictly necessary. For example, if your application<br \/>\ndoesn\u2019t need an SSH server, don\u2019t include one. For another example,<br \/>\navoid running apt-get upgrade if you don\u2019t need to.<\/p>\n<h3>Use a Minimalist Operating System<\/h3>\n<p>One of the greatest benefits of containers as compared to virtual<br \/>\nmachines is that containers don\u2019t require you to duplicate an entire<br \/>\noperating system to host an application. To take advantage of this<br \/>\nfeature to greatest effect, you should host your images with an<br \/>\noperating system that does everything you need, and nothing more. Your<br \/>\noperating system shouldn\u2019t include extra services or data if they do not<br \/>\nadvance the mission of your Docker environment. Anything extra is bloat,<br \/>\nwhich will undercut the efficiency of your containers. Fortunately, you<br \/>\ndon\u2019t have to build your own minimalist operating system for Docker.<br \/>\nPlenty of pre-built Linux distributions with small footprints are<br \/>\navailable for hosting Docker, such as<br \/>\n<a href=\"http:\/\/rancher.com\/rancher-os\/\">RancherOS<\/a>.<\/p>\n<h3>Optimize Build Time<\/h3>\n<p>Image build time is often the biggest kink in your continuous delivery<br \/>\npipeline. When you have to wait a long time for your Docker images to<br \/>\nbuild, you delay your entire delivery process. One way to speed image<br \/>\nbuild time is to use registry mirrors. Mirrors make builds faster by<br \/>\nreducing the amount of time required to download components when<br \/>\nbuilding an image. Combining multiple RUN commands into a single command<br \/>\nalso improves build time for images because it reduces the number of<br \/>\nlayers in your image, which improves build speed, and optimizes the<br \/>\nimage size to boot. <a href=\"https:\/\/docs.docker.com\/engine\/userguide\/eng-image\/dockerfile_best-practices\/#build-cache\">Docker\u2019s build cache<br \/>\nfeature<\/a><br \/>\nis another useful way to improve build speed. The cache allows you to<br \/>\ntake advantage of existing cached images, rather than building each<br \/>\nimage from scratch. Finally, creating minimalist images, as discussed<br \/>\nabove, will speed build time, too. The less you have to build, the<br \/>\nfaster your builds will be.<\/p>\n<h3>Use a Containers-as-a-Service Platform<\/h3>\n<p>For staff at many organizations, the greatest obstacle to deploying<br \/>\ncontainers quickly and efficiently results from the complexity of<br \/>\nbuilding and managing a containerized environment themselves. This is<br \/>\nwhy using a Containers-as-a-Service platform, or CaaS, can be handy.<br \/>\nWith a CaaS, you get preconfigured environments, as well as deployment<br \/>\nand management tools. A CaaS helps to prevent the bottlenecks that would<br \/>\notherwise slow down a continuous delivery chain.<\/p>\n<h3>Use Resource Quotas<\/h3>\n<p>By default, each container can consume as many resources as it wants.<br \/>\nThis may not always be ideal because poorly designed or malfunctioning<br \/>\ncontainers can eat up resources, thereby making other containers run<br \/>\nslowly. To help prevent this problem, you can <a href=\"https:\/\/docs.docker.com\/engine\/admin\/resource_constraints\/\">set<br \/>\nquotas<\/a> on<br \/>\neach container\u2019s compute, memory and disk I\/O allotments. Just keep in<br \/>\nmind, of course, that misconfigured quotas can cause serious performance<br \/>\nproblems, too; you therefore need to ensure that your containers are<br \/>\nable to access the resources they require.<\/p>\n<h2>Conclusion<\/h2>\n<p>Even if your containers are already fast, you can probably make them<br \/>\nfaster. Optimizing what goes into your images, improving image build<br \/>\ntime, avoiding operating system bloat, taking advantage of CaaS and<br \/>\nsetting resource quotas are all ways to improve the overall speed and<br \/>\nefficiency of your Docker environment.<\/p>\n<p><a href=\"https:\/\/rancher.com\/5-tips-making-containers-faster\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Take a deep dive into Best Practices in Kubernetes Networking From overlay networking and SSL to ingress controllers and network security policies, we&#8217;ve seen many users get hung up on Kubernetes networking challenges. In this video recording, we dive into Kubernetes networking, and discuss best practices for a wide variety of deployment options. Watch the &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/10\/31\/5-tips-for-making-containers-faster\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;5 Tips for Making Containers Faster&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-732","post","type-post","status-publish","format-standard","hentry","category-kubernetes"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/732","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/comments?post=732"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/732\/revisions"}],"predecessor-version":[{"id":734,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/732\/revisions\/734"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/media?parent=732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/categories?post=732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/tags?post=732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}