<?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>Technology: Learn and Share &#187; Server load</title>
	<atom:link href="http://crazytoon.com/category/server-load/feed/" rel="self" type="application/rss+xml" />
	<link>http://crazytoon.com</link>
	<description>Enterprise level solutions, LAMP, Linux, Apache, MySQL, PHP, Perl, Windows, Cache, Optimization</description>
	<lastBuildDate>Thu, 20 Oct 2011 20:56:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Apache/http monitoring:  monitor http traffic in realtime using httptop</title>
		<link>http://crazytoon.com/2008/08/12/apachehttp-monitoring-monitor-http-traffic-in-realtime-using-httptop/</link>
		<comments>http://crazytoon.com/2008/08/12/apachehttp-monitoring-monitor-http-traffic-in-realtime-using-httptop/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 20:05:59 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Server load]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[apache monitoring]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[realtime monitoring]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=86</guid>
		<description><![CDATA[Server monitoring is a big part of running a solid web site.  As an admin, you must know what is going on your server.  One of the tools most Linux/Unix admins are used to is called &#8220;top&#8221;.  &#8220;top&#8221; by itself is a very powerful tool.  Here is a quick guide on how to read output [...]]]></description>
			<content:encoded><![CDATA[<p>Server monitoring is a big part of running a solid web site.  As an admin, you must know what is going on your server.  One of the tools most Linux/Unix admins are used to is called &#8220;top&#8221;.  &#8220;<a title="Introduction to load averages under &quot;top&quot;" href="http://crazytoon.com/2007/01/29/what-is-this-load-average-i-keep-hearing-about/" target="_blank">top</a>&#8221; by itself is a very powerful tool.  Here is a quick guide on how to read output from top:  <a title="Introduction to load averages under &quot;top&quot;" href="http://crazytoon.com/2007/01/29/what-is-this-load-average-i-keep-hearing-about/">introduction to load averages under top</a>.  It just makes sense that somebody went and created http<strong>top</strong> to monitor http traffic.</p>
<p>Install perl modules:</p>
<p><code>install Term::ReadKey<br />
install File::Tail<br />
install Time::HiRes<br />
</code><br />
Now copy paste the script below and save it in a location and set +x attribute on it so you can execute it.  On my setup, I have the script under /usr/bin/httptop:</p>
<p><code>#!/usr/bin/perl -w<br />
use Time::HiRes qw( time );<br />
use File::Tail (  );<br />
use Term::ReadKey;<br />
use Getopt::Std;<br />
use strict;<br />
### Defaults you might be interested in adjusting.<br />
my $Update = 2; # update every n secs<br />
my $Backtrack = 250; # backtrack n lines on startup<br />
my @Paths = qw(<br />
%<br />
/title/%/logs/access_log<br />
/var/log/httpd/%/access_log<br />
/usr/local/apache/logs/%/access_log<br />
);<br />
my $Log_Format = "combined";<br />
my %Log_Fields = (<br />
combined =&gt; [qw/ Host x x Time URI Response x Referer Client /],<br />
vhost =&gt; [qw/ VHost Host x x Time URI Response x Referer Client /]<br />
);<br />
### Constants &amp; other thingies. Nothing to see here. Move along.<br />
my $Version = "0.4.1";<br />
sub by_hits_per (  ) { $b-&gt;{Rate} &lt;=&gt; $a-&gt;{Rate} }<br />
sub by_total (  ) { $b-&gt;{Total} &lt;=&gt; $a-&gt;{Total} }<br />
sub by_age (  ) { $a-&gt;{Last} &lt;=&gt; $b-&gt;{Last} }<br />
my $last_field = "Client";<br />
my $index = "Host";<br />
my $show_help = 0;<br />
my $order = \&amp;by_hits_per;<br />
my $Help = "htlwufd?q";<br />
my %Keys = (<br />
h =&gt; [ "Order by hits/second" =&gt; sub { $order = \&amp;by_hits_per } ],<br />
t =&gt; [ "Order by total recorded hits" =&gt; sub { $order = \&amp;by_total } ],<br />
l =&gt; [ "Order by most recent hits" =&gt; sub { $order = \&amp;by_age } ],<br />
w =&gt; [ "Show remote host" =&gt; sub { $index = "Host" } ],<br />
u =&gt; [ "Show requested URI" =&gt; sub { $index = "URI" } ],<br />
f =&gt; [ "Show referring URL" =&gt; sub { $index = "Referer" } ],<br />
d =&gt; [ "Show referring domain" =&gt; sub { $index = "Domain" } ],<br />
'?' =&gt; [ "Help (this thing here)" =&gt; sub { $show_help++ } ],<br />
q =&gt; [ "Quit" =&gt; sub { exit } ]<br />
);<br />
my @Display_Fields = qw/ Host Date URI Response Client Referer Domain /;<br />
my @Record_Fields = qw/ Host URI Referer Domain /;<br />
my $Max_Index_Width = 50;<br />
my $Initial_TTL = 50;<br />
my @Months = qw/ Jan Feb Mar Apr May Jun Jul Aug Sep Nov Dec /;<br />
my %Term = (<br />
HOME =&gt; "\033[H",<br />
CLS =&gt; "\033[2J",<br />
START_TITLE =&gt; "\033]0;", # for xterms etc.<br />
END_TITLE =&gt; "\007",<br />
START_RV =&gt; "\033[7m",<br />
END_RV =&gt; "\033[m"<br />
);<br />
my ( %hist, %opt, $spec );<br />
$SIG{INT} = sub { exit };<br />
END { ReadMode 0 };<br />
### Subs.<br />
sub refresh_output<br />
{<br />
my ( $cols, $rows ) = GetTerminalSize;<br />
my $show = $rows - 3;<br />
my $count = $show;<br />
my $now = (shift || time);<br />
for my $type ( values %hist ) {<br />
for my $peer ( values %$type ) {<br />
# if ( --$peer-&gt;{_Ttl} &gt; 0 ) {<br />
my $delta = $now - $peer-&gt;{Start};<br />
if ( $delta &gt;= 1 ) {<br />
$peer-&gt;{ Rate } = $peer-&gt;{ Total } / $delta;<br />
} else {<br />
$peer-&gt;{ Rate } = 0<br />
}<br />
$peer-&gt;{ Last } = int( $now - $peer-&gt;{ Date } );<br />
# } else {<br />
# delete $type-&gt;{$peer}<br />
# }<br />
}<br />
}<br />
$count = scalar( values %{$hist{$index}} ) - 1 if $show &gt;= scalar values %{$hist{$index}};<br />
my @list = ( sort $order values %{$hist{$index}} )[ 0 .. $count ];<br />
my $first = 0;<br />
$first = ( $first &lt;= $_ ? $_ + 1 : $first ) for map { $_ ? length($_-&gt;{$index}) : 0 } @list;<br />
$first = $Max_Index_Width if $Max_Index_Width &lt; $first;<br />
print $Term{START_TITLE}, "Monitoring $spec at: ", scalar localtime, $Term{END_TITLE} if $ENV{TERM} eq "xterm"; # UGLY!!!<br />
my $help = "Help/?";<br />
my $head = sprintf( "%-${first}s %6s %4s %4s %s (%d total)",<br />
$index, qw{ Hits/s Tot Last }, $last_field,<br />
scalar keys %{$hist{$index}}<br />
);<br />
#<br />
# Truncate status line if need be<br />
#<br />
$head = substr($head, 0, ($cols - length($help)));<br />
print @Term{"HOME", "START_RV"}, $head, " " x ($cols - length($head) - length($help)), $help, $Term{END_RV}, "\n";<br />
for ( @list ) {<br />
# $_-&gt;{_Ttl}++;<br />
my $line = sprintf( "%-${first}s %6.3f %4d %3d %s",<br />
substr( $_-&gt;{$index}, 0, $Max_Index_Width ), @$_{(qw{ Rate Total Last }, $last_field)} );<br />
if ( length($line) &gt; $cols ) {<br />
substr( $line, $cols - 1 ) = "";<br />
} else {<br />
$line .= " " x ($cols - length($line));<br />
}<br />
print $line, "\n";<br />
}<br />
print " " x $cols, "\n" while $count++ &lt; $show;<br />
}<br />
sub process_line<br />
{<br />
my $line = shift;<br />
my $now = ( shift || time );<br />
my %hit;<br />
chomp $line;<br />
@hit{@{$Log_Fields{$Log_Format}}} = grep( $_, split( /"([^"]+)"|\[([^]]+)\]|\s/o, $line ) );<br />
$hit{ URI } =~ s/HTTP\/1\S+//gos;<br />
$hit{ Referer } = "&lt;unknown&gt;" if not $hit{Referer} or $hit{Referer} eq "-";<br />
( $hit{Domain} = $hit{Referer} ) =~ s#^\w+://([^/]+).*$#$1#os;<br />
$hit{ Client } ||= "&lt;none&gt;";<br />
$hit{ Client } =~ s/Mozilla\/[\w.]+ \(compatible; /(/gos;<br />
$hit{ Client } =~ s/[^\x20-\x7f]//gos;<br />
# if $now is negative, try to guess how old the hit is based on the time stamp.<br />
if ( $now &lt; 0 ) {<br />
my @hit_t = ( split( m![:/\s]!o, $hit{ Time } ))[ 0 .. 5 ];<br />
my @now_t = ( localtime )[ 3, 4, 5, 2, 1, 0 ];<br />
my @mag = ( 3600, 60, 1 );<br />
# If the hit didn't parse right, or didn't happen today, the hell with it.<br />
return unless $hit_t[2] == ( $now_t[2] + 1900 )<br />
and $hit_t[1] eq $Months[ $now_t[1] ]<br />
and $hit_t[0] == $now_t[0];<br />
splice( @hit_t, 0, 3 );<br />
splice( @now_t, 0, 3 );<br />
# Work backward to the UNIX time of the hit.<br />
$now = time;<br />
$now -= (shift( @now_t ) - shift( @hit_t )) * $_ for ( 3600, 60, 1 );<br />
}<br />
$hit{ Date } = $now;<br />
for my $field ( @Record_Fields ) {<br />
my $peer = ( $hist{$field}{$hit{$field}} ||= { Start =&gt; $now, _Ttl =&gt; $Initial_TTL } );<br />
@$peer{ @Display_Fields } = @hit{ @Display_Fields };<br />
$peer-&gt;{ Total }++;<br />
}<br />
}<br />
sub display_help {<br />
my $msg = "httptop v.$Version";<br />
print @Term{qw/ HOME CLS START_RV /}, $msg, $Term{END_RV}, "\n\n";<br />
print " " x 4, $_, " " x 8, $Keys{$_}[0], "\n" for ( split "", $Help );<br />
print "\nPress any key to continue.\n";<br />
}<br />
### Init.<br />
getopt( 'frb' =&gt; \%opt );<br />
$Backtrack = $opt{b} if $opt{b};<br />
$Update = $opt{r} if $opt{r};<br />
$Log_Format = $opt{f} if $opt{f};<br />
$spec = $ARGV[0];<br />
die &lt;&lt;End unless $spec and $Log_Fields{$Log_Format};<br />
Usage: $0 [-f &lt;format&gt;] [-r &lt;refresh_secs&gt;] [-b &lt;backtrack_lines&gt;] &lt;logdir | path_to_log&gt;<br />
Valid formats are: @{[ join ", ", keys %Log_Fields ]}.<br />
End<br />
for ( @Paths ) {<br />
last if -r $spec;<br />
( $spec = $_ ) =~ s/%/$ARGV[0]/gos;<br />
}<br />
die "No access_log $ARGV[0] found.\n" unless -r $spec;<br />
my $file = File::Tail-&gt;new(<br />
name =&gt; $spec,<br />
interval =&gt; $Update / 2,<br />
maxinterval =&gt; $Update,<br />
tail =&gt; $Backtrack,<br />
nowait =&gt; 1<br />
) or die "$spec: $!";<br />
my $last_update = time;<br />
my ( $line, $now );<br />
# Backtracking.<br />
while ( $Backtrack-- &gt; 0 ) {<br />
last unless $line = $file-&gt;read;<br />
process_line( $line, -1 );<br />
}<br />
$file-&gt;nowait( 0 );<br />
ReadMode 4; # Echo off.<br />
print @Term{"HOME", "CLS"}; # Home &amp; clear.<br />
refresh_output;<br />
### Main loop.<br />
while (defined( $line = $file-&gt;read )) {<br />
$now = time;<br />
process_line( $line, $now );<br />
while ( $line = lc ReadKey(-1) ) {<br />
$show_help = 0 if $show_help;<br />
$Keys{$line}[1]-&gt;(  ) if $Keys{$line};<br />
}<br />
if ( $show_help == 1 ) {<br />
display_help;<br />
$show_help++; # Don't display help again.<br />
} elsif ( $now - $last_update &gt; $Update and not $show_help ) {<br />
$last_update = $now;<br />
refresh_output( $now );<br />
}<br />
}</code></p>
<p>Save/exit and make sure you make it executable by setting it to +x (<a title="man chmod - man page for chmod" href="http://www.lamp-tips.com/man-pages/chmod/" target="_blank">chmod </a>+x httptop)</p>
<p>Now you can run httptop by typing:  <code>httptop -f combined -r 1 /usr/local/apache2/logs/access_log</code></p>
<p>NOTE:  Your access_log file might be in different location.  Point to the right location.  This sets the refresh rate to 1 sec (-r 1).  Now you can run httptop any time you want to checkout how your http traffic is doing.  Remember to press &#8220;?&#8221; to get help once you are in.</p>
<p>—————</p>
<p><small>DISCLAIMER: As always, if you find any inaccurate information, please comment and let me know. When you do comment, make sure you give me some references to confirm.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/08/12/apachehttp-monitoring-monitor-http-traffic-in-realtime-using-httptop/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Apache2 gzip compression:  How do I speed up my website download time?</title>
		<link>http://crazytoon.com/2008/05/29/apache-gzip-compression-how-do-i-speed-up-my-website-download-time/</link>
		<comments>http://crazytoon.com/2008/05/29/apache-gzip-compression-how-do-i-speed-up-my-website-download-time/#comments</comments>
		<pubDate>Thu, 29 May 2008 15:54:06 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Server load]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=76</guid>
		<description><![CDATA[One of the things people tend to forget is the ability for web servers to compress content before sending it back to client.  Client&#8217;s browser then uncompresses the data and displays it to the user.  Pretty much all of the recent browsers support gzip compression.  In this post, I will go over [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things people tend to forget is the ability for web servers to compress content before sending it back to client.  Client&#8217;s browser then uncompresses the data and displays it to the user.  Pretty much all of the recent browsers support gzip compression.  In this post, I will go over how to setup apache2 to use compression.  First let&#8217;s see if your Apache installation has &#8220;deflate&#8221; enabled.  You can check to see if you have deflate by typing:</p>
<p><code># /usr/local/apache2/bin/apachectl -t -D DUMP_MODULES<br />
Loaded Modules:<br />
...<br />
deflate_module (static)<br />
...<br />
Syntax OK</code></p>
<p>If you don&#8217;t have have deflate_module, you would have to recompile your apache with &#8220;&#8211;enable-deflate&#8221; option.</p>
<p>Going forward, I am going to assume you have deflate_module.  Add the following to your apache conf file:</p>
<p><code>&lt;Location /&gt;<br />
SetOutputFilter DEFLATE<br />
BrowserMatch ^Mozilla/4\.0[678] no-gzip\<br />
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html<br />
# Don't compress images<br />
SetEnvIfNoCase Request_URI \<br />
<strong>\.(?:gif|jpe?g|png)$ no-gzip dont-vary</strong><br />
&lt;/Location&gt;</code></p>
<p>The main thing you need to configure is the line which says &#8220;no-gzip dont-vary&#8221; also in bold above.  This tells apache to not compress certain type of files.  I have noticed on some of my sites that swf (flash) files do not work as expected if they are compressed.  So if you have swf files in your site, you may want to add <strong>|swf </strong>right after png.</p>
<p>This is all what it takes for you to enable gzip compression in Apache2.  Once you restart your apache so it reads the conf file, you can test if your site is getting compressed or not by using this tool:  <a title="http://www.gidnetwork.com/tools/gzip-test.php" href="http://www.gidnetwork.com/tools/gzip-test.php" target="_blank">http://www.gidnetwork.com/tools/gzip-test.php</a></p>
<p>Here are the results for my blog:</p>
<p style="padding-left: 30px;">Results for: http://crazytoon.com<br />
Web page compressed? 	Yes<br />
Compression type? 	gzip<br />
Size, Markup (bytes) 	57,337<br />
Size, Compressed (bytes) 	11,666<br />
Compression % 	79.7</p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/05/29/apache-gzip-compression-how-do-i-speed-up-my-website-download-time/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Ramdisk:  How do you install and set up Ramdisk under Linux (CentOS, RHEL, Fedora)?</title>
		<link>http://crazytoon.com/2007/06/01/ramdisk-how-do-you-install-and-set-up-ramdisk-under-linux-centos-rhel-fedora/</link>
		<comments>http://crazytoon.com/2007/06/01/ramdisk-how-do-you-install-and-set-up-ramdisk-under-linux-centos-rhel-fedora/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 23:36:21 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[Server load]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/06/01/ramdisk-how-do-you-install-and-set-up-ramdisk-under-linux-centos-rhel-fedora/</guid>
		<description><![CDATA[Ramdisk is very good to have if you want something to stay in memory.   Files in memory makes it so you can access them with out having to access hard drive all the time.  Perfect candidates would be things which do not change eg. web images or downloadable files, etc.  If you have Linux Kernel [...]]]></description>
			<content:encoded><![CDATA[<p>Ramdisk is very good to have if you want something to stay in memory.   Files in memory makes it so you can access them with out having to access hard drive all the time.  Perfect candidates would be things which do not change eg. web images or downloadable files, etc.  If you have Linux Kernel 2.4 or later, you already have support of ramdisk built in.  You can check if ramdisk is setup by doing: </p>
<p><code># dmesg | grep RAMDISK<br />
RAMDISK driver initialized: 16 RAM disks of 16384K size 1024 blocksize</code></p>
<p>You should get above output on CentOS and RHEL.  Other linux flavors will have similar output as well.  If you would like to see how they are named and what you would need to refer to, do the following:</p>
<p><code># ls -l /dev/ram*<br />
lrwxrwxrwx 1 root root 4 Apr 24 12:05 /dev/ram -&gt; ram1<br />
brw-rw---- 1 root disk 1, 0 Apr 24 12:05 /dev/ram0<br />
brw-rw---- 1 root disk 1, 1 Apr 24 12:05 /dev/ram1<br />
brw-rw---- 1 root disk 1, 10 Apr 24 12:05 /dev/ram10<br />
brw-rw---- 1 root disk 1, 11 Apr 24 12:05 /dev/ram11<br />
brw-rw---- 1 root disk 1, 12 Apr 24 12:05 /dev/ram12<br />
brw-rw---- 1 root disk 1, 13 Apr 24 12:05 /dev/ram13<br />
brw-rw---- 1 root disk 1, 14 Apr 24 12:05 /dev/ram14<br />
brw-rw---- 1 root disk 1, 15 Apr 24 12:05 /dev/ram15<br />
brw-rw---- 1 root disk 1, 2 Apr 24 12:05 /dev/ram2<br />
brw-rw---- 1 root disk 1, 3 Apr 24 12:05 /dev/ram3<br />
brw-rw---- 1 root disk 1, 4 Apr 24 12:05 /dev/ram4<br />
brw-rw---- 1 root disk 1, 5 Apr 24 12:05 /dev/ram5<br />
brw-rw---- 1 root disk 1, 6 Apr 24 12:05 /dev/ram6<br />
brw-rw---- 1 root disk 1, 7 Apr 24 12:05 /dev/ram7<br />
brw-rw---- 1 root disk 1, 8 Apr 24 12:05 /dev/ram8<br />
brw-rw---- 1 root disk 1, 9 Apr 24 12:05 /dev/ram9<br />
lrwxrwxrwx 1 root root 4 Apr 24 12:05 /dev/ramdisk -&gt; ram0</code></p>
<p>All those ramdisks listed have same size.  In above example, they are all 16MB.  Let us change that so we have more space allowed.  Note that I say allowed and not allocated.  We allocate space in one of the later steps by formatting one of the drives above.   Let us set it up so we have 128 MB.  Since this has to be in multiples of 1024, we will setup Ramdisk to have 131072K. </p>
<p><code>vi /etc/grub.conf</code></p>
<p>Find first line which looks similar to following:</p>
<p><code>kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/VolGroup00/LogVol00</code></p>
<p>add ramdisk_size=131072 to the end of the line.  Now your line should look like:</p>
<p><code>kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/VolGroup00/LogVol00 <strong>ramdisk_size=131072</strong></code><strong> </strong>Save and exit grub.conf.  At this point you have it configured to have ramdisk with new size but it does not take effect until you reboot your system.  Once you have rebooted your system, we can start doing rest of configurations.</p>
<p><code>mke2fs -m 0 /dev/ram0</code></p>
<p>This will format the ram0 ramdrive for us to use. At this point, kernel will allocate space for you.  Let us setup Ramdisk mount point so we can use it.  We will also have it be owned by user &#8220;sunny&#8221; so that user can read/write to that mount.</p>
<p><code>mkdir /home/ramdisk<br />
mount /dev/ram0 /home/ramdisk<br />
chown sunny.sunny /home/ramdisk</code></p>
<p>At this point you should be able to type:  <strong>mount </strong>and see your new Ramdisk drive mounted on /home/ramdisk</p>
<p>Remember that everything you put on this drive will be gone if you reboot your server.  If you unmounted the Ramdisk drive and remounted it, your files will still be there.  It is because your system has that much ram set aside for your Ramdisk and will not use it for anything else.   If you would like to setup Ramdisk the same next time you boot up, add these lines to your /etc/rc.local files.</p>
<p><code>mke2fs -m 0 /dev/ram0<br />
mount /dev/ram0 /home/ramdisk<br />
chown sunny.sunny /home/ramdisk</code></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/06/01/ramdisk-how-do-you-install-and-set-up-ramdisk-under-linux-centos-rhel-fedora/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL wait_timeout setting</title>
		<link>http://crazytoon.com/2007/02/20/mysql-wait_timeout-setting/</link>
		<comments>http://crazytoon.com/2007/02/20/mysql-wait_timeout-setting/#comments</comments>
		<pubDate>Wed, 21 Feb 2007 01:17:37 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Server load]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/02/20/mysql-wait_timeout-setting/</guid>
		<description><![CDATA[We were having issues with mysql threads where they would be in sleep mode and wouldn&#8217;t die off for long time.  At the same time we started having issues with our servers where the load will spike and eventually server will come to halt unless we killed all the apache processes and restarted apache [...]]]></description>
			<content:encoded><![CDATA[<p>We were having issues with mysql threads where they would be in sleep mode and wouldn&#8217;t die off for long time.  At the same time we started having issues with our servers where the load will spike and eventually server will come to halt unless we killed all the apache processes and restarted apache (which seems to be the hung application).  We traced it back eventually and noticed that the time when server hung was when it burned through all the ram and was using up all the swap also.  So we started to work backwards and tried to resolve one thing at a time.  We started with MySQL.  We put in wait_timeout = 30 in to my.cnf and restarted mysql.  Than I closely watched the server for few hours and noticed that we didn&#8217;t have any more of those sleep connections.  GREAT! A work around until we get to bottom of whats causing this.  That was on Friday.  Sat we started noticing different problem.  Problem worsened and we started to look into what might&#8217;ve caused it and found out that we had a script which was pulling row at a time, processing it, and deleting the row.  Except, it was never getting to delete the row due to timeout would kick in and close the connection.  We found this out when we watched error logs and saw:  Mysql has gone away message.</p>
<p>We took out the wait timeout and everything seems to started to work fine.  Did anybody ever notice this behavior where you would loose connection to the mysql server due to timeout?  The script which processes line by line and deletes line by line takes fraction of second to process that particular line.  Does wait timeout starts counting from the starting of the connection?  Does it mean that wait timeout is actually a max connection time limit?  Suggestions/comments?</p>
<p>Edit 5/31/09:  Friend of mine was getting this error: <code>database error: Lost connection to MySQL server during query </code><br />
he got around it by adjusting wait_timeout setting. </p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/02/20/mysql-wait_timeout-setting/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>What is this &#8220;load average&#8221; I keep hearing about?</title>
		<link>http://crazytoon.com/2007/01/29/what-is-this-load-average-i-keep-hearing-about/</link>
		<comments>http://crazytoon.com/2007/01/29/what-is-this-load-average-i-keep-hearing-about/#comments</comments>
		<pubDate>Tue, 30 Jan 2007 03:01:33 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Server load]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/01/29/what-is-this-load-average-i-keep-hearing-about/</guid>
		<description><![CDATA[I have been asked numerous times what does &#8220;load average&#8221; means in top.  If you don&#8217;t know what top is and you have access to linux machine, go type top now and see what it shows.
load average: 2.05, 2.17, 1.93
Quick answer is:  first number (2.05) is 1 minute avg, second number (2.17) is [...]]]></description>
			<content:encoded><![CDATA[<p>I have been asked numerous times what does &#8220;load average&#8221; means in top.  If you don&#8217;t know what top is and you have access to linux machine, go type <em>top </em>now and see what it shows.</p>
<p>load average: 2.05, 2.17, 1.93</p>
<p>Quick answer is:  first number (2.05) is 1 minute avg, second number (2.17) is 5 minute avg, third number (1.93) is 15 min avg.  Generally system admins look at these #&#8217;s to see how is their server is doing.   But now you wonder, if this is the #&#8217;s you look at, why is there cpu %?  Isn&#8217;t that computer load also? Ofcourse it is.  BUT, meaning of cpu % shown in  [ Cpu(s): 14.2% us,  1.7% sy,  0.0% ni, 80.7% id,  3.1% wa,  0.0% hi,  0.3% si,  0.0% st ] actually just means how much % of time was spent doing stuff on cpu.  On the other hand, load average takes other things such as how much cpu&#8217;s were being used and how many process had to wait for their turn to use cpu, etc.  Thats why sometimes you will see high % for Cpu usage but low # for load average because things didn&#8217;t get queued much and cpu just spiked a bit at the time you looked at it. You can also have slow responding server with high cpu % and low load average.</p>
<p>So what is ok and what is not ok # to see in load average?  This is actually simpler to answer than explaining what is what.  For each cpu you add, you add 1 to your high #.  For example, if you dual cpu, its ok to see load upto 2.  Which basically says both of the cpus were doing 100% of work and its ok.  If that # is above 2, lets say 4, that means your system is working twice as hard as it should.  So lets say you have dual cpu with hyperthreading, what is the optimial number to see in load average?  If you said 4, you are correct!</p>
<p>So now you know!  Here are couple other commands which will show you load averages:</p>
<p>w<br />
18:58:26 up 438 days, 13:32,  1 user,  load average: 1.83, 2.26, 2.24</p>
<p>uptime<br />
18:58:44 up 438 days, 13:33,  1 user,  load average: 1.59, 2.18, 2.21</p>
<p>To learn about the commands used in this post, see <a href="http://www.lamp-tips.com/man-pages/w/" title="man w - man page for w" target="_blank">man w</a>, <a href="http://www.lamp-tips.com/man-pages/uptime/" title="man uptime - man page for uptime" target="_blank">man uptime</a>, <a href="http://www.lamp-tips.com/man-pages/top/" title="man top - man page for top" target="_blank">man top</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><small>DISCLAIMER:  As always, if you find any inaccurate information, please comment and let me know.  When you do comment, make sure you give me some references to confirm.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/01/29/what-is-this-load-average-i-keep-hearing-about/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Improve page load time and increase server capacity by doing simple DNS and server changes</title>
		<link>http://crazytoon.com/2007/01/23/improve-page-load-time-and-increase-server-capacity-by-doing-simple-dns-and-server-changes/</link>
		<comments>http://crazytoon.com/2007/01/23/improve-page-load-time-and-increase-server-capacity-by-doing-simple-dns-and-server-changes/#comments</comments>
		<pubDate>Tue, 23 Jan 2007 21:31:04 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Server load]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/01/23/dns-server-changes-to-improve-page-load-time-and-increase-server-capacity/</guid>
		<description><![CDATA[Problem:
One of the sites I maintain has been getting more and more traffic everyday.  A very good thing for the site, not so good for the solo server which is serving those pages.  The site is VERY dynamic with LAMP setup.  We only have one server serving our web pages to our [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>One of the sites I maintain has been getting more and more traffic everyday.  A very good thing for the site, not so good for the solo server which is serving those pages.  The site is VERY dynamic with LAMP setup.  We only have one server serving our web pages to our users.   Since its a dynamic site with PHP and MySQL,  it has a lot of load during peak times.  Average load time of a page is between 1-2 secs during normal usage, 2-5 secs under average to heavy load.</p>
<p>During heavy load, we started to see our mysql stop responding to requests which is a big concern for us since we don&#8217;t show content if there is no db connection.  We had to come with a solution, fast, to prevent this issue from appearing.</p>
<p><strong>Solution: </strong></p>
<p>So here are couple things I ended up doing on the server side to reduce load on this server without having to do much code change.</p>
<ul>
<li>We have couple other servers at the same location for doing other tasks.  So I decided to use one of those servers to offload some of the http processing.  I setup  our dns to point js.domain.com and css.domain.com to go to this spare server which reduced load on our main server quite a bit.  We have a lot of js and css content which is loaded every time   user hits a page.  Our development team took care of the including the domain in the part where it loads js/css on the page.  Another benefit of doing this was to allow users&#8217; browsers to simultaneously download from two servers at a time which in turn equates to load time decrease.  Browsers only do certain # of connection per server and wait until those requests are completed before making another request.  I believe both FF and IE have limit of 2 per domain.</li>
<li>Second thing I did was to turn on compression at Apache level to decrease the amount of traffic sent to users.  As long as users browsers support compression, apache would server compressed content.  Doing this more than halved our bandwidth usage.  We went from doing about 20-25 gigs/day to about 11-13 gigs.</li>
</ul>
<p>As of now our load has been low even during high traffic times.  Our bandwidth usage is low and going up with traffic as expected.  Users have to wait 1-2 secs during high traffic times compared to 2-5 secs before tweaking.  And during normal usage, we barely see 2 sec page load time instead its mostly only 1 sec.  As of writing of this blog, we currently have 12781 users on-line with 90 sql queries per sec on average.</p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/01/23/improve-page-load-time-and-increase-server-capacity-by-doing-simple-dns-and-server-changes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

