<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Low End Box &#187; Tuning</title>
	<atom:link href="http://www.lowendbox.com/category/tuning/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lowendbox.com</link>
	<description>Hosting Websites on Bare Minimum VPS/Dedicated Servers</description>
	<lastBuildDate>Wed, 08 Feb 2012 08:33:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Tell Your OpenVZ VPS is Swapping</title>
		<link>http://www.lowendbox.com/blog/how-to-tell-your-openvz-vps-is-swapping/</link>
		<comments>http://www.lowendbox.com/blog/how-to-tell-your-openvz-vps-is-swapping/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 07:02:07 +0000</pubDate>
		<dc:creator>LowEndAdmin</dc:creator>
				<category><![CDATA[Tuning]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[openvz]]></category>

		<guid isPermaLink="false">http://www.lowendbox.com/?p=1450</guid>
		<description><![CDATA[So you think your OpenVZ VPS really has &#8220;guaranteed memory&#8221;? Well. Not quite. I have got an OpenVZ VPS from one of the providers listed here &#8212; 256MB guaranteed and 512MB burstable memory. When I run free it shows $ free -m total used free shared buffers cached Mem: 512 65 446 0 0 0 [...]]]></description>
			<content:encoded><![CDATA[<p>So you think your OpenVZ VPS really has &#8220;guaranteed memory&#8221;? Well. Not quite. I have got an OpenVZ VPS from one of the providers listed here &#8212; 256MB guaranteed and 512MB burstable memory. When I run <code>free</code> it shows</p>
<pre class="code">
$ <b>free -m</b>
             total       used       free     shared    buffers     cached
Mem:           512         65        446          0          0          0
-/+ buffers/cache:         65        446
Swap:            0          0          0
</pre>
<p>So &#8212; 512MB total memory and 0 swap? After all I am only using 65MB of memory so well below my &#8220;guaranteed&#8221; amount. Zero swap because it is just how OpenVZ does its memory account. But is it <em>really</em> the case that all my processes reside in physical RAM?</p>
<p>Let&#8217;s dig out the good ol&#8217; user_beancounters.</p>
<pre class="code">
$ <b>sudo cat /proc/user_beancounters | grep -E '(uid|physpages|oomguarpages)'</b>
uid  resource              held       maxheld       barrier         limit       failcnt
     physpages             <em>6662</em>         11570             0    2147483647             0
     oomguarpages          <em>8085</em>         12750         65536    2147483647             0
</pre>
<p>I am trying to highlight the &#8220;<a href="http://wiki.openvz.org/Physpages">physpages</a>&#8221; and &#8220;<a href="http://wiki.openvz.org/Oomguarpages">oomguarpages</a>&#8221; amount. According to OpenVZ Wiki:</p>
<blockquote>
<p><b>physpages</b></p>
<p>Total number of RAM pages used by processes in this container.</p>
<p><b>oomguarpages</b></p>
<p>oomguarpages parameter accounts the total amount of memory and swap space used by the processes of a particular container.</p>
</blockquote>
<p>Sounds like one is the total number of physical pages used by the container, and the other one is the total number of pages (physical + swap) used by the container. That means when you take <b>oomguarpages &#8211; physpages</b> you get &#8212; the number of swapped pages from processes in this container! Now back to my UBC readouts, I have</p>
<p>(8085 &#8211; 6662) * 4096 / 1024 / 1024 = <b>5.56MB</b>!</p>
<p>out of 31.58MB (8,085 pages) that has been swapped out. And the 65MB figure returned by &#8220;free&#8221; is merely how much my processes have been allocating &#8212; so only 1/2 are actually used, and 18% of that is already swapped out.</p>
<p>So, has your low end provider been overselling the memory and caused your pages to swap out?</p>
<div style="display:none">38.107.179.230</div><hr/><div>Copyright &copy; <a href="http://www.lowendbox.com/">LowEndBox.com</a>. All Rights Reserved.</div>]]></content:encoded>
			<wfw:commentRss>http://www.lowendbox.com/blog/how-to-tell-your-openvz-vps-is-swapping/feed/</wfw:commentRss>
		<slash:comments>93</slash:comments>
		</item>
		<item>
		<title>Running Trac + Git Hosting on a Low End VPS</title>
		<link>http://www.lowendbox.com/blog/running-trac-git-hosting-on-a-low-end-vps/</link>
		<comments>http://www.lowendbox.com/blog/running-trac-git-hosting-on-a-low-end-vps/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 02:59:00 +0000</pubDate>
		<dc:creator>LowEndAdmin</dc:creator>
				<category><![CDATA[Tuning]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[trac]]></category>

		<guid isPermaLink="false">http://www.lowendbox.com/?p=1256</guid>
		<description><![CDATA[Any user of Version Control System? When I started as a programmer back in the 90&#8242;s it was RCS. Then moved to CVS when I joined my first start up. About 5 years ago I moved everything &#8212; work projects and personal projects &#8212; to Subversion. And these days I use Git for my personal [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lowendbox.com/media/pix/trac-logo.png" alt="Trac" style="margin:0 1ex 1ex 0;float:left;"/> Any user of Version Control System? When I started as a programmer back in the 90&#8242;s it was RCS. Then moved to CVS when I joined my first start up. About 5 years ago I moved everything &#8212; work projects and personal projects &#8212; to Subversion. And these days I use Git for my personal projects. While I <em>could</em> pay someone (<a href="http://github.com/">GitHub</a> for example, or <a href="http://repositoryhosting.com/">RepositoryHosting</a> which is quite cheap for unlimited repositories), for a peace of mind I would rather host the shared central repositories myself and organise my own backups.</p>
<p>At the same time I would like to have a bug/enhancement tracking system to track and to prioritize my work. A wiki for documentation would be a bonus (if I ever have time to write docos). <a href="http://trac.edgewall.org/">Trac</a> fits the bill. I know there is also <a href="http://www.redmine.org/issues/6249">RedMine</a> but I am a Python developer it&#8217;s just easier for me to write plugins for Trac.</p>
<p>This will (hopefully) be a step-by-step guide to install both Git and Trac 0.12 on a Ubuntu 10.04 system. I used my <a href="http://www.lowendbox.com/blog/rackvm-6-gbpyear-128mb-openvz-vps-in-uk-exclusive-offer/">6 pound/year RackVM VPS in UK</a> to write this HOWTO. 256MB burstable memory is more than enough.</p>
<p>Do note that <b>this is not a tutorial on how to use git</b> or any other distributed version control system. See <a href="http://git-scm.com/">Git&#8217;s website</a> if you wish to learn more about it.</p>
<p><span id="more-1256"></span></p>
<h3>1. Setting up a Low End Box</h3>
<p>To get the basics running,</p>
<ol>
<li>Get an empty VPS, but feel free to use one that is already deployed for something else &#8212; in this case feel free to skip this method and just make sure Nginx is installed.</li>
<li>Refer to <a href="http://www.lowendbox.com/blog/wordpress-cheap-vps-lowendscript/">the lowendscript article</a> to set up a low end VPS with Exim4 and Nginx running.</li>
</ol>
<pre class="code">
# <b>wget http://github.com/lowendbox/lowendscript/raw/master/setup-debian.sh</b>
...
# <b>bash setup-debian.sh system</b>
...
# <b>bash setup-debian.sh exim4</b>
...
# <b>bash setup-debian.sh nginx</b>
...
</pre>
<h3>2. Install Git and Set up Master Repository</h3>
<p>Make sure git is installed. We are also creating a git user under <code>/home/git</code> as the home of all repositories.</p>
<pre class="code">
# <b>apt-get install -y git-core</b>
...
# <b>useradd -m -K UMASK=027 git</b>
</pre>
<p>Now you have a &#8220;git&#8221; user. You could set it up with <code>git-shell</code> as restricted login shell (which also needs to be added to <code>/etc/shells</code>), however I found it&#8217;s too restrictive, especially when I also want to be able to copy the repositories around with scp. You will also need to decide how to authenticate it &#8212; with password or with pubkeys so you can log in to push/pull the git repositories in there.</p>
<p>For example I want to create copy my lowendscript repository there. I will do this on my home computer (assuming running Linux).</p>
<pre class="code">
$ <b>cd ~/proj/lowendscript</b>
$ <b>git clone --bare . /tmp/lowendscript.git</b>
$ <b>scp -r /tmp/lowendscript.git git@my-gitbox:</b>
$ <b>git remote add origin git@my-gitbox:lowendscript.git</b>
</pre>
<p>Replace &#8220;my-gitbox&#8221; with the hostname of your VPS. <code>scp</code> would only work <em>after</em> you have set up authentication for user &#8220;git&#8221; (password or pubkey).</p>
<p>You should now be able to push/pull from the central shared repository.</p>
<h3>3. Install Trac</h3>
<p>Ubuntu 10.04 LTS only comes with Trac 0.11 but I <em>really</em> wanted to use Trac 0.12 because of better multi-repositories support. So instead of <code>apt-get install trac</code>, we are going the long way and downloading and installing it manually. The <a href="http://trac.edgewall.org/wiki/TracInstall">Trac installation guide</a> is a good reference, as well as <a href="http://trac-hacks.org/wiki/GitPlugin">Git plugin for Trac</a>.</p>
<p>Let&#8217;s get some Python dependencies installed first, and then use <code>easy_install</code> to install Trac and Git plugin. Note that Genshi 0.6 is required for Trac so we won&#8217;t be using the 0.5 from Ubuntu repo.</p>
<pre class="code">
# <b>apt-get install python python-setuptools python-pygments python-tz subversion</b>
...
# <b>easy_install Trac</b>
...
# <b>easy_install http://trac-hacks.org/svn/gitplugin/0.12</b>
...
</pre>
<p>I will now create a trac user to run the standalone instance, and initialize our first Trac project. Note that I am adding user trac into git group so it can have read access to the git repositories.</p>
<pre class="code">
# <b>useradd -m -K UMASK=077 -G git trac</b>
# <b>sudo -u trac trac-admin ~trac/project initenv</b>
...
</pre>
<p>Just put in your new project&#8217;s name (that can be changed later), and use the default for the rest. Done! You have a Trac project created, and it&#8217;s time to get the Trac standalone server up and running.</p>
<pre class="code">
# <b>sudo -u trac tracd -s -p 8000 --pidfile ~trac/project/tracd.pid -d ~trac/project</b>
</pre>
<p>You should be able to connect to port 8000 on your VPS via your browser to see it up and running. <em>However</em>, a plain vanilla Trac installation is not very useful. We need to get authentication working first so you can administer your Trac install from its web interface. You can find more info on setting up authentication for Trac standalone server <a href="http://trac.edgewall.org/wiki/TracStandalone#UsingAuthentication">here</a>. Need to get apache2-utils installed first so we can use htpasswd.</p>
<p>I&#8217;ll also create a &#8220;lowendadmin&#8221; user with password &#8220;12345&#8243;.</p>
<pre class="code">
# <b>apt-get install apache2-utils</b>
...
# <b>sudo -u trac htpasswd -bc ~trac/project/htpasswd lowendadmin 12345</b>
Adding password for user lowendadmin
</pre>
<p>We will also need to grant <a href="http://trac.edgewall.org/wiki/WebAdmin">WebAdmin</a> permission to the user &#8220;lowendadmin&#8221;. Now restart Trac to use the <b>htpasswd</b> file we have just created.</p>
<pre class="code">
# <b>[ -e ~trac/project/tracd.pid ] &amp;&amp; kill `cat ~trac/project/tracd.pid`</b>
# <b>sudo -u trac trac-admin ~trac/project permission add lowendadmin TRAC_ADMIN</b>
# <b>sudo -u trac tracd -s -p 8000 --pidfile ~trac/project/tracd.pid -d --basic-auth="*,/home/trac/project/htpasswd,Project" ~trac/project</b>
</pre>
<p>When you log back into Trac (port 8000 on your VPS), you should be able to see a &#8220;Login&#8221; link. Click on that to bring out the HTTP Basic Authentication dialog box that prompts for username/password. Once authenticated, you&#8217;ll be back at Trac with &#8220;Admin&#8221; link at the top navigation bar.</p>
<h3>4. Adding Git Repository to Trac</h3>
<p>Once you have Admin enabled on Trac, it can be all GUI work from now. First you need to enable GitPlugin for Trac.</p>
<ol>
<li>Click on &#8220;Admin&#8221; at top right.</li>
<li>Click on &#8220;Plugins&#8221; on the left navigation menu, under &#8220;General&#8221;</li>
<li>Click on &#8220;TracGit&#8221; in the middle of the page, enable &#8220;GitConnector&#8221; and Save Change</li>
</ol>
<p>Next, you need to add your repositories using the Admin interface.</p>
<ol>
<li>Click on &#8220;Repositories&#8221; on the left navigation menu, under &#8220;Version Control&#8221;</li>
<li>In my lowendscript example, I put
<ul>
<li>Name=<b>lowendscript</b></li>
<li>Type=<b>git</b></li>
<li>Directory=<b>/home/git/lowendscript.git</b></li>
</ul>
</li>
<li>Click on Add! And you should now be able to browse your source under &#8220;Browse&#8221;</li>
</ol>
<p>That&#8217;s pretty much it for Trac. It would be a good idea to put that long <code>tracd</code> command in /etc/rc.local so it starts everytime you reboot the VPS.</p>
<h3>5. SSL + Proxy via Nginx</h3>
<p>Now, you do want your latest source code browser + bug tracking system behind SSL, right? I found the easiest way to do it is by putting a Nginx proxy in front. Since we already have Nginx installed in step 1, we just need to</p>
<ul>
<li>Get a SSL certificate.</li>
<li>Add Nginx configuration to do the proxy.</li>
</ul>
<p>For &#8220;free&#8221; SSL certificates, I use <a href="http://www.startssl.com/">StartSSL</a>, which works for most modern browsers. However to make it simple, I am going to use self-signed certificate in this tutorial.</p>
<pre class="code">
# <b>openssl genrsa -out /etc/nginx/ssl.key 1024</b>
Generating RSA private key, 1024 bit long modulus
..............................................++++++
........................................++++++
e is 65537 (0x10001)
# <b>openssl req -new -key /etc/nginx/ssl.key -out /tmp/ssl.csr</b>
...
Country Name (2 letter code) [US]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:my-gitbox
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
# <b>openssl x509 -req -days 365 -in /tmp/ssl.csr -signkey /etc/nginx/ssl.key -out /etc/nginx/ssl.crt</b>
Signature ok
subject=/C=US/ST=Some-State/O=Internet Widgits Pty Ltd/CN=my-gitbox
Getting Private key
# <b>rm -f /tmp/ssl.csr</b>
</pre>
<p>Done. Your self signed SSL key and certificate are now installed. Time to get Nginx to use it. Save the following file to <code>/etc/nginx/sites-enabled/my-gitbox.conf</code>:</p>
<pre class="code">
server {
    server_name _;
    listen 443;
    ssl on;
    ssl_certificate /etc/nginx/ssl.crt;
    ssl_certificate_key /etc/nginx/ssl.key;

    location / {
        proxy_pass http://localhost:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
    location /trac/chrome/site {
        rewrite /trac/chrome/site/(.*) /htdocs/$1 break;
        root    /home/trac/project;
    }
}
</pre>
<p>Restart Nginx, and now browse to your VPS&#8217;s HTTPS port. You&#8217;ll see Trac in its SSL glory (well, after bypass the browser&#8217;s security check at least).</p>
<p>Trac also happens to have pretty good Wiki engine, and it has heaps of plugins for customization. With a bit of optimization (most notably <a href="http://www.lowendbox.com/blog/reduce-stack-limit-for-multi-thread-apps/">reducing the stack size</a> for multi-threaded tracd), you should be able to run the entire stack with less than 80MB on an OpenVZ VPS (and much less on a Xen).</p>
<p>Now with code repository, bug tracking system and documentation wiki ready, I better get back to do more coding :)</p>
<div style="display:none">38.107.179.230</div><hr/><div>Copyright &copy; <a href="http://www.lowendbox.com/">LowEndBox.com</a>. All Rights Reserved.</div>]]></content:encoded>
			<wfw:commentRss>http://www.lowendbox.com/blog/running-trac-git-hosting-on-a-low-end-vps/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>Bootstraping WordPress/Nginx/PHP/MySQL on a Cheap VPS with lowendscript</title>
		<link>http://www.lowendbox.com/blog/wordpress-cheap-vps-lowendscript/</link>
		<comments>http://www.lowendbox.com/blog/wordpress-cheap-vps-lowendscript/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 01:07:02 +0000</pubDate>
		<dc:creator>LowEndAdmin</dc:creator>
				<category><![CDATA[Tuning]]></category>
		<category><![CDATA[lowendscript]]></category>

		<guid isPermaLink="false">http://www.lowendbox.com/?p=1101</guid>
		<description><![CDATA[One constantly posted question on LowEndBox and LowEndTalk is &#8212; how to get the same setup as LowEndBox, a WordPress site that runs on cheap VPS with 80MB of memory? Instead of doing a step-by-step explanation (damn I hate writing long blog posts), I decided to wrap it into a bash script that does it [...]]]></description>
			<content:encoded><![CDATA[<p>One constantly posted question on LowEndBox and <a href="http://www.lowendtalk.com/">LowEndTalk</a> is &#8212; how to get the same setup as LowEndBox, a WordPress site that runs on cheap VPS with 80MB of memory? Instead of doing a step-by-step explanation (<em>damn I hate writing long blog posts</em>), I decided to wrap it into a bash script that <em>does it all</em>.</p>
<table align="center" cellpadding="0" cellspacing="10">
<tr valign="top">
<td><img src="http://www.lowendbox.com/media/pix/nginx.png" alt="Nginx"/></td>
<td><img src="http://www.lowendbox.com/media/pix/php.png" alt="PHP"/></td>
</tr>
<tr valign="top">
<td><img src="http://www.lowendbox.com/media/pix/wordpress.png" alt="WordPress"/></td>
<td><img src="http://www.lowendbox.com/media/pix/mysql.png" alt="MySQL"/></td>
</tr>
</table>
<p>It is based on <a href="http://www.lowendbox.com/blog/bootstraping-low-end-vps-with-pre-built-scripts/">my previous script here</a>, and it has been tested on both Debian 5 &#8220;Lenny&#8221; and Ubuntu 10.04 &#8220;Lucid Lynx&#8221;. Sorry no other distributions are supported. It is currently <a href="http://github.com/lowendbox/lowendscript">hosted at github</a> so feel free to branch it and tune it to your heart&#8217;s desire.</p>
<p><span id="more-1101"></span></p>
<h3>Usage</h3>
<p>Here is a quick step by step on how to set up a WordPress blog running on Nginx, PHP/FastCGI and MySQL on a low end box. Let&#8217;s assume that you are going to set up a blog on hostname &#8220;<tt>blog.example.com</tt>&#8220;.</p>
<ol>
<li>
<p>Go and buy a <a href="http://www.lowendbox.com/">cheap VPS</a>. Yes, you know where to find cheap virtual servers under $7/month, don&#8217;t you? :) I am using my <a href="http://www.lowendbox.com/blog/rackvm-6-gbpyear-128mb-openvz-vps-in-uk-exclusive-offer/">6 pound/year RackVM VPS with 128MB memory</a> to test this script, and the performance turns out to be quite good. YMMV.</p>
<p>Make sure it is either a Debian or a Ubuntu distro though.</p>
</li>
<li>
<p>After gaining root access to your VPS,</p>
<pre class="code">
# <b>wget --no-check-certificate https://github.com/lowendbox/lowendscript/raw/master/setup-debian.sh</b>
...
# <b>bash setup-debian.sh system</b>
...
# <b>bash setup-debian.sh exim4</b>
...
# <b>bash setup-debian.sh nginx</b>
...
# <b>bash setup-debian.sh mysql</b>
...
# <b>bash setup-debian.sh php</b>
...
# <b>bash setup-debian.sh wordpress blog.example.com</b>
...
</pre>
</li>
<li>
<p>Now altering your DNS entry to point <code>blog.example.com</code> to your new VPS (or alter your local <code>/etc/hosts</code> entry). Navigate to it from your browser, and you should be presented with WordPress set up page. Fill in your blog&#8217;s name, admin&#8217;s password and contact email, and your new WordPress is online!</p>
<p>Just repeat the last step (running <code>bash setup-debian.sh wordpress <em>&lt;hostname&gt;</em></code>) to set up more blogs on the same box.</p>
</li>
</ol>
<p>That&#8217;s it!</p>
<h3>Software Stack</h3>
<p>It&#8217;s pretty similar to my own stack that runs LowEndBox.com.</p>
<ul>
<li><a href="http://matt.ucc.asn.au/dropbear/dropbear.html">dropbear</a> to replace openssh. Invoked from xinetd.</li>
<li><a href="http://packages.debian.org/inetutils-syslogd">inetutils-syslogd</a> to replace rsyslog.</li>
<li><a href="http://www.exim.org/">exim4</a> to replace sendmail (if installed). Re-configured to allow Internet delivery.</li>
<li><a href="http://packages.debian.org/cron">cron</a></li>
<li><a href="http://nginx.net/">nginx</a></li>
<li><a href="http://www.mysql.com/">mysql</a>. Re-configured to remove innodb support, remove query cache and reduce key buffer size.</li>
<li><a href="http://php.net/">php</a> with built-in FastCGI interface. Running only 1 child process and respawn after 5,000 requests.</li>
</ul>
<p>The lowendscript is also</p>
<ul>
<li>Removing some commonly bundled applications that should not be there in the first place for a minimal distro (apache2, sendmail, bind9, samba, nscd, etc).</li>
<li>MySQL root is given a new password (which can be found in <code>~root/.my.cnf</code>)</li>
<li>Installing each WordPress site under /var/www/<em>&lt;hostname&gt;</em>. It will create appropriate database, users and password for the site.</li>
</ul>
<p>I have to say that it is still &#8220;work in progress&#8221;, but if you want to figure out the internals please check the source code of that bash script.</p>
<h3>Memory Usage</h3>
<p>I am testing the same script on the following 3 systems:</p>
<ul>
<li>Ubuntu 10.04 64bit (RackVM)</li>
<li>Debian 5 64bit (RackVM)</li>
<li>Debian 5 32bit (VPSGuy)</li>
</ul>
<p>They are all showing different memory usage. I am taking the snapshot of memory usage <b>AFTER</b> 10 page loads on the WordPress blog that has been created to ensure PHP process is fully loaded.</p>
<h4>Ubuntu 10.04 64bit</h4>
<pre class="code">
root@ubuntu64:~# <b>ps aux</b>
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.5  23300  1536 ?        Ss   06:58   0:00 init
root     10124  0.0  0.5  23576  1496 ?        Ss   07:34   0:00 dropbear -i
root     15742  0.0  0.7  17880  1944 pts/0    Ss   07:35   0:00 -bash
root     15754  0.0  0.4  14960  1084 pts/0    R+   07:35   0:00 ps aux
root     24290  0.0  0.3  12508   788 ?        S    07:22   0:00 /usr/sbin/syslo
root     24524  0.0  0.3  21064  1004 ?        Ss   07:22   0:00 cron
root     25689  0.0  0.3  19512   972 ?        Ss   07:22   0:00 /usr/sbin/xinet
mysql    26346  0.0  4.2  61812 11248 ?        Ssl  07:23   0:00 /usr/sbin/mysql
www-data 27920  0.0  2.6  87768  7048 ?        Ss   07:23   0:00 /usr/bin/php-cg
www-data 27922  0.5 15.0 122460 39432 ?        S    07:23   0:04 /usr/bin/php-cg
103      30162  0.0  0.3  44356  1000 ?        Ss   07:24   0:00 /usr/sbin/exim4
root     30267  0.0  0.3  28104   932 ?        Ss   07:24   0:00 nginx: master p
www-data 30268  0.0  0.8  28744  2196 ?        S    07:24   0:00 nginx: worker p

root@ubuntu64:~# <b>free</b>
             total       used       free     shared    buffers     cached
Mem:        262144     100500     161644          0          0          0
-/+ buffers/cache:     100500     161644
Swap:            0          0          0
</pre>
<p>Memory Usage: <b>98.1MB</b></p>
<h4>Debian 5 64bit</h4>
<pre class="code">
debian64:~# <b>ps aux</b>
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.2  10304   740 ?        Ss   12:22   0:00 init [2]
106       1414  0.0  0.3  42708  1004 ?        Ss   12:26   0:00 /usr/sbin/exim4
www-data  1655  0.0  2.5  72028  6560 ?        Ss   12:26   0:00 /usr/bin/php-cg
www-data  1657  0.9 11.7  98500 30928 ?        S    12:26   0:03 /usr/bin/php-cg
www-data  3126  0.0  0.7  28380  1912 ?        S    12:29   0:00 nginx: worker p
root      7668  0.1  0.5  23340  1528 ?        Rs   12:31   0:00 dropbear -i
root      7831  0.0  0.6  17472  1716 pts/0    Ss   12:32   0:00 -bash
root      7836  0.0  0.3  14720   980 pts/0    R+   12:32   0:00 ps aux
root     20169  0.0  0.3  18540   936 ?        Ss   12:22   0:00 /usr/sbin/cron
root     24462  0.0  0.2  12236   732 ?        S    12:25   0:00 /usr/sbin/syslo
root     25637  0.0  0.3  19256   952 ?        Ss   12:25   0:00 /usr/sbin/xinet
root     25694  0.0  0.5  28380  1552 ?        Ss   12:25   0:00 nginx: master p
root     32427  0.0  0.2   3872   588 ?        S    12:26   0:00 /bin/sh /usr/bi
mysql    32466  0.0  3.0  50420  8124 ?        Sl   12:26   0:00 /usr/sbin/mysql
root     32468  0.0  0.2   3772   592 ?        S    12:26   0:00 logger -p daemo

debian64:~# <b>free</b>
             total       used       free     shared    buffers     cached
Mem:        262144      61008     201136          0          0          0
-/+ buffers/cache:      61008     201136
Swap:            0          0          0
</pre>
<p>Memory Usage: <b>59.6MB</b></p>
<h4>Debian 5 32bit</h4>
<pre class="code">
debian32:~# <b>ps aux</b>
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.1   1980   688 ?        Ss   23:34   0:00 init [2]
root     14064  0.0  0.1   1704   512 ?        S    23:52   0:00 /bin/sh /usr/bi
mysql    14119  0.0  1.7  20056  6968 ?        Sl   23:52   0:00 /usr/sbin/mysql
root     14120  0.0  0.1   1628   536 ?        S    23:52   0:00 logger -p daemo
www-data 15968  0.0  1.2  16352  4996 ?        Ss   23:53   0:00 /usr/bin/php-cg
www-data 15971  0.5  4.7  29436 18576 ?        S    23:53   0:01 /usr/bin/php-cg
root     16040  0.0  0.3   2700  1464 ?        Rs   23:53   0:00 dropbear -i
root     16119  0.0  0.1   1880   684 ?        S    23:44   0:00 /usr/sbin/syslo
root     16133  0.0  0.3   2780  1536 pts/0    Ss   23:54   0:00 -bash
root     17728  0.0  0.2   2352   896 ?        Ss   23:45   0:00 /usr/sbin/xinet
www-data 17758  0.0  0.3   5004  1488 ?        S    23:54   0:00 nginx: worker p
root     27834  0.0  0.3   4548  1236 ?        Ss   23:47   0:00 nginx: master p
root     28146  0.0  0.2   2296   896 pts/0    R+   23:57   0:00 ps aux
102      32065  0.0  0.2   6104   900 ?        Ss   23:49   0:00 /usr/sbin/exim4

debian32:~# <b>free</b>
             total       used       free     shared    buffers     cached
Mem:        262144      44272     217872          0          0          0
-/+ buffers/cache:      44272     217872
Swap:            0          0          0
</pre>
<p>Memory Usage: <b>43.2MB</b></p>
<p>So to put that in summary form</p>
<ul>
<li>Ubuntu 10.04 uses significantly more memory than Debian 5 (PHP5.3/MySQL5.1 vs. PHP5.2/MySQL5.0). So pick your distro wisely and maybe you don&#8217;t need the latest and greatest if your application does not need it.</li>
<li>32bit also uses quite a bit less than 64bit, running exactly the same version of stack. That pretty much <a href="http://www.lowendbox.com/blog/32bit-or-64bit-for-my-low-end-vps-take-2/">confirms what I posted before</a>.</li>
</ul>
<p>And hopefully the above script is useful for your next WordPress splog farm :P</p>
<div style="display:none">38.107.179.230</div><hr/><div>Copyright &copy; <a href="http://www.lowendbox.com/">LowEndBox.com</a>. All Rights Reserved.</div>]]></content:encoded>
			<wfw:commentRss>http://www.lowendbox.com/blog/wordpress-cheap-vps-lowendscript/feed/</wfw:commentRss>
		<slash:comments>449</slash:comments>
		</item>
		<item>
		<title>32bit or 64bit for My Low End VPS, Take #2</title>
		<link>http://www.lowendbox.com/blog/32bit-or-64bit-for-my-low-end-vps-take-2/</link>
		<comments>http://www.lowendbox.com/blog/32bit-or-64bit-for-my-low-end-vps-take-2/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 00:57:42 +0000</pubDate>
		<dc:creator>LowEndAdmin</dc:creator>
				<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://www.lowendbox.com/?p=1044</guid>
		<description><![CDATA[Saw this discussion on WHT today when someone tries to confirm whether &#8220;32bit systems are better when it comes to memory management&#8221;, and when it comes to low end virtual servers, which of 32bit or 64bit operating system is preferred. That&#8217;s something I have discussed over 2 years ago, but for all the new readers [...]]]></description>
			<content:encoded><![CDATA[<p>Saw <a href="http://www.webhostingtalk.com/showthread.php?t=963874">this discussion on WHT</a> today when someone tries to confirm whether &#8220;32bit systems are better when it comes to memory management&#8221;, and when it comes to low end virtual servers, which of 32bit or 64bit operating system is preferred.</p>
<p>That&#8217;s <a href="http://www.lowendbox.com/blog/stick-to-32-bit-for-your-low-end-box/">something I have discussed over 2 years ago</a>, but for all the new readers out there &#8212; <b>go for 32bit OS for your next low end VPS</b>. The &#8220;memory management&#8221; perspect is the same between 32bit and 64bit &#8212; it&#8217;s the same OS with the same virtual memory manager (well, not quite, as with 64bit there are a lot more tricks for OS to play with). But the main reason for going 32bit is, your applications are going to use far less memory due to a lot of data is only stored at 1/2 the space as 64bit. Modern scripting language VMs are full of pointers (I am talking about PHP, Python VMs etc) and when all those values are double in size, it can really add up.</p>
<p>I will only go 64bit for my low end VPS if</p>
<ul>
<li>That&#8217;s the only OS image the providers offer. Let&#8217;s just call it a conspiracy to get you upgrade earlier.</li>
<li>64bit testing. I have one small 64bit VPS around so I can do compilation + testing of some of my open sourced code under 64bit.</li>
<li>Application requirement. Probably not that relevant if you are just running an web app, but some other apps might require 64bit.</li>
</ul>
<p>Or your MySQL database that needs more than 4GB for key buffers. But in those case you should not be reading LowEndBox anyway :) These days I found 32bit is usually good enough for big boxes when you use PAE, as the performance penalty is really insignificant with today&#8217;s CPU/memory speed.</p>
<div style="display:none">38.107.179.230</div><hr/><div>Copyright &copy; <a href="http://www.lowendbox.com/">LowEndBox.com</a>. All Rights Reserved.</div>]]></content:encoded>
			<wfw:commentRss>http://www.lowendbox.com/blog/32bit-or-64bit-for-my-low-end-vps-take-2/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>Reduce Stack Limit for Multi-Thread Apps</title>
		<link>http://www.lowendbox.com/blog/reduce-stack-limit-for-multi-thread-apps/</link>
		<comments>http://www.lowendbox.com/blog/reduce-stack-limit-for-multi-thread-apps/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 12:32:40 +0000</pubDate>
		<dc:creator>LowEndAdmin</dc:creator>
				<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://www.lowendbox.com/?p=546</guid>
		<description><![CDATA[Just a small tips for those trying to run multiple threaded applications on OpenVZ. Personally I code quite a few multi-threaded applications in Python (as some things are just too hard to do asynchronisely). Very often a 6MB RSS application would eat up close to 100MB of VSZ. As one of the most important metrics [...]]]></description>
			<content:encoded><![CDATA[<p>Just a small tips for those trying to run multiple threaded applications on OpenVZ.</p>
<p>Personally I code quite a few multi-threaded applications in Python (as some things are just too hard to do asynchronisely). Very often a 6MB RSS application would eat up close to 100MB of VSZ. As one of the most important metrics on OpenVZ &#8212; not &#8220;guaranteed memory&#8221; but &#8220;burstable memory&#8221;, i.e. <code>privvmpages</code> &#8212; is counted on how much your processes have <em>allocated</em>, you&#8217;ll soon find your application, which actually only use 6MB of &#8220;real memory&#8221;, quickly died on your 64MB VPS with 128MB of burstable memory.</p>
<p>The same applies to many other multi-threaded applications that use the default stack size when creating threads. I use <a href="http://www.phys.uu.nl/~rombouts/pdnsd.html">pdnsd</a> as a local DNS resolver/cache. A fresh start on Debian would show to use around 1MB RSS but <b>51MB VSZ</b>!</p>
<pre class="code">
$ <b>ps -u pdnsd u</b>
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
pdnsd    32521  0.0  0.3  51436   976 ?        Sl   23:12   0:00 /usr/sbin/pdnsd
</pre>
<p>It turns out that for multi-threaded applications, each thread will be allocated 8MB of stack (although not actually used). The allocated stack actually counts against <code>privvmpages</code> in user beancounters, i.e. against your &#8220;burstable memory&#8221;. That sucks. Which is why I much prefer a Xen VPS which has a proper memory accounting!</p>
<p>So the trick is reducing the stack size so not much will be allocated for each of the threads. In many cases, you don&#8217;t need that much stack (applications should <code>malloc</code> instead of assuming a big stack is available). So let&#8217;s reduce the stack size (with <code>ulimit -s</code>) and see how much memory you can save.</p>
<pre class="code">
# <b>ulimit -s 256</b>
# <b>/etc/init.d/pdnsd restart</b>
...
# <b>ps -u pdnsd u</b>
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
pdnsd     3261  0.0  0.3   3308   916 ?        Sl   23:24   0:00 /usr/sbin/pdnsd
</pre>
<p>There we go. From 51MB to 3.3MB. You should see a huge drop under the <code>held</code> column of <code>privvmpages</code> as well under <code>/proc/user_beancounters</code>!</p>
<p>You can pretty much use <code>ulimit -s</code> to limit the stack size of any application but I found it&#8217;s only really effectively on multi-threaded applications on OpenVZ. To find out which apps are multi-threaded, you can use <code>`ps auxm`</code> to list not just the processes but also threads. Add the limit before you start the service, or put the ulimit line inside the RC file. You&#8217;ll find that you can now squeeze more into your low end box :)</p>
<div style="display:none">38.107.179.230</div><hr/><div>Copyright &copy; <a href="http://www.lowendbox.com/">LowEndBox.com</a>. All Rights Reserved.</div>]]></content:encoded>
			<wfw:commentRss>http://www.lowendbox.com/blog/reduce-stack-limit-for-multi-thread-apps/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Bootstraping Low End VPS with Pre-built Scripts</title>
		<link>http://www.lowendbox.com/blog/bootstraping-low-end-vps-with-pre-built-scripts/</link>
		<comments>http://www.lowendbox.com/blog/bootstraping-low-end-vps-with-pre-built-scripts/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 01:52:57 +0000</pubDate>
		<dc:creator>LowEndAdmin</dc:creator>
				<category><![CDATA[Tuning]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.lowendbox.com/blog/bootstraping-low-end-vps-with-pre-built-scripts/</guid>
		<description><![CDATA[It was fun setting up your very own server. I remembered the time when I received the root password to my very first virtual server back in March 2006 ($22/month for a merely 192MB of memory), it took me hours setting it up to exactly the way I wanted. At the end of the day [...]]]></description>
			<content:encoded><![CDATA[<p>It was fun setting up your very own server. I remembered the time when I received the root password to my very first virtual server back in March 2006 ($22/month for a <em>merely</em> 192MB of memory), it took me <em>hours</em> setting it up to <em>exactly</em> the way I wanted. At the end of the day when it started to pump out my websites on TCP port 80 &#8212; <b>joy</b>!</p>
<p>Well. It&#8217;s still fun the second time around when I moved hosting, but it wasn&#8217;t the same. 3<sup>rd</sup> time? Hmm. By now I probably have set up 30+ virtual servers due to expansion or migration, and it feels a lot like <em>work</em> than fun. In the effort to possess the 3 great virtues of a programmer according to Larry Wall, <em>laziness, impatience, and hubris</em>, I decided to write some simple scripts to quickly get my low end virtual servers up running <em>and configured</em> in no time!</p>
<p>Here is one that I want to share today.</p>
<ul>
<li><b style="font-size:120%">Download <a href="http://www.lowendbox.com/scripts/lowend-debian.sh">lowend-debian.sh</a></b></li>
</ul>
<p>Usage:</p>
<ol>
<li>Buy a new low end VPS from any provider</li>
<li>Build a standard <em>Debian 5</em> minimum install</li>
<li>Got the root password</li>
<li><code>ssh</code> into your new low end box, and
<pre class="code">
$ ssh root@my-new-box
Linux lowendbox 2.6.18-blah #1 SMP Wed Aug 26 15:47:17 MSD 2009 i686
...
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
# <b>wget -q http://www.lowendbox.com/scripts/lowend-debian.sh</b>
# <b>bash ./lowend-debian.sh</b>
...
</pre>
</li>
</ol>
<p>What it does is:</p>
<ul>
<li>Remove <code>rsyslogd</code> (memory hog on OpenVZ system) and <code>portmap</code> (mostly useless).</li>
<li>Run <code>apt-get update &amp;&amp; apt-get upgrade</code> to get the server up to date.</li>
<li>Install and configure <code>dash</code> as <code>/bin/sh</code>.</li>
<li>Install and configure <code>inetutils-syslog</code> as default system logger.</li>
<li>Install and configure <code>dropbear</code> as OpenSSH replacement.</li>
</ul>
<p>Once done, it should bring the memory usage to around 4-5MB on a 32bit Debian (where 2.8MB is from <code>bash</code> and <code>dropbear</code> that handles the SSH connection). It should also work on Ubuntu-based distributions (tested on a 64MB Ubuntu 9.04 VPS). Feel free to check the code to make sure I am not doing anything malicious like hijacking the server and install a ssh key or something :)</p>
<div style="display:none">38.107.179.230</div><hr/><div>Copyright &copy; <a href="http://www.lowendbox.com/">LowEndBox.com</a>. All Rights Reserved.</div>]]></content:encoded>
			<wfw:commentRss>http://www.lowendbox.com/blog/bootstraping-low-end-vps-with-pre-built-scripts/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Yes, You Can Run 18 Static Sites on a 64MB Link-1 VPS</title>
		<link>http://www.lowendbox.com/blog/yes-you-can-run-18-static-sites-on-a-64mb-link-1-vps/</link>
		<comments>http://www.lowendbox.com/blog/yes-you-can-run-18-static-sites-on-a-64mb-link-1-vps/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 01:36:15 +0000</pubDate>
		<dc:creator>LowEndAdmin</dc:creator>
				<category><![CDATA[Tuning]]></category>
		<category><![CDATA[vpslink.com]]></category>

		<guid isPermaLink="false">http://www.lowendbox.com/?p=206</guid>
		<description><![CDATA[One thing I hated about WebHostingTalk is how much bad advice the so-called &#8220;professionals&#8221; are giving out to the world. Some poor college student asked in the VPS forums whether he is able to run 18 static HTML sites on VPSLink.com Link-1 plan (64MB RAM, 2.5GB storage &#38; 100GB/month data), and the typical responses are: [...]]]></description>
			<content:encoded><![CDATA[<p>One thing I hated about <a href="http://www.webhostingtalk.com/">WebHostingTalk</a> is how much bad advice the so-called &#8220;professionals&#8221; are giving out to the world. Some poor college student asked in the VPS forums <a href="http://www.webhostingtalk.com/showthread.php?t=765561">whether he is able to run 18 static HTML sites</a> on <a href="http://www.vpslink.com/">VPSLink.com</a> Link-1 plan (64MB RAM, 2.5GB storage &amp; 100GB/month data), and the typical responses are:</p>
<blockquote>
<p>&#8220;I do not believe you can host 18 websites on 64MB of RAM. I&#8217;d bump that up to at least 128 or 256.&#8221; &#8211;nexbyte</p>
<p>&#8220;I really wouldn&#8217;t advise anything lower than 265MB RAM for website hosting.&#8221; &#8211;RikeMedia</p>
</blockquote>
<p><em>(Well, there are some more optimistic comments but I mainly list out those &#8220;with things to sell&#8221;)</em></p>
<p>So, just trying to prove the point that <em>yes, 64MB is more than enough to host 18 static sites</em>, I decided to add a <b>Link-1 Xen</b> to my account and document the process. Btw, thanks to <em>Dan</em> @ VPSLink for getting my billing issue resolved :) You can get <a href="http://www.lowendbox.com/blog/vpslink-february-sale-and-10-off-referral-discount/">10% recursive discount here</a>, or <a href="http://www.lowendbox.com/blog/exclusive-66-off-first-3-months-from-vpslink/">66% off for the first 3 months here</a>.</p>
<p><span id="more-206"></span></p>
<h3>Setting Up the VPS</h3>
<p>After my order has been provisioned, I re-image the server with a Debian 5 &#8220;Lenny&#8221; image. I normally pick Debian or Ubuntu because <code>apt-get</code> uses much less memory than RedHat/Fedora&#8217;s equivalent, and it&#8217;s also my personal preference. I named my new VPS &#8220;endor&#8221; as I usually just name my boxes after <a href="http://starwars.wikia.com/wiki/List_of_systems">Star Wars systems</a>. Re-imaging a VPS is pretty fast &#8212; 2 minutes later I have my root password sent to my email address so I can ssh in to set up the new system.</p>
<pre class="code">
$ <b>ssh root@endor</b>
root@endor's password:
Linux 66671 2.6.18-53.1.13.el5xen #1 SMP Tue Feb 12 14:04:18 EST 2008 i686

endor:~# <b>free</b>
             total       used       free     shared    buffers     cached
Mem:         65704      64008       1696          0       5616      44100
-/+ buffers/cache:      14292      51412
Swap:       131064          0     131064
endor:~# <b>cat /proc/cpuinfo</b>
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Core(TM)2 Duo CPU     E4500  @ 2.20GHz
stepping        : 13
cpu MHz         : 2194.496
cache size      : 2048 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu tsc msr pae mce cx8 apic mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc up pni monitor ds_cpl est tm2 cx16 xtpr lahf_lm
bogomips        : 5558.81
</pre>
<p><em>Plenty</em> of free memory and a single core of C2Duo E4500 &#8212; although not a high-end Xeon CPU, but should be more than sufficient to do what we need it to do. The next thing I want to do is to make sure every package is up to date.</p>
<pre class="code">
endor:~# <b>apt-get update &amp;&amp; apt-get upgrade</b>
Get:1 http://debrepo.mirror.vpslink.com lenny Release.gpg [386B]
Get:2 http://debrepo.mirror.vpslink.com lenny Release [63.2kB]
Get:3 http://debrepo.mirror.vpslink.com lenny/main Packages [5295kB]
Get:4 http://security.debian.org lenny/updates Release.gpg [197B]
Get:5 http://security.debian.org lenny/updates Release [40.8kB]
Get:6 http://debrepo.mirror.vpslink.com lenny/contrib Packages [76.1kB]
Ign http://security.debian.org lenny/updates/main Packages/DiffIndex
Get:7 http://security.debian.org lenny/updates/contrib Packages [14B]
Get:8 http://security.debian.org lenny/updates/main Packages [50.6kB]
Fetched 5526kB in 4s (1330kB/s)
Reading package lists... Done
...
</pre>
<h3>Setting Up Web Server</h3>
<p>Okay. The 64MB VPS is now up and running. What should we do next? Installing a web server of course, so we can start serving our static pages! Which web server? <a href="http://www.lowendbox.com/blog/getting-rid-of-a-in-lamp-for-your-low-end-vps/">Definitely not Apache</a> as it would be a waste of valuable memory here. Again my personal favourite is <a href="http://nginx.net/">Nginx</a> (pronounces Engine X), which currently powers LowEndBox.com. However, in this exercise I will go for <a href="http://www.lighttpd.net/">Lighttpd</a> because I found it easier to set up for abitary sites.</p>
<p>First of all &#8212; get Lighttpd installed.</p>
<pre class="code">
endor:~# <b>apt-get install lighttpd</b>
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
...
Setting up libterm-readkey-perl (2.30-4) ...
Setting up libterm-readline-perl-perl (1.0302-1) ...
Setting up lighttpd (1.4.19-5) ...
Starting web server: lighttpd.
endor:~# <b>ps -u www-data u</b>
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
www-data  1690  0.0  1.5   5416  1008 ?        S    07:17   0:00 /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
</pre>
<p>Plain vanilla stripped down and un-configured 32 bit Lighttpd sits around 1MB RSS &#8212; not bad.</p>
<p>Next, we need to get our websites up there and point Lighttpd to them. It&#8217;s a good idea to put the web sites in an organised structure inside the file system. I usually just place them this way:</p>
<ul>
<li><code>/var/www/<em>&lt;hostname&gt;</em>/html</code></li>
</ul>
<p>So if I have an HTML file at http://www.example.com/testing.html, it will sit on the file system at <code>/var/www/www.example.com/html/testing.html</code>. Unfortunately I do not have 18 static sites. For testing purpose I am only going to display a very basic HTML page at http://test.lowendbox.com/.</p>
<pre class="code">
endor:~# <b>mkdir -p /var/www/test.lowendbox.com/html</b>
endor:~# <b>echo '&lt;h1&gt;Low End Box Rocks!&lt;/h1&gt;' &gt; /var/www/test.lowendbox.com/html/index.html</b>
</pre>
<p>So now our &#8220;website&#8221; is ready &#8212; how does Lighttpd, our webserver, knows where to find the files corresponding to the website? That&#8217;s where Lighttpd&#8217;s <a href="http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModSimpleVhost">mod_simple_vhost</a> comes in handy.</p>
<pre class="code">
endor:~# <b>lighttpd-enable-mod simple-vhost</b>
Available modules: auth cgi fastcgi proxy rrdtool simple-vhost ssi ssl status userdir
Already enabled modules:
Enabling simple-vhost: ok
Run /etc/init.d/lighttpd force-reload to enable changes
endor:~# <b>/etc/init.d/lighttpd force-reload</b>
Stopping web server: lighttpd.
Starting web server: lighttpd.
</pre>
<p>Now navigate to test.lowendbox.com (which already has an A record to my new VPS&#8217;s IP address) &#8212; here we have it! Low End Box Rocks!!!</p>
<p class="notes">Prerequisite:<br/>You must be already familiar with DNS and know how to create records to point to IP addresses. For free DNS hosting I recommend <a href="http://www.everydns.com/">EveryDNS</a>, which has also been hosting LowEndBox&#8217;s domain.</p>
<p>You can now basically just dump static files at /var/www/<em>&lt;hostname&gt;</em>/html, with &lt;hostname&gt; resolved to your VPS&#8217;s IP address, and you will have your static websites over there in no time. You do not even need to tell Lighttpd to reload, as mod_simple_vhost automatically maps the hostname to appropriate file name. Repeat it 18 times and problem solved!</p>
<p>At 1 single testing site with no traffic, Lighttpd sits at around 1.5MB RSS, although I doubt it would increase significantly when you increase the number of sites or the traffic. Lighttpd and Nginx are single-threaded poll-based asynchronised web servers so for static file serving, the bottle-neck would be disk/network IO rather than amount of memory or CPU performance.</p>
<p>There are still <em>lots</em> of memory left. Maybe we can have some fun.</p>
<h3>Installing WordPress</h3>
<p>So you think, &#8220;hey Low End Box rocks and it runs on <a href="http://wordpress.org/">WordPress</a>. So maybe I will have that installed as well!&#8221; Wow. But WordPress is a <em>content management system</em> for creating <em>dynamic websites</em>! It simply cannot be possible on a 64MB VPS, the WHT crowd says! Grrr!! Let&#8217;s give it a try.</p>
<p>To run WordPress from your static-file serving Lighttpd, you need a few more packages &#8212; namely MySQL and PHP in CGI/FastCGI mode.</p>
<pre class="code">
endor:~# <b>apt-get install mysql-server php5-cgi php5-mysql</b>
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
...
Creating config file /etc/php5/cgi/php.ini with new version
Setting up php5-mysql (5.2.6.dfsg.1-1+lenny2) ...
Setting up sgml-base (1.26) ...
Setting up xml-core (0.12) ...
Setting up mailx (1:20071201-3) ...
</pre>
<p>I know it installs whole lot of other junks but don&#8217;t worry &#8212; we will live with them first and will try to optimise later. It also requires you to set up the root password for MySQL server, and I conveniently chose the most obscured password in this exercise &#8212; &#8220;root&#8221; (yes, don&#8217;t use that because I am already using it as my root password :)</p>
<p>We then need to configure lighttpd to handle PHP files.</p>
<pre class="code">
endor:~# <b>cat > /etc/lighttpd/conf-enabled/10-cgi-php.conf
server.modules += ("mod_cgi")
cgi.assign = (".php" => "/usr/bin/php5-cgi")</b><em>^D</em>
endor:~# <b>/etc/init.d/lighttpd force-reload</b>
Stopping web server: lighttpd.
Starting web server: lighttpd.
</pre>
<p>Done! It should be able to serve PHP files. Just to test it out:</p>
<pre class="code">
endor:~# <b>echo '&lt;?php phpinfo(); ?&gt;' &gt; /var/www/test.lowendbox.com/html/phpinfo.php</b>
</pre>
<p>Now navigate to http://test.lowendbox.com/phpinfo.php &#8212; you should be able to see the output of <code>phpinfo()</code> function. What we are going to do next is to set up a WordPress blog under http://test.lowendbox.com/blog/. WordPress.org <a href="http://codex.wordpress.org/Installing_WordPress">already provides a great tutorial on installing WordPress</a>, but let&#8217;s do it <em>step by step</em> on the command prompt.</p>
<p>My plan:</p>
<ul>
<li>Create database &#8220;test_blog&#8221;</li>
<li>Download the latest WordPress and unzip to test.lowendbox.com/blog</li>
<li>Set up configuration file and run the WordPress install</li>
<li>Update Lighttpd to provide clean URL, aka <a href="http://codex.wordpress.org/Using_Permalinks">Pretty Permalinks</a>.</li>
</ul>
<p>Let&#8217;s go!</p>
<pre class="code">
endor:~# <b>mysqladmin -uroot -proot create test_blog</b>
endor:~# <b>wget http://wordpress.org/latest.tar.gz</b>
Resolving wordpress.org... 72.233.56.138, 72.233.56.139
Connecting to wordpress.org|72.233.56.138|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: `latest.tar.gz'

...

2009-03-17 13:03:15 (1.01 MB/s) - `latest.tar.gz' saved [1624416]

endor:~# <b>tar zxf latest.tar.gz -C /var/www/test.lowendbox.com/html</b>
endor:~# <b>cd /var/www/test.lowendbox.com/html</b>
endor:/var/www/test.lowendbox.com/html# <b>mv wordpress blog</b>
endor:/var/www/test.lowendbox.com/html# <b>mv blog/wp-config-sample.php blog/wp-config.php</b>
endor:/var/www/test.lowendbox.com/html# <b>vi blog/wp-config.php</b>
</pre>
<p>When you are editing WordPress&#8217; configuration file, set <code>DB_NAME</code> to &#8220;test_blog&#8221;, <code>DB_USER</code> and <code>DB_PASSWORD</code> to &#8220;root&#8221; for something quick, dirty and potentially insecure. Here is one final step &#8212; navigate to http://test.lowendbox.com/blog/, and WordPress will guide you through the rest of setup.</p>
<p>It is also relatively easy to set up pretty permalinks for WordPress on Lighttpd. In our example,</p>
<pre class="code">
endor:~# <b>cat > /etc/lighttpd/conf-enabled/lowendbox.conf</b>
<b>$HTTP["host"] == "test.lowendbox.com" {</b>
<b>    $HTTP["url"] =~ "^/blog/" {</b>
<b>        server.error-handler-404 = "/blog/index.php"</b>
<b>    }</b>
<b>}</b><em>^D</em>
endor:~# <b>/etc/init.d/lighttpd force-reload</b>
Stopping web server: lighttpd.
Starting web server: lighttpd.
</pre>
<p>That&#8217;s it! You can now go into WordPress to configure the desirable Permalink Structure. Do note that the current WordPress dashboard page is <em>very resource intensive</em>, as it fetches development blog, other WP news, incoming links, etc from various sources, <em>concurrently</em> on separate PHP CGI processes. There might be plugins to turn off this server-killing behavior (or just use older version of WordPress like 2.0.x which is still maintained). Likewise some WP caching plugin can be very useful in reducing the load. Google them and you shall find.</p>
<h3>Optimisation &#8212; Squeeze More Memory!</h3>
<p>So now we have a Debian 5 web server box that can handle lots of static sites + a few WordPress blogs, and it fits &#8220;fine&#8221; on a 64MB Xen VPS. Let&#8217;s see what processes are running:</p>
<pre class="code">
endor:~# <b>ps aux</b>
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
...
root       325  0.0  0.4   2032   292 ?        S&lt;s  04:25   0:00 udevd --daem
root       879  0.0  0.4   2788   304 ?        Ss   Mar17   0:00 /bin/bash --
root      1216  0.0  0.0      0     0 ?        S    Mar17   0:00 [pdflush]
root      1649  0.0  0.2   3144   188 ?        Ss   Mar17   0:00 /usr/sbin/famd
root      6427  0.0  4.4   8024  2928 ?        Ss   Mar17   0:00 sshd: root@pts/
root      6429  0.0  2.3   2804  1564 pts/0    Ss   Mar17   0:00 -bash
root      6441  0.0  1.8  33092  1200 ?        Sl   Mar17   0:00 /usr/sbin/rsysl
root      6453  0.0  1.4   5284   976 ?        Ss   Mar17   0:00 /usr/sbin/sshd
root      6470  0.0  1.3   2048   896 ?        Ss   Mar17   0:00 /usr/sbin/cron
daemon    6482  0.0  0.8   1772   560 ?        Ss   Mar17   0:00 /sbin/portmap
www-data  6510  0.0  2.6   5848  1736 ?        S    Mar17   0:00 /usr/sbin/light
root      6572  0.0  1.7   2488  1156 pts/0    S    Mar17   0:00 /bin/sh /usr/bi
mysql     6611  0.0 26.2 143652 17228 pts/0    Sl   Mar17   0:00 /usr/sbin/mysql
root      6613  0.0  0.8   1636   536 pts/0    S    Mar17   0:00 logger -p daemo
103       6973  0.0  1.3   6112   908 ?        Ss   Mar17   0:00 /usr/sbin/exim4
root      6986  0.0  1.3   2308   908 pts/0    R+   00:01   0:00 ps aux
endor:~# <b>free</b>
             total       used       free     shared    buffers     cached
Mem:         65704      51424      14280          0        936      22588
-/+ buffers/cache:      27900      37804
Swap:       131064        864     130200
</pre>
<p>Note that it&#8217;s an idle box. The swap is slightly used and at <b>37MB free</b> it is actually not too bad. Let&#8217;s try to squeeze a little bit more memory out from the factory setup.</p>
<p>MySQL is by far the biggest <em>offender</em>, and I have <a href="http://www.lowendbox.com/blog/reducing-mysql-memory-usage-for-low-end-boxes/">talked about how to reduce MySQL memory usage here</a>. If you are just running simple CMS, InnoDB is probably not required &#8212; it uses more memory and a lot heavier on IO as well. We can simply use the LxAdmin&#8217;s mysql.cnf which I linked on the other blog post to get the bare-minimum MySQL running.</p>
<pre class="code">
endor:~# <b>cat > /etc/mysql/conf.d/lowendbox.cnf
[mysqld]
key_buffer = 16K
max_allowed_packet = 1M
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K
skip-bdb
skip-innodb</b><em>^D</em>
</pre>
<p>As <code>mysqld_safe</code> script uses <code>/bin/sh</code> for scripting, it&#8217;s also a good idea to check <a href="http://www.lowendbox.com/blog/replacing-big-fat-bash-with-dash-for-scripting/">whether dash is used instead of bash</a>.</p>
<pre class="code">
endor:~# <b>apt-get install dash</b>
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
...
Unpacking dash (from .../dash_0.5.4-12_i386.deb) ...
Processing triggers for man-db ...
Setting up dash (0.5.4-12) ...
endor:~# <b>dpkg-reconfigure dash</b>
Adding `diversion of /bin/sh to /bin/sh.distrib by dash'
Adding `diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by dash'
endor:~# <b>/etc/init.d/mysql restart</b>
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..
</pre>
<p>One thing I don&#8217;t like about Debian 5 is its default inclusion of <a href="http://www.rsyslog.com/">rsyslog</a>. Well &#8212; it&#8217;s feature rich, but I don&#8217;t need MySQL and TCP syslog support. Weight at 1.2MB RSS is just a bit too fat I reckon. I am not game enough to go <em>without</em> a syslog daemon, so I just go for <a href="http://en.wikipedia.org/wiki/Syslog-ng">syslog-ng</a>. Probably not the most light weight, but it&#8217;s just something I have been using for the last couple of years.</p>
<pre class="code">
endor:~# <b>ps -C rsyslogd v</b>
  PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
 6441 ?        Sl     0:00      0   207 32936  1260  1.9 /usr/sbin/rsyslogd -c3
endor:~# <b>apt-get install syslog-ng &amp;&amp; dpkg --purge rsyslog</b>
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
...
Setting up syslog-ng (2.0.9-4.1) ...
Starting system logging: syslog-ng.
(Reading database ... 16517 files and directories currently installed.)
Removing rsyslog ...
Purging configuration files for rsyslog ...
endor:~# <b>ps -C syslog-ng v</b>
  PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
 8215 ?        Ss     0:00      0   105  2754   708  1.0 /usr/sbin/syslog-ng -p
</pre>
<p>Shedding 500kb RSS &#8212; not too bad I guess :)</p>
<p>Next &#8212; <a href="http://neil.brown.name/portmap/">Portmap</a> and <a href="http://savannah.nongnu.org/projects/fam/">FAM</a> got installed when Lighttpd was first installed. Lighttpd does not <em>really</em> need FAM. It&#8217;s used for stat cache to reduce seeks, but can live without. Not that I have noticed any performance difference anyway for small traffic anyway. Having both of them removed from the process list would give us extra 750KB.</p>
<pre class="code">
endor:~# <b>apt-get remove --purge portmap</b>
eading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
...
</pre>
<p>OpenSSH can be <a href="http://www.lowendbox.com/blog/replacing-openssh-with-dropbear/">replaced by dropbear</a> to save memory.</p>
<pre class="code">
endor:~# <b>touch /etc/ssh/sshd_not_to_be_run</b>
endor:~# <b>apt-get install dropbear</b>
...
endor:~# <b>vi /etc/default/dropbear</b>
endor:~# <b>/etc/init.d/dropbear start</b>
Starting Dropbear SSH server: dropbear.
</pre>
<p>Just remember to set <code>NO_START=0</code> in <code>/etc/default/dropbear</code> so dropbear can run as a daemon. Dropbear daemon is using around 500KB less than OpenSSH daemon during idle, and for each connection it uses 1.5MB less on this Debian 5 box &#8212; that&#8217;s quite a saving!</p>
<p>That&#8217;s probably it! Vixie cron can be replaced by a light weight <a href="http://apollo.backplane.com/FreeSrc/">DCRON</a> but I can&#8217;t seem to be able find it in Debian&#8217;s repository. Exim4 is probably one of the most light weight mail daemon you can have, but then again you might want to question &#8212; &#8220;do I need a mail daemon running&#8221;? You can probably bring it down, and just run <code>/usr/sbin/runq</code> once every 2 hours to process the queue, in case the previous delivery failed. That would probably give you another 1MB to play with.</p>
<p>You can also use <a href="http://www.lowendbox.com/blog/replacing-that-big-fat-bash/">PDKSH</a> to replace BASH as interactive shell to loose some weight.</p>
<pre class="code">
endor:~# <b>ps -C bash v</b>
  PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
 8409 pts/1    Ss     0:00      2   663  2140  1568  2.3 -bash
endor:~# <b>apt-get install pdksh</b>
endor:~# <b>chsh -s /bin/pdksh</b>
<em>&lt;log out and then SSH back in&gt;</em>
# <b>ps -C pdksh v</b>
  PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
 8550 pts/0    Rs     0:00      0   174  1633   588  0.8 -pdksh
</pre>
<p>That&#8217;s 1 full megabyte off the scale! Also note that VPSLink&#8217;s <code>/etc/inittab</code> automatically spawn a BASH process on the console &#8212; just in case you got locked out from firewall. For me it&#8217;s the last line of <code>inittab</code> file. Change it to <code>/bin/sh</code> or <code>/bin/pdksh</code>, run <code>init q</code> to reload init(1), and then kill that bash process.</p>
<p>Here&#8217;s the end result:</p>
<pre class="code">
# <b>ps aux</b>
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
...
root       325  0.0  0.4   2032   292 ?        S&lt;s  Mar17   0:00 udevd --daem
root      1216  0.0  0.0      0     0 ?        S    Mar17   0:00 [pdflush]
root      6470  0.0  1.3   2048   896 ?        Ss   Mar17   0:00 /usr/sbin/cron
103       6973  0.0  1.3   6112   912 ?        Ss   Mar17   0:00 /usr/sbin/exim4
root      7953  0.0  0.7   1716   524 ?        S    00:23   0:00 /bin/sh /usr/bi
mysql     7992  0.0  8.2  37904  5404 ?        Sl   00:23   0:00 /usr/sbin/mysql
root      7994  0.0  0.8   1636   536 ?        S    00:23   0:00 logger -p daemo
root      8215  0.0  1.1   2860   776 ?        Ss   00:31   0:00 /usr/sbin/syslo
www-data  8313  0.0  2.4   5712  1640 ?        S    00:37   0:00 /usr/sbin/light
root      8418  0.0  0.7   2052   468 ?        Ss   00:51   0:00 /usr/sbin/dropb
root      8527  0.0  0.7   1712   468 ?        Ss   01:19   0:00 /bin/sh --
root      8549  0.0  1.9   2712  1300 ?        Ss   01:21   0:00 /usr/sbin/dropb
root      8550  0.0  0.9   1808   600 pts/0    Rs   01:21   0:00 -pdksh
root      8562  0.0  1.3   2308   908 pts/0    R+   01:26   0:00 ps aux
# <b>free</b>
             total       used       free     shared    buffers     cached
Mem:         65704      58852       6852          0       2180      40344
-/+ buffers/cache:      16328      49376
Swap:       131064        380     130684
</pre>
<p>That&#8217;s 12MB trimmed, which can be used in disk cache to improve static file serving.</p>
<h3>Conclusion</h3>
<p>So how do we conclude? <b>64MB is more than enough to serve a few low traffic static websites</b>. You can actually run a few WordPress sites with a few hundred visitors a day &#8212; at the price equivalent to many heavily oversold shared hosting <b>and you get root access</b>!</p>
<p>One thing about root access though &#8212; in all my examples above I used root account and never bothered to use a <em>normal</em> user account. It is <em>bad</em> from security aspect so <em>don&#8217;t do it</em>. Or at least don&#8217;t tell anyone that you use nothing but root :)</p>
<div style="display:none">38.107.179.230</div><hr/><div>Copyright &copy; <a href="http://www.lowendbox.com/">LowEndBox.com</a>. All Rights Reserved.</div>]]></content:encoded>
			<wfw:commentRss>http://www.lowendbox.com/blog/yes-you-can-run-18-static-sites-on-a-64mb-link-1-vps/feed/</wfw:commentRss>
		<slash:comments>142</slash:comments>
		</item>
		<item>
		<title>Stick to 32 Bit For Your Low End Box</title>
		<link>http://www.lowendbox.com/blog/stick-to-32-bit-for-your-low-end-box/</link>
		<comments>http://www.lowendbox.com/blog/stick-to-32-bit-for-your-low-end-box/#comments</comments>
		<pubDate>Wed, 07 May 2008 06:20:11 +0000</pubDate>
		<dc:creator>LowEndAdmin</dc:creator>
				<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://www.lowendbox.com/blog/stick-to-32-bit-for-your-low-end-box/</guid>
		<description><![CDATA[When you go and find a cheap low end Linux virtual server, the criteria usually involve price (very important!), location (for low latency SSH access), virtualization (Xen vs. OpenVZ?), etc. However the &#8220;bit-ness&#8221; is rarely looked at. Most current Intel and AMD processors can run 64bit instruction sets, and many virtual server vendors are also [...]]]></description>
			<content:encoded><![CDATA[<p>When you go and find a cheap low end Linux virtual server, the criteria usually involve <b>price</b> (very important!), <b>location</b> (for low latency SSH access), <b>virtualization</b> (Xen vs. OpenVZ?), etc. However the &#8220;bit-ness&#8221; is rarely looked at. Most current Intel and AMD processors can run <a href="http://en.wikipedia.org/wiki/X86-64">64bit instruction sets</a>, and many virtual server vendors are also offering VPSs in either 32bit or 64bit.</p>
<p>However, contrary to conventional wisdom, bigger is not necessarily better. Do you really have a need for 64 bit on your 64MB VPS? Maybe (but not likely), and it will actually be more prudent to stick with the good ol&#8217; 32 bit, because for exactly the same application, it actually uses less memory on 32bit than 64bit!</p>
<p>Currently I&#8217;ve got two 64MB Xen VPS &#8212; one running 32bit Debian Etch at <a href="http://www.lowendbox.com/tag/virtual-dedicated.net/">Virtual-Dedicated.net</a>, and the other running 64bit Ubuntu Hardy at <a href="http://www.lowendbox.com/tag/rapidxen.net/">RapidXen</a>. Two have very similar stack &#8212; syslogh-ng, xinetd with <a href="http://www.lowendbox.com/blog/replacing-openssh-with-dropbear/">dropbear</a>, Vixie Cron, Postfix, Lighttpd and PHP. The 32bit Debian actually runs a few more &#8212; gld for greylisting and 2x PHP/FastCGI processes (which are at 6MB each). Guess what, I actually have more memory left with my 32bit Debian VPS than my 64bit Ubuntu VPS!</p>
<p>It makes sense that 64bit programs use more memory. Integers and pointers are now double the size. So you are not only allocating more, you also need a bigger stack for bigger pointers. Result? Less free memory for other applications or cache.</p>
<p>You can still make a 64bit 64MB VPS do a lot of tricks, but if the only reason to get 64bit is huge address space + ability to do massive matrix manipulation, then you are going to need a lot more memory anyway.</p>
<p>Meanwhile, for a small web head or a redundant MX, 32 bit ought to be enough :)</p>
<div style="display:none">38.107.179.230</div><hr/><div>Copyright &copy; <a href="http://www.lowendbox.com/">LowEndBox.com</a>. All Rights Reserved.</div>]]></content:encoded>
			<wfw:commentRss>http://www.lowendbox.com/blog/stick-to-32-bit-for-your-low-end-box/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Reducing MySQL Memory Usage for Low End Boxes</title>
		<link>http://www.lowendbox.com/blog/reducing-mysql-memory-usage-for-low-end-boxes/</link>
		<comments>http://www.lowendbox.com/blog/reducing-mysql-memory-usage-for-low-end-boxes/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 01:46:27 +0000</pubDate>
		<dc:creator>LowEndAdmin</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Tuning]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.lowendbox.com/blog/reducing-mysql-memory-usage-for-low-end-boxes/</guid>
		<description><![CDATA[MySQL is pretty much the de facto database engine for most open source scripts, and it is almost-always installed on hosted servers. However the default MySQL installation on Debian/Ubuntu takes around 25MB RSS on a cold-start. Well, not too bad I guess, unless you are running a tight ship with only 64MB of total memory. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mysql.com/">MySQL</a> is pretty much the <em>de facto</em> database engine for most open source scripts, and it is almost-always installed on hosted servers. However the default MySQL installation on Debian/Ubuntu takes around 25MB RSS on a cold-start. Well, not too bad I guess, <em>unless</em> you are running a tight ship with only 64MB of total memory. Depending on how important MySQL is to your stack, you might wish to bring the memory usage down so you can fit other applications in memory.</p>
<p>The easiest way is to start from an existing configuration file to bring down the memory usage, and then tune it to bring back adequate performance. On Debian/Ubuntu you might wish to replace your installed <code>/etc/mysql/my.cnf</code> with <code>my-small.cnf</code> that can be found in <code>/usr/share/doc/my-server-5.0/examples</code>. I am also attaching a <a href="http://www.lowendbox.com/media/mysql/my-lxadmin-centos.cnf">my.cnf here</a> that is taken out from CentOS 4 installation of <a href="http://lxlabs.com/software/lxadmin-sse/">LxAdmin</a> (which has been famous for its low-memory foot print). It is pretty much based on <code>my-small.cnf</code>. Some important notes:</p>
<ul>
<li>
<p><code>skip-bdb</code> and <code>skip-innodb</code> are added, so you don&#8217;t get BSD DB nor InnoDB support. BSD DB support in MySQL is pretty much obsolete, and many open source scripts don&#8217;t rely on the presence of InnoDB. A low end VPS is not likely to enjoy the concurrency InnoDB is offering anyway. Transaction and referential integrity? Real Programmers<sup>TM</sup> write their own rollback routines :)</p>
</li>
<li>
<p><code>key_buffer</code> is <em>only</em> 16K which is far from enough. <code>key_buffer</code> is pretty much one of the most important parameter for MyISAM tables and I usually bump it up to at least 1MB. The same can be said about <code>table_cache</code> &#8212; 4 is way too small. A WordPress page will likely touch 10 tables, and much more for apps like Drupal or MediaWiki.</p>
</li>
<li>
<p>Query cache <em>might</em> be a good thing if you intend to run a busy site on such a low end VPS (provided that it has small data set, mostly read, like blogs, news sites, etc). I have my <code>query_cache_limit</code> set to 256K and <code>query_cache_size</code> set to 4M here.</p>
</li>
</ul>
<p>After a few adjustment you should be able to start mysqld at around 5-6MB RSS. You might need to check the runtime variables to monitor the performance and how everything works out.</p>
<div style="display:none">38.107.179.230</div><hr/><div>Copyright &copy; <a href="http://www.lowendbox.com/">LowEndBox.com</a>. All Rights Reserved.</div>]]></content:encoded>
			<wfw:commentRss>http://www.lowendbox.com/blog/reducing-mysql-memory-usage-for-low-end-boxes/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Tuning for 64MB Virtual Private Server</title>
		<link>http://www.lowendbox.com/blog/tuning-for-64mb-virtual-private-server/</link>
		<comments>http://www.lowendbox.com/blog/tuning-for-64mb-virtual-private-server/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 23:38:11 +0000</pubDate>
		<dc:creator>LowEndAdmin</dc:creator>
				<category><![CDATA[Tuning]]></category>
		<category><![CDATA[vpsvillage.com]]></category>

		<guid isPermaLink="false">http://www.lowendbox.com/blog/tuning-for-64mb-virtual-private-server/</guid>
		<description><![CDATA[Zein: Making the most out of a 64MB VPS &#8212; how Ahmed tuned his 64MB Xen VPS from VPS Village to run Lighttpd, PHP/FastCGI and MySQL. He was also trying to get a Ruby on Rails app running but OOM seems inevitable. Great article on getting PHP applications like WordPress running on a minimal VPS. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.azein.com/blog/2007/10/06/stretching-64mb-as-much-as-you-can/">Zein: Making the most out of a 64MB VPS</a> &#8212; how Ahmed tuned his 64MB Xen VPS from <a href="http://www.lowendbox.com/tag/vpsvillage.com/">VPS Village</a> to run Lighttpd, PHP/FastCGI and MySQL. He was also trying to get a Ruby on Rails app running but OOM seems inevitable. Great article on getting PHP applications like WordPress running on a minimal VPS.</p>
<p>I am taking a similar approach tuning my 64MB VPS from <a href="http://www.lowendbox.com/tag/virtual-dedicated.net/">Virtual-Dedicated.net</a>, except:</p>
<ul>
<li>PHP 5.2 does not need a parent monitoring process if <code>PHP_FCGI_CHILDREN =&gt; 0</code>. Therefore I am running 2x PHP/FastCGI processes with <code>maxprocs =&gt; 2</code> and <code>PHP_FCGI_CHILDREN =&gt; 0</code>.</li>
<li>I haven&#8217;t bothered to run any query cache on MySQL. Or maybe I should :)</li>
<li>SSHD is replaced with <a href="http://matt.ucc.asn.au/dropbear/dropbear.html">Dropbear</a> running off Xinetd, which saves me 1MB idle, and 1MB for every SSH connection.</li>
</ul>
<div style="display:none">38.107.179.230</div><hr/><div>Copyright &copy; <a href="http://www.lowendbox.com/">LowEndBox.com</a>. All Rights Reserved.</div>]]></content:encoded>
			<wfw:commentRss>http://www.lowendbox.com/blog/tuning-for-64mb-virtual-private-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

