<?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>Bigmite Solutions</title>
	<atom:link href="http://www.bigmite.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bigmite.com/blog</link>
	<description>...solving big problems with simple solutions</description>
	<lastBuildDate>Sat, 10 Sep 2011 07:30:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Caching name service to improve unix server stability</title>
		<link>http://www.bigmite.com/blog/2011/07/07/caching-name-service-to-improve-unix-server-stability/</link>
		<comments>http://www.bigmite.com/blog/2011/07/07/caching-name-service-to-improve-unix-server-stability/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 17:12:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.bigmite.com/blog/?p=38</guid>
		<description><![CDATA[Introduction
Over the past few years I&#8217;ve seen a number of cases where Unix systems have suffered serious outages caused by the loss of a primary name server. Such systems appear really slow, and often when used in conjunction with Samba or a remote name service such as Centrify servers may appear to hang.
The main reason [...]]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>Over the past few years I&#8217;ve seen a number of cases where Unix systems have suffered serious outages caused by the loss of a primary name server. Such systems appear really slow, and often when used in conjunction with Samba or a remote name service such as Centrify servers may appear to hang.</p>
<p>The main reason for this is the manner in which Unix performs DNS lookups, by first looking at the primary name server, then trying the secondary etc. Since it is stateless every successive lookup will hit the primary server, even if it is not responding. Since there is a timeout on DNS lookups, it is not before this that it will try the second server causing all processes which require DNS resolution to hang.</p>
<p>On machines with a reasonable degree of DNS lookups, this eventually consumed a large amount of system resources as requests block and accumulate, and in some cases has resulted in servers running out of physical memory.</p>
<h2>Using a bind cache to reduce the problem&#8230;</h2>
<p>One solution is to use name service caching daemons, but experience has shown these can be troublesome. Samba for instance does not work correctly when used in conjunction with the Sun nscd.</p>
<p>The simple and reliable solution is to install a local caching name server, a simple lightweight bind install configured to forward requests to the primary and secondary (and other) name servers, but only listening on localhost, and with zone transfers etc disabled for security reasons. Then the nameserver 127.0.0.1 is added to the servers /etc/resolv.conf to ensure it&#8217;s used. Since bind obeys &#8220;time to live&#8221; cache times, there is no impact on name resolution accuracy.</p>
<p>On failure of a primary name sever, the local caching name server is most likely to hold the required address, but if not will search forwarding servers, then cache the result, hence preventing future delayed lookups.</p>
<h2>Caching Bind Config</h2>
<p>The named.conf file for bind is shown below, the forwarders section should contain the list of name servers from the /etc/resolv.conf, the resolv.conf file should have name server 127.0.0.1 added before the other name servers.</p>
<p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; white-space: pre;">options {</span></p>
<pre>
    listen-on { 127.0.0.1; };

    directory "/var/named";

    dump-file "logs/named_dump.db";

    forwarders {

        //  LOCAL-FORWARDERS

    };

    forward only;

};

 

logging {

    channel "mainlog" {

    file "logs/named.log" versions 3 size 1m;

    print-category yes;

    print-severity yes;

    print-time yes;

};

channel "querylog" {

    file "logs/query.log" versions 2 size 1m;

    print-category yes;

    print-severity yes;

    print-time yes;

};

category queries {

    //  Uncomment next line to log query messages.

     #querylog;

    null;

};

category default { mainlog; };

};
</pre>
<p><a title="Software Solutions, Hardware Solutions" href="/">Bigmite creating software and hardware solutions&#8230;.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigmite.com/blog/2011/07/07/caching-name-service-to-improve-unix-server-stability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chroot sftp using openssh and logging</title>
		<link>http://www.bigmite.com/blog/2010/05/19/chroot-sftp-using-openssh-and-logging/</link>
		<comments>http://www.bigmite.com/blog/2010/05/19/chroot-sftp-using-openssh-and-logging/#comments</comments>
		<pubDate>Wed, 19 May 2010 12:05:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.bigmite.com/blog/?p=31</guid>
		<description><![CDATA[Introduction
I have seen many posts on how to set up chroot jail&#8217;ed sftp using openssh, but few cover the logging aspects in detail. This tries to cover some of the issues and solutions.
SFTP
SFTP is ftp wrapped in a SSH secure environment. It is used to transfer files securely and is now used widely to transfer [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>I have seen many posts on how to set up chroot jail&#8217;ed sftp using openssh, but few cover the logging aspects in detail. This tries to cover some of the issues and solutions.</p>
<h2>SFTP</h2>
<p>SFTP is ftp wrapped in a SSH secure environment. It is used to transfer files securely and is now used widely to transfer files between servers securely. Open SSH is the most common ssh implementation and includes all the required configuration logic to allow group based access control and chroot jail&#8217;ing of users.</p>
<h2>Chroot Configuration</h2>
<p>In this example I am going to set up a group of users that require SFTP access only (no SSH) and are going to copy files to a filesystem on a SFTP server. The location of the filesystem is going to be /sftp and users will reside in seperate folders under here.</p>
<p>Initially a new group should be created, here called &#8220;sftpuser&#8221;. Each user that requires SFTP access will be placed in this group.</p>
<p>The sshd_config (on debian in /etc/ssh) should be edited and the following added on the end:-</p>
<pre>Match group sftpuser
 ChrootDirectory /sftp/%u
 X11Forwarding no
 AllowTcpForwarding no
 ForceCommand internal-sftp -l VERBOSE -f LOCAL6</pre>
<p>This does the following:-</p>
<ol>
<li>Forces all users connecting via ssh on port 22 to have sftp only</li>
<li>Runs their sftp session in a chroot jail in directory /sftp/$USER</li>
<li>Prevents them TCP of X11 forwarding connections</li>
<li>Runs the internal sftp server getting it to log verbose and to syslog channel name <strong>LOCAL6</strong></li>
</ol>
<p>Now a user should be created, without creating a home directory and in the default group <strong>sftpuser</strong>. On ubuntu you can enter:-</p>
<pre>adduser --home / --gecos "First Test SFTP User" --group sftpuser --no-create-home --shell /bin/false testuser1</pre>
<p>The reason the home directory is set to / is that the sftp will chroot to /sftp/testuser1. Next the users home directory will need creating:-</p>
<pre>mkdir /sftp/testuser1
chmod 755 /sftp/testuser1
mkdir /sftp/tstuser1/in
mkdir /sftp/testuser1/out
chown testuser1 /sftp/testuse1/in</pre>
<p>Note that the directory structure and permissions that you set may differ depending on your requirements. The users password should be set, and sshd restarted (on debian service ssh restart).</p>
<p>Now it should be possible to sftp files to the host using the command line sftp tool, but it should not be possible to ssh to the server as user testuser1.</p>
<h2>Logging</h2>
<p>You will see verbose sftp logging being produced in the /var/logmessages for each chroot&#8217;ed user, where by default this should go to the daemon.log. The reason for this is that the chroot&#8217;ed sftp process can not open /dev/log as this is not within the chrooted filesystem.</p>
<p>There are two fixes to this problem, depending on the filesystem configuration.</p>
<h3>If the users sftp directory /sftp/user is on the root filesystem</h3>
<p>You can create a hard link to mimic the device:-</p>
<pre>mkdir /sftp/testuser1/dev
chmod 755 /sftp/testuser1/dev
ln /dev/log /sftp/testuser1/dev/log</pre>
<h3>If the users sftp directory is NOT on the root filesystem</h3>
<p>First syslog or rsyslog will need use an additonal logging socket within the users filesystem. For my example /sftp is a seperate sftp filesystem.</p>
<h4>For Redhat</h4>
<p>On redhat syslog is used, so I altered /etc/sysconfif/syslog so that the line:-</p>
<pre style="padding-left: 30px;">SYSLOGD_OPTIONS="-m 0"</pre>
<p>reads:-</p>
<pre>SYSLOGD_OPTIONS="-m 0 -a /sftp/sftp.log.socket</pre>
<p>Finally the syslog daemon needs to be told to log messages for LOCAL6 to the /var/log/sftp.log file, so the following was added to /etc/syslog.conf:-</p>
<pre style="padding-left: 30px;"># For SFTP logging
local6.*                        /var/log/sftp.log</pre>
<p>and syslog was restarted.</p>
<h4>For Ubuntu Lucid</h4>
<p>On Ubuntu lucid I created /etc/rsyslog.d/sshd.conf containing:-</p>
<pre># Create an additional socket for some of the sshd chrooted users.
$AddUnixListenSocket /sftp/sftp.log.socket
# Log internal-sftp in a separate file
:programname, isequal, "internal-sftp" -/var/log/sftp.log
:programname, isequal, "internal-sftp" ~</pre>
<p>&#8230; and restarted rsyslogd.</p>
<h4>Creating log devices for users</h4>
<p>Now for each user a /dev/log device needs creating:-</p>
<pre>mkdir /sftp/testuser1/dev
chmod 755 /sftp/testuser1/dev
ln /sftp/sftp.log.socket /sftp/testuser1/dev/log</pre>
<h2>Log Rotation</h2>
<p>TBD</p>
<h2>Producing xfer logs</h2>
<p>The format of the logging from openssh&#8217;es sftp server is a little cryptic. The perl <a title="Script to turn open ssh sftp logs to xfer log format" href="/other/createXferLog">script here</a> can be used to produce an proftp like <a title="Information on Xfer Log" href="http://www.castaglia.org/proftpd/doc/xferlog.html">xfer log</a>. <a title="Experts in Software Development" href="/software_development.mhtml">Bigmite Software Solutions </a>are experts in finding simple solutions to everyday problems.</p>
<p>Several people have said they had trouble running the script to produce Xfer logs. I&#8217;ll try to write a wrapper for ubuntu logroate and redhat later, but for now:-</p>
<p>Save script somewhere sensible and run &#8220;chmod +x createXferLog&#8221;, then to create a Xfer log from another log file simply type:-</p>
<p>createXferLog logfile &gt; xfer.log</p>
<p>The file will be the syslog, or daemon log depending on system, the file with sshd logs in,</p>
<p>or</p>
<p>cat logfile | createXferLog &gt; xfer.log</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigmite.com/blog/2010/05/19/chroot-sftp-using-openssh-and-logging/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Poll, Push or Pull &#8211; Which is best&#8230;.</title>
		<link>http://www.bigmite.com/blog/2010/04/23/poll-push-or-pull-which-is-best/</link>
		<comments>http://www.bigmite.com/blog/2010/04/23/poll-push-or-pull-which-is-best/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 10:55:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.bigmite.com/blog/?p=26</guid>
		<description><![CDATA[What do we mean by &#8220;Poll&#8221;, &#8220;Push&#8221; and &#8220;Pull&#8221; in terms of data communication
Communications systems either &#8220;Push&#8221; or &#8220;Pull&#8221; data, but in some cases, when you need to know if anything is waiting a &#8220;Poll&#8221; is performed, these techniques each have advantages and disadvantages discussed here.
Polling
Polling is asking whether data is available, or can be [...]]]></description>
			<content:encoded><![CDATA[<h2>What do we mean by &#8220;Poll&#8221;, &#8220;Push&#8221; and &#8220;Pull&#8221; in terms of data communication</h2>
<p>Communications systems either &#8220;Push&#8221; or &#8220;Pull&#8221; data, but in some cases, when you need to know if anything is waiting a &#8220;Poll&#8221; is performed, these techniques each have advantages and disadvantages discussed here.</p>
<h2>Polling</h2>
<p>Polling is asking whether data is available, or can be sent, for example the pop3 protocol used by main readers. It is very simple and has the advantage that the server being polled need not know anything about the polling client state. The polling client must make periodic requests to the server to determine if data is ready or can be sent.</p>
<p>The disadvantages of &#8220;Polling&#8221; are that the polling client will not know exactly when it can send or receive data, hence to reduce latency the poll interval may need to be quite frequent increasing the server overhead, especially if it serves a number of clients.</p>
<p>If the polling interval is set to <em>n</em>, and the data transfer time <em>m</em>, then the average delivery/fetch latency is <em>n/2 + m</em>. This can be a limit in many systems.</p>
<p>Computer hardware has historically suffered from issues where some hardware did not use interrupts to indicate data reception, or, like in the PC the old interrupt controller having limited interrupts caused devices to share an interrupt. This in turn increased interrupt latency as the <a title="IBM PC Wiki" href="http://en.wikipedia.org/wiki/IBM_Personal_Computer">IBM PC</a> had to <strong>poll</strong> all the hardware devices sharing this interrupt to determine the interrupt source. Hence the evolution of the <a title="APIC Controller" href="http://en.wikipedia.org/wiki/Advanced_Programmable_Interrupt_Controller">APIC</a>.</p>
<p>Polling is a solution only to used where servers need not know availability of clients, low latency is unimportant and the host being polled is able to handle the amount of polling requests.</p>
<p>Examples of services using &#8220;Poll&#8221; are <a title="NTP Time Synchornisation" href="http://www.ntp.org/">NTP</a>, <a title="Post Office Protocol V3" href="http://www.ietf.org/rfc/rfc1939.txt">POP3</a>,</p>
<h2>Pushing</h2>
<p>Pushing of data is highly efficient and is where a host pushes data to the receiving host. Many protocols use such schemes such as:-</p>
<ul>
<li><a title="open source printing system developed by Apple" href="http://www.cups.org/">Cups </a>(Printed files are pushed to print server)</li>
<li><a title="File Transfer Protocol" href="http://www.faqs.org/rfcs/rfc959.html">FTP</a> (oddly uses &#8220;Pull&#8221; as well) (files are ushed to remove server)</li>
<li><a title="Unix Line Printer Daemon Protocol" href="http://www.ietf.org/rfc/rfc1179.txt">LPR</a> (Printed files are pushed to print server)</li>
<li><a title="Secure File Transfer Protocol" href="http://en.wikipedia.org/wiki/SSH_file_transfer_protocol">SFTP</a> (Secure FTP using ssh wrapper)</li>
<li><a title="Simple Network Messaging Protocol" href="http://en.wikipedia.org/wiki/Simple_Network_Management_Protocol">SNMP</a> (Simple Network Messaging Protocol)</li>
<li><a title="Simple Mail Transfer Protocol" href="http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol">SMTP</a> (Internet email delivery &#8211; very old &#8211; very reliable)</li>
<li>Hardware Interrupts</li>
</ul>
<p>&#8220;Pushing&#8221; is best used where data is ready for delivery and the client can accept data at any time.</p>
<h3>Double Buffering</h3>
<p>In some cases, such as writing large amounts of data to a &#8220;block&#8221; based piece of hardware, double buffering can be used to vastly reduce latency.</p>
<p>Consider a network adapter, which has an output buffer, and interrupts when it has completed a transmit. The OS writes a packet of data to the buffer, then waits for the card to send the data. When the hardware has successfully send the data it interrupts the OS to inform that it is ready to receive more data, but the time taken for the OS to service the interrupt filling the transmit buffer may delay a successive network transmit, adding unwanted delay between packets.</p>
<p>The solution is to utilise two transmit buffers in the hardware device, buffer a and b. Following successful transmission of buffer a, the network adapter will start to tranmit the data in buffer b (if ready) as well as interrupt the computer to instigate a data copy to buffer a. This ensures that the delay following the interrupt and the OS copy of data to buffer a does not add additional latency to the system. The OS software requires little change to cater for this type of system, but the throughput gains are massive. The overall latency of the system is not reduced, but the throughput is increased.</p>
<h1>Pulling</h1>
<p>Pulling of data is done when a client requires data, and is normally served by fast services. Most client user interfaces use &#8220;Pull&#8221; type services to achieve the fast response expected by a user. Examples of such services are:-</p>
<ul>
<li>FTP</li>
<li><a title="Hypertext Transfer Protocol" href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">HTTP</a> (driving the internet)</li>
</ul>
<p>The HTTP protocol is a best use case, where users pull content &#8220;On Demand&#8221; and has driven the last 20 years of Internet development.</p>
<h2>Conclusion</h2>
<p>Most data communications systems work best when &#8220;Pulling&#8221; or &#8220;Pushing&#8221; data, the use of a &#8220;Poll&#8221; type system should be avoided unless their is a clear business case.</p>
<p>When designing systems it&#8217;s often simpler to implement a scheme which works &#8220;Sufficiently Well&#8221;, but if designed inappropriately  requires more resources and power. It is often possible to implement systems that utilise very few resources by careful interface designs, and for low power embedded devices this is so important.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigmite.com/blog/2010/04/23/poll-push-or-pull-which-is-best/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>High Performance Hosting &#8211; Unfinished</title>
		<link>http://www.bigmite.com/blog/2010/04/09/high-performance-hosting-unfinished/</link>
		<comments>http://www.bigmite.com/blog/2010/04/09/high-performance-hosting-unfinished/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 10:55:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.bigmite.com/blog/?p=16</guid>
		<description><![CDATA[Introduction
Over the years I&#8217;ve been asked to produce a number of high reliability high throughout web hosting solutions. Although there are a number of off the shelf solutions that are expensive, the true high availability solutions can be realised using standard linux builds.
In the following article I&#8217;ll outline aids to help you build low cost [...]]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>Over the years I&#8217;ve been asked to produce a number of high reliability high throughout web hosting solutions. Although there are a number of off the shelf solutions that are expensive, the true high availability solutions can be realised using standard linux builds.</p>
<p>In the following article I&#8217;ll outline aids to help you build low cost HA solutions using linux.</p>
<h1>Load Balancing</h1>
<p>For high throughput application it is often not possible to host on a single server. In addition the availability of a single host cannot be guaranteed, so a multi hosted solution is often better.</p>
<p>Developing web applications that can run on multiple servers poses a number of problems, mainly around state maintenance and session management, but these will be covered elsewhere.</p>
<h2>Commercial Load Balancers</h2>
<p>Commercial hardware load balancers offer a range of features, but you must always consider the &#8220;Single Point of Failure&#8221; problem, even if the load balancer has dual power supplies etc it can fail, or require replacement. It is always better to buy two complete units that can work in parallel offering higher availability. Upgrading a single unit can be done without fear of loss off service.</p>
<p>By using an external pair of round robin DNS entries it is possible to spread the load across balancers. In the event of a balancer failing you can move the failed IP address to the remaining balancer.</p>
<p>Commercial load balancers are expensive!.</p>
<h2>Linux Load Balancers</h2>
<p>Using two linux servers and a <a title="High Availibility Linux Solutions" href="http://www.linux-ha.org/">high availability heartbeat configuration</a> provides a far cheaper solution had has been used by <a title="Bigmite Webhosting Solutions" href="http://www.bigmite.com/">Bigmite Hosting Solutions</a>. Using two linux servers in a HA configuration and running suitable load balancing software a high throughput can be achieved.</p>
<p>A small server can saturate a 1Gb/s network link, leaving the back end application servers to do the work. The choice of load balancing software depends on your requireements such as:-</p>
<ol>
<li>Session Management</li>
<li>Keep Alives</li>
<li>Monitoring</li>
<li>Latency</li>
</ol>
<p>If no session management is required (such as a static site) then the kernel based ipvs (<a title="Linux Virtual Server - Load Balancing" href="http://www.linuxvirtualserver.org/">Linux Virtual Server</a>) can be used, this is part of the standard linux distribution, and is simple to configure and very reliable.</p>
<p>If sessions need to be maintained to a client then layer x based load balancing is required. Packages such as  <a title="HA Proxy - Load Balancing" href="http://haproxy.1wt.eu/">HAProxy</a> and <a title="balanceNG - Load Balancer" href="http://www.inlab.de/balanceng/">BalanceNG</a> (which is next generation of the <a title="Balance - Load Balancer" href="http://www.inlab.de/balance.html">balance </a>software) offer these features.</p>
<h1>Heartbeat</h1>
<p>Heatbeat (www.linuxha.org</p>
<h1>Requests for comments&#8230;&#8230;</h1>
<p>It is NOT finished&#8230;. it&#8217;s just ready for comments&#8230;. I&#8217;ve two busy to complete &#8211; please comment, and I&#8217;ll add your comments&#8230;..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigmite.com/blog/2010/04/09/high-performance-hosting-unfinished/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Low Power Computers</title>
		<link>http://www.bigmite.com/blog/2010/03/30/low-power-computers/</link>
		<comments>http://www.bigmite.com/blog/2010/03/30/low-power-computers/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 08:17:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.bigmite.com/blog/?p=11</guid>
		<description><![CDATA[In our office we have a development machine which runs all our websites in development along with a number of other applications. This computer is powered 24/7 and consumed considerable energy. The plan was to build a new faster machine that used a fraction of the energy.
The requirements were large storage (1T byte), 4G ram, [...]]]></description>
			<content:encoded><![CDATA[<p>In our office we have a development machine which runs all our websites in development along with a number of other applications. This computer is powered 24/7 and consumed considerable energy. The plan was to build a new faster machine that used a fraction of the energy.</p>
<p>The requirements were large storage (1T byte), 4G ram, capability to drive a large DVI panel for developers and a large number of USB ports. In addition we used an ADSL router which itself consumed 8 watts so using an ADSL USB model plugged into this machine would save further energy. Originally the server had raid disks, but the choice was made to backup regularly and use a single disk to save energy.</p>
<p>It&#8217;s worth noting that units using small power adapters have poor load factors and even if they consume a small amount of energy the effective transformer losses at the local substation due to poor load factors increase losses &#8211; so eliminating additional system components saves more energy than you expect.</p>
<p>The chosen components were:-</p>
<ul>
<li><strong>ASUS AT3N7A-I motherboard</strong> &#8211; this is a dual core atom motherboard with a nvidia ION chipset providing exceptional graphics (DVI connector) and low power consumption. In it&#8217;s mini-itx form factor it also reduces space requirements.</li>
<li><strong>ST31000528AS Seagate 1TB SATA HDD</strong> &#8211; This is the seagate low power version, and performed better than expected.</li>
<li><strong>4G Kingston RAM</strong> &#8211; Chose a manufacturer that offered a lower power device, there is a vast variation in power consumption of memory devices.</li>
<li><strong>Noah Mini-ITX Case &#8211; Silver/Black </strong>- this case had in integral DC-DC adaptor and required no additional fans. It was strongly constructed and had a range of front panel connectors.</li>
<li><strong>Speedtouch 330 USB Modem</strong> &#8211; this modem is a third generation speedtouch modem, and is well supported in linux and consumed minimal power.</li>
<li><strong>Ubuntu Linux OS</strong> &#8211; I&#8217;m a Unix developer, so using windows would have been madness &#8211; but Unix has a smaller memory footprint and lower CPU utilisation on average. In addition it&#8217;s easier to run a large number of Unix applications in parallel than on a Windows system as the library loading, and configuration file separation facilitate better isolation of applications.</li>
</ul>
<div id="attachment_12" class="wp-caption alignleft" style="width: 460px"><a href="http://www.bigmite.com/blog/wp-content/uploads/2010/03/30032010036.jpg"><img class="size-large wp-image-12" title="30032010036" src="http://www.bigmite.com/blog/wp-content/uploads/2010/03/30032010036-1024x808.jpg" alt="Low Power Server" width="450" height="355" /></a><p class="wp-caption-text">New Low Power Office Server</p></div>
<p>Most of these components were purchased from LinITX in the UK who helped with the case choice.</p>
<p>The large number of cables feed all the office printers, scanners etc along with the USB ADSL modem.</p>
<p>Further power savings were made by turning off all unused devices (printers scanners etc).</p>
<p>The final power consumption was less than 35 watts, which considering how much work this machine is doing is remarkable. It is running ubuntu Karmic, awaiting the release of 10.04 LTS (the 8.04 version did not support the new nvidia graphics properly out of the box).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigmite.com/blog/2010/03/30/low-power-computers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Log File Rotation</title>
		<link>http://www.bigmite.com/blog/2010/03/24/log-file-rotation/</link>
		<comments>http://www.bigmite.com/blog/2010/03/24/log-file-rotation/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 17:15:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.bigmite.com/blog/?p=5</guid>
		<description><![CDATA[Introduction
File rotation, or log file rotation may seem simple, but for most high throughput applications such as web servers the problems of multiple threads or processes logging to the same file pose problems.
In this example we have a multi process multi thread service which logs incoming requests to a file, the process is written for [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>File rotation, or log file rotation may seem simple, but for most high throughput applications such as web servers the problems of multiple threads or processes logging to the same file pose problems.</p>
<p>In this example we have a multi process multi thread service which logs incoming requests to a file, the process is written for speed, hence the logging overhead has to be very light, the code is running on a linux base OS.</p>
<p>The file rotation can be rotated by either,</p>
<ol>
<li>the client program, in which case all processes/threads must cooperate together</li>
<li>a separate rotate program, which signals to the clients to close the file and open a new file</li>
</ol>
<h2>Evaluation</h2>
<p>Initially looking at current applications such as apache and mysql,</p>
<p><strong>APACHE:</strong> The apache webserver on startup opens a file or pipe to a program, this file descriptor is passed to all child processes and threads which log to this file. This model does not rotate files, but if the pipe is opened to a seperate process (rotatelogs) then this process can handle writing to a rotated file. This model seems tidy, but relies on a context switch to ensure the data is logged, if many processes are logging large amounts of data it doubles the number of required context switches to log the data.</p>
<p><strong>MYSQL</strong>: Mysql opens the file for append, writes the log line then closes the file, hence is not optimised for speed, when logging lots of data many fopen and fclose system calls are handled.</p>
<p>The optimal solution will:-</p>
<ul>
<li>allow the file to remain open</li>
<li>require minimal overhead for checking for rotation</li>
<li>allow a separate program to rotate removing the rotation overhead from each process/thread</li>
</ul>
<h2>Solution</h2>
<p>The solution required a means for a rotation process to signal to the logging server(s) that the file has been rotated. Renaming of a file does not effect the file handle properties, but if the file permissions or owner are changed the logging client can fstat the handle and check for a permission/ower change before a write. The fstat system call is faster than a normal stat since it uses the inode stored in file handle.</p>
<p>Since the fstat call is very lightweight, and will be kernel optimised by the use of the buffer cache the client log process need only open the file for append, then before each write fstat the handle and check to see if the owner or permissions have changed, and if so close the file and reopen a new file. Using this schema processes which have a number of workers can still all write to a log file concurrently as the write (with append) is atomic.</p>
<p>The rotation process simply renames the file to a file with a suitable date and change the owner or permissions.</p>
<p>There is a tiny race condition between the client fstat and write which would cause the client to write a log line to the end of a rotated file in rare conditions, but since this is a tiny time period, as long as processing of the rotated log file is deferred for a suitable period following rotation all will b OK.</p>
<p>An example Perl implementation of a client logger is provided, it should be noted that this uses a stat on the filehandle which Perl actually calls fstat internally (running strace on the process determined this) &#8211; <a href="/BigLogger.pm">download this file</a>.</p>
<h2>Limitations</h2>
<p>Unfortunately NFS has limitations (unsure of v4),  a linux manual page states:-</p>
<pre>       O_APPEND
              The file is opened in append mode. Before each write(), the file
              offset is positioned at the end of the file, as if with lseek().
              O_APPEND may lead to corrupted files on NFS file systems if more
              than one process appends data  to  a  file  at  once.   This  is
              because  NFS does not support appending to a file, so the client
              kernel has to simulate it, which can't be done  without  a  race
              condition.</pre>
<p>So writing to an NFS file using append may not work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigmite.com/blog/2010/03/24/log-file-rotation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Solving Problems</title>
		<link>http://www.bigmite.com/blog/2010/03/24/hello-world/</link>
		<comments>http://www.bigmite.com/blog/2010/03/24/hello-world/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 16:02:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.bigmite.com/blog/?p=1</guid>
		<description><![CDATA[Welcome to the Bigmite Software Solutions.
Over the next few months we&#8217;ll attempt to document solutions to simple problems experienced in our daily work. These problems may be unique to the environment on which they run, but offer an insight into software architecture and OS interaction.
]]></description>
			<content:encoded><![CDATA[<p>Welcome to the Bigmite Software Solutions.</p>
<p>Over the next few months we&#8217;ll attempt to document solutions to simple problems experienced in our daily work. These problems may be unique to the environment on which they run, but offer an insight into software architecture and OS interaction.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigmite.com/blog/2010/03/24/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

