Advertise here!


  • Page 1 of 2
  • 1
  • 2
  • >

Linux Web Server Hack - How to Write Automated Load Balancing Script!

Posted in A+Featured Hacks, Blog, Consumer, Cool, DoItYourself!, Educational, HOWTO, Hack, Web, Wordpress by max on the September 23rd, 2008 at 9:15 am

Well, I have been manually managing the dedicated server for this site for last 2 years or so but I found a better way to automate the server so it doesn’t ever go down due to overload.

One of the common problems in dedicated servers is the fact that load can go out of control and your web server along with it, causing you to hard-restart the server.

A better way to deal with this over-load problem is to shut down the HTTPD server (web server) before your server load gets to something around 2 to 5.

When the server load drops under 2, the script then can restart the server.

By doing this, you save a lot of headaches especially if you get “digged” or simply need the site up as much as possible.

Believe it or not, there’s no script that does this available free online so I made one for all you webmasters:


#!/bin/bash
loadavg=`uptime | awk ‘{print $9}’`
RESTART=”/sbin/service httpd restart”
# bash doesn’t understand floating point
# so convert the number to an interger
thisloadavg=`echo $loadavg|awk -F \. ‘{print $1}’`
if [ "$thisloadavg" -ge "5" ]; then
echo “Busy - Load Average $loadavg ($thisloadavg) “
httpd -k stop
elif [ "$thisloadavg" -le "2" ]; then
echo “Okay - Load Average $loadavg ($thisloadavg) “
pgrep httpd
if [ $? -ne 0 ] # if apache not running
then
# restart apache
$RESTART
echo “restart!”
else
echo “no restart!”
fi
else
echo “waiting…!”
fi

Save this code somewhere such as /root/checkload.sh.

Then add the following to your cron job.  (/etc/cron.d/sa-update for Fedora Linux)

*/1 * * * * root sh /root/checkloadsh

This will run the script every 1 minute to check the load and if load is too high, web server will be turned off, if it’s lower than 2 and web server is off, it will turn the web server on.

There’s a lot of things that can go wrong with your web server whether from extra traffic or whatnot, but this script will be handy and I do recommend it to anyone who’s having trouble with high-load web servers that go down often. (like this blog)

Now, go install this script, you will never have to worry about your web server dying from high load ever again.

You can also change the value of “2″ in the code to something higher such as 5 or 10, which will wait longer to shut the web server off if load goes high.

I didn’t write the code from scratch, I took 2-3 different scripts and mixed it up so here’s the resources I used for the code:

Load Average Script - This one is the main skeleton I used

Check/Restart HTTPD Script - This one I used to check HTTPD server before trying to restart it.

Cron Task Scheduler - I keep forgetting that the most left number is the minutes, darn.

NOTE - This is a simple solution to keep your dedicated server running on 1 server (like this one), if you can afford more servers, you will need to resort to load balancing the “servers”, load balancing here refers to balancing within 1 server.

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 2.33 out of 5)
Loading ... Loading ...


Memcached, MediaWiki, and MySQL for optimizing Database

Posted in A+Featured Hacks, Blog, Consumer, Cool, Educational, Hack, SiteHoppin, Web, WebApp, Wordpress by max on the August 7th, 2008 at 8:49 pm

Memcached, MediaWiki, and MySQL for optimizing Database

Today, I saw that Hackszine’s Jason Striegel has postsed a blog post about Memcached and MySQL.

Well, basically Memcached is an open-source software for your web server that allows you to cache almost any MySQL query.

In other words, it caches your MySQL queries.  But to do this, you do need to check the Memcached cache before doing the actual MySQL query.

So what’s the point?

Well, certain Wiki softwares like MediaWiki already comes with built-in support for Memcached.  I have used a similar strategy for one of my custom sites, SiteHoppin.com.

Memcached is also designed for server-farming, meaning you are only limited by number of servers and gigs of ram.

Unlike PHP accelerators, Memcache is really a database cache, thus can give you some extra performance if you implement it right.

Now if the developers at Wordpress started implementing Memcache, that’d do a lot of good for bloggers.

That said, if you want to explore Memcached, you can check out Jason post over at Hackszine.

For MediaWiki implementations, you will have to digg a little deeper. (You can start here)  You can buy this book called Wiki Professional.

Other Resources:

Memcached Official Website

Strategies for Using Memcached and MySQL Better Together
Memcached and MySQL tutorial (PDF)

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


DIY - How to Make your own Lunchbox Linux Firewall!

Posted in Computer, Consumer, Cool, DoItYourself!, Educational, Gadgets, HOWTO, Linux, Projects by max on the June 26th, 2008 at 10:19 pm

DIY - How to Make your own Lunchbox Linux Firewall!

As an avid fan of Linux operating systems ever since I took Minix class, which Linux was born from, I love to hear about cool little DIYs on making a Linux firewall out of a lunch box.

The greatest thing about Linux operating systems in comparison to Windows or any other operating systems is that it can be easily custom tailored to do one thing whether that’s a web server, firewall, file server, or any type of server that requires stability at “no cost”.

This simple DIY shows us the things that are possible with open source and free software.

Heck, you could probably make a lot of money putting these Lunchbox Linux firewall boxes to production as they are as good as an over-priced Cisco router.

It’s a plastic Thermos brand Hot Wheels lunchbox circa 2007. Black plastic, white handle, but no Thermos inside. As soon as I saw it, I knew it would become a computer case, so I bought it, brought it home, and started digging in the parts box. Grabbed one of my Via C3 embedded 3.5″ boards, a cheap 4GB compact flash card, a small 5V, 8A power supply, and my exacto knife and files.

via technabob

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...


Linux Server Hacks - How to increase Plesk Q-mail Maximum E-mail Attachment size of 2MB!

Posted in Computer, DoItYourself!, HOWTO, Linux by max on the May 28th, 2008 at 12:37 am

Well, recently I had one of my clients that I host their e-mail system on my web server ask me if they can send more than 2MB for their e-mail attachments.

To do this on a Plesk system, you need to create a new file for the Q-mail.

Plesk defaults to 2MB for e-mail attachments.

Goto this directory:

/var/qmail/control

make a file called “databytes” and store the max number of bytes allowed.

For example, “4000000″ would be max 4MB attachments.

via zwiki

, , , , , , , , , , , , , , , , , , , , , , , ,
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Data Browser allows you to manipulate MySQL database in a Snap!

Posted in Blog, Cool, Educational, Web, WebApp by max on the May 11th, 2008 at 8:33 pm

Here’s a desktop based data browser that allows you to manipulate MySQL database in a snap.  The most amazing part is how quickly you can bring in any RSS feeds from blogs/social network sites as a database table, almost as fast as my finger snapping.

Watch as David, the CTO of the company, explains how it works.

Click Here to View in Full Screen Mode

As you can see in the video interview, Kirix Strata lets users view, organize, and manipulate data tables with desktop speeds and ease.

Although you could make a similar webapp, it wouldn’t perform as fast since you’d have to constantly connect to a web server.

Kirix Strata solves all that, and as a programmer myself, I am impressed at how quickly you can manipulate data. (If you watch the end of the video, you will see how quickly Strata can bring is RSS feeds to a MySQL table)

Now, there’s a LOT of applications that the Strata could be used for such as organizing your web database without coding, importing your database to your desktop, manipulating the database at desktop PC speed, and tons more.

This application is really geared towards those web programmers but if you are able to get the drift, this app is amazing and seems to have a bright future.

via zedomax.net

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


IP in Your Email, get your external IP and send it to any email

Posted in Consumer, Cool, Educational, Microcontroller, Network by max on the February 28th, 2007 at 2:13 pm

IP in Your Email

Here’s a cool blog I came across on our new wagg.it site.
It’s a custom application that will send email containing current external IP address to a specified email address automatically at set intervals.

Why do you need this?

I used to work as a network administrator at a company and had issues with DDNS (dynamic DNS) addresses where the domain name can change.
We used to use free DDNS services such as no-ip.com but this tool will allow you to bypass that and simply check your email to access your server. (Therefore keeping it even more secure…)

This can be great tool for embedded TCP/IP applications too.

What was that IP address again? How many times did you wish you had the IP of your crashing router on your home network to do a quick reset. I used to have a Linksys that would crash at least once a month at the most inopportune times and I designed this application to send me my network’s external IP address everyday or what ever intervals I wanted. Many ISPs with broadband give you a dynamic IP address and this helps you know that you are up and running and what the IP address is. It also is a nice monitor sending hourly emails for testing flaky connections. I have grown used to being able to view my external IP from my system tray and at the request of others with the same problems I created IP in Your Email application (don’t send me emails on the name).

via wagg.it

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Zedomax Server Upgrade Complete!

Posted in Blog, Cool, Network, Web, Wordpress by max on the February 22nd, 2007 at 5:01 pm

server upgrade

Noticed we haven’t been posting as much lately? We got a server upgrade (now we got more servers) over the last couple days to handle more traffic and make the website load faster.

Finally, we are ready to go at full speed again without being slowed down by mysql and web server. We now have different servers to handle the mysql and the web server.

If you want to know about running a more efficient web server, check out this article on mysql and web server on different boxes.

Thanks goes to Vax and Spas at Aplus.net dedicated server team for getting us back online at a faster speed. (Yes, we got more servers now… we are starting to learn about server farms…)

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


DIY HACK - The Orb - mini ITX hack project

Posted in Consumer, Cool, DoItYourself!, Educational, Entertainment, Gadgets, Projects, Video by max on the February 5th, 2007 at 8:16 pm
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Web-server enabled Christmas Tree that you can play with

Posted in Consumer, Cool, Entertainment, Gadgets by max on the December 8th, 2006 at 6:12 pm
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


  • Page 1 of 2
  • 1
  • 2
  • >