<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Resource-Limits on K-Life Hack | Systems Architecture &amp; DevOps</title><link>https://klifehack.com/en/tags/resource-limits/</link><description>Recent content in Resource-Limits on K-Life Hack | Systems Architecture &amp; DevOps</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Mon, 08 Jun 2026 10:02:31 +0900</lastBuildDate><atom:link href="https://klifehack.com/en/tags/resource-limits/index.xml" rel="self" type="application/rss+xml"/><item><title>Implementation of Resource Isolation and Migration Using Docker Compose in Multi-tenant Web Hosting</title><link>https://klifehack.com/en/p/docker-multi-tenant-resource-isolation/</link><pubDate>Mon, 08 Jun 2026 10:02:31 +0900</pubDate><guid>https://klifehack.com/en/p/docker-multi-tenant-resource-isolation/</guid><description>&lt;h1 id="improving-resource-isolation-and-operational-stability-in-multi-tenant-environments-through-docker-containerization"&gt;Improving Resource Isolation and Operational Stability in Multi-tenant Environments through Docker Containerization
&lt;/h1&gt;&lt;p&gt;In traditional single-server virtual machine (VM) environments where multiple web services share resources, the &amp;ldquo;Noisy Neighbor&amp;rdquo; problem—where a traffic spike on a specific site degrades the performance of the entire server—frequently occurs. This article describes the migration procedure to an independent Docker-based container infrastructure to eliminate this operational risk and improve service stability and visibility.&lt;/p&gt;
&lt;h2 id="challenges-of-the-traditional-environment-and-background-of-the-migration"&gt;Challenges of the Traditional Environment and Background of the Migration
&lt;/h2&gt;&lt;p&gt;In the traditional VM environment, 10 different websites were operating within a single VM. This configuration contained the following technical debt:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Single Point of Failure (SPOF) Risk&lt;/b&gt;: If CPU usage reaches 100% due to a DDoS attack or spam bot activity on one site, the remaining nine sites simultaneously suffer downtime or severe latency.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Delayed Incident Response&lt;/b&gt;: Since all sites share the same OS and process space, it was difficult to quickly identify which site was the root cause when a failure occurred.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By migrating to containerization using Docker Compose, each site is isolated as a lightweight container with physical resource limits (CPU/memory) imposed, creating a &amp;ldquo;sandbox&amp;rdquo; environment where the load of a specific site does not propagate to others.&lt;/p&gt;
&lt;h2 id="technical-implementation-steps"&gt;Technical Implementation Steps
&lt;/h2&gt;&lt;h3 id="1-docker-engine-setup"&gt;1. Docker Engine Setup
&lt;/h3&gt;&lt;p&gt;Install the Docker Engine and Compose plugin on the host system. This establishes the foundation for container orchestration.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Docker Installation for Ubuntu/Debian&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get update
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="2-preparation-of-directory-structure-and-storage"&gt;2. Preparation of Directory Structure and Storage
&lt;/h3&gt;&lt;p&gt;Construct a directory hierarchy to manage data for the proxy and each site. Here, storage mounted at &lt;code&gt;/data&lt;/code&gt; is used to ensure persistence and backup efficiency.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir -p /data/docker-web/proxy/conf.d
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir -p /data/docker-web/site1/html
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir -p /data/docker-web/site1/logs
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir -p /data/docker-web/site2/html
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir -p /data/docker-web/site2/logs
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="3-defining-resource-limits-with-docker-compose"&gt;3. Defining Resource Limits with Docker Compose
&lt;/h3&gt;&lt;p&gt;In &lt;code&gt;docker-compose.yml&lt;/code&gt;, use the &lt;code&gt;deploy.resources.limits&lt;/code&gt; attribute to prevent each container from consuming 100% of the host&amp;rsquo;s resources.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;version&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#39;3.8&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;services&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;site1&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;image&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;nginx:alpine&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;container_name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;web-site1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;volumes&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;/data/docker-web/site1/html:/usr/share/nginx/html&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;/data/docker-web/site1/logs:/var/log/nginx&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;deploy&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;resources&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;limits&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;cpus&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#39;0.50&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;memory&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;512M&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;networks&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;web-network&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;networks&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;web-network&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;driver&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;bridge&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="4-nginx-reverse-proxy-configuration"&gt;4. Nginx Reverse Proxy Configuration
&lt;/h3&gt;&lt;p&gt;Use &lt;code&gt;nginx.conf&lt;/code&gt; to route requests to the appropriate container based on &lt;code&gt;server_name&lt;/code&gt;. Within the Docker bridge network, the service name functions as the hostname.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-nginx" data-lang="nginx"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;server&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;listen&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;80&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;server_name&lt;/span&gt; &lt;span style="color:#e6db74"&gt;site1.example.com&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;location&lt;/span&gt; &lt;span style="color:#e6db74"&gt;/&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;proxy_pass&lt;/span&gt; &lt;span style="color:#e6db74"&gt;http://site1:80&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;proxy_set_header&lt;/span&gt; &lt;span style="color:#e6db74"&gt;Host&lt;/span&gt; $host;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;proxy_set_header&lt;/span&gt; &lt;span style="color:#e6db74"&gt;X-Real-IP&lt;/span&gt; $remote_addr;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="operational-verification-and-logic-of-resource-isolation"&gt;Operational Verification and Logic of Resource Isolation
&lt;/h2&gt;&lt;p&gt;Deployment is executed with the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker compose up -d
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With this configuration, even if traffic spikes on &lt;code&gt;site1&lt;/code&gt;, the container is physically restricted within the configured &lt;b&gt;0.5 CPU cores&lt;/b&gt; and &lt;b&gt;512MB RAM&lt;/b&gt;. This prevents the exhaustion of the entire host&amp;rsquo;s computational resources, allowing other services from &lt;code&gt;site2&lt;/code&gt; to &lt;code&gt;site10&lt;/code&gt; to continue operating unaffected.&lt;/p&gt;
&lt;p&gt;Additionally, since logs for each site are output separately to &lt;code&gt;/data/docker-web/siteX/logs&lt;/code&gt;, identifying the site where an anomaly occurred and performing root cause analysis is accelerated.&lt;/p&gt;
&lt;h2 id="configuration-notes"&gt;Configuration Notes
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Docker Compose V2 Specification&lt;/b&gt;: The &lt;code&gt;version&lt;/code&gt; specification is optional in the current specification, but it is retained for compatibility.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Tuning Resource Limits&lt;/b&gt;: Numerical values such as &lt;code&gt;cpus: '0.5'&lt;/code&gt; need to be adjusted based on the actual baseline load of the service. This configuration is a reference model for ensuring minimum stability in a multi-tenant environment.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Network Isolation&lt;/b&gt;: By using the &lt;code&gt;web-network&lt;/code&gt; bridge driver, direct external access is limited to going through the proxy, clarifying the security boundary.&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>