\n

I returned from a trip out of town Monday to crashing web servers that ate my lunch all week long. For several days, I used the top command in Linux and watched helplessly as two servers ground to a halt with load averages higher than 100.

Top reports the processes that are taking up the most CPU, memory and time. On the server running Workbench, the culprit was always httpd, the Apache web server. This didn't make sense, because Apache serves web pages, images, and other files with incredible efficiency. You have to hose things pretty badly to make Apache suck.

If you know the process ID of a server hog, Apache can tell you what that process is doing in its server status report, a feature that requires the mod_status module. The report for Apache's web site shows what they look like.

Using this report, I found the culprit: A PHP script I wrote to receive trackback pings was loading the originating site before accepting the ping, which helps ensure it's legit:

// make sure the trackback ping's URL links back to us
$handle = fopen($url, "r");
$tb_page = '';
while (!feof($handle)) {
$tb_page .= fread($handle, 8192);
}
fclose($handle);
$pos = strpos($tb_page, "http://www.cadenhead.org/workbench");
if ($pos === false) {
$error_code = 1;
send_response(1, "No link found to this site.");
exit;
}

Most trackback pings are not legit -- I've received 600 from spammers in just the past three hours. Each ping required Apache to check the spammer's site, download a page if it existed, and look for a link to Workbench. A single process performing this task could occupy more than 50 percent of the CPU and run for a minute or more.

I'm surprised Apache ran at all after I added trackback a couple months ago. I was beginning to think the web server software was idiot-proof, but I've proven otherwise.

-- Rogers Cadenhead

Comments

I was beginning to think the web server software was idiot-proof, but I've proven otherwise.

I'm confused. Why is it Apache's fault that you wrote code causing it to crash? A search through all the source of a page would be extremely processor intensive with hundreds of requests an hour.

Can I blame IIS if I wrote an infinite loop in VBScript?


 

Who said it was Apache's fault?


 

Ah, my apologies! I mis-read and took the quote (that I quoted) as meaning it was Apache's fault. Silly me glossed over:

I found the culprit: A PHP script

Keep up the good work!


 

> I was beginning to think the web server software was idiot-proof, but I've proven otherwise.

It's like that saying in Poker... If you've been playing for a while and you haven't spotted the chump, then you are the chump.


 

Just accept the trackbacks (returning a "202 Accepted") and queue them into a file or database table, then separately via a cronjob or some other process, run the queue and purge the 99.999957281% of the crap that is spam from the spammers.

I changed my trackback script to be a PHP script which always replies "202 Accepted" but files all the data way in files to be processed later. Out of maybe 5000 trackbacks I received last year not a single one was valid.


 

I'm having trouble figuring out how the script you posted was using up 50% of the CPU for up to a minute. It shouldn't be nearly that bad. What kind of hardware are we dealing with? The download of the page is essentially computationally free, and scanning one string for a single occurrence of another string is very efficient. I'm just not seeing why it would be running slowly.


 

This server is an Intel 2.4 Ghz P4 Celeron with 1 gig of DDR 266 memory running Redhat Enterprise Linux 3.


 

I would bet it's the DNS lookup on the fopen of the URL. DNS is typically thread safe but not reentrant. Under a threaded server like Apache/2 each DNS call will block until the hostname's been resolved, if you get a slew of trackbacks at the same time the following requests will stall waiting for the hostname to resolve. Assuming everything is working perfectly this shouldn't be a problem, but if you're getting slammed by trackbacks which list fake web sites for the trackback URL, your DNS may hang just long enough on each request to cause the server to fall over.

This is pure speculation on my part, I haven't stared at apache or resolver source code in years.


 

It it helps, I just crashed a server too by simply requesting 100 or so PHP files in just a few minutes via AJAX. Seems each of th PHP files had loops which ran a thousand+ or so times, causing the crash by overloading the machine?


 

It's not apache's fault the server crashed? How preposterous! The software shouldn't crash. It should issue some form of useful error message then carry on.


 

Post #9. I too just carshed a W2K3 server by running a php script that processes a lot of data. Crashdump shows that php is at fault. This is is rather annoying.


 

The problem with the example code is that it does not check for errors returned by fopen().

If fopen() returns an invalid handle, then the while loop will run forever, since feof($handle) will always be false.


 

This is just the information I am finding everywhere. Thanks for your blog, I just subscribe your blog. This is a nice blog..


 

Jordan 12 Gym Red www.jordan12gymred.us.com
nike factory outlet store online www.nikefactoryoutletstoreonline.com
nike factory outlet store online www.nikefactoryoutletstoreonline.us
Nike Outlet www.nikestores.us.com
retro jordan 33 www.jordan33.us
cheap jerseys from china www.cheapjerseysfromchina.us
nfl jerseys www.customnfljerseys.us
air jordan 11 concord www.jordan11concord.us.com
Jordan 12 Gym Red 2018 www.jordan12gymred.us
Jordan 12 Gym Red 2018 www.redjordan12.us
Yeezy Shoes www.yeezy.com.co
Yeezys www.yeezys.us.com

Pandora Rings Official Site www.pandorarings-jewelry.us


 

Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts.


 

Nike Air Vapormax Flyknit www.nikeairvapormaxflyknit2.us
Nike VaporMax Flyknit,Nike Air Vapormax Flyknit,Nike Air Vapormax Flyknit 2 www.nikevapormaxflyknit.us
Nike VaporMax Plus,Nike Air VaporMax Plus,VaporMax Plus,Nike Air Vapormax Flyknit,Nike Air Vapormax Flyknit 2 www.nike-vapormaxplus.us
Nike Air Max 2019,Air Max 2019 www.max2019.us
Nike Air Max 2019,Air Max 2019,Nike Air Max www.air-max2019.us
Nike Air Max 2019,Air Max 2019,Nike Air Max www.nike-airmax2019.us
Nike Air Zoom Pegasus 35,Nike Pegasus 35,Nike Air Zoom Pegasus www.nikeairzoompegasus35.us
Nike Pegasus 35,Nike Air Zoom Pegasus 35,Nike Air Zoom Pegasus,Nike Pegasus www.nikepegasus-35.us
Nike Zoom,Nike Air Zoom www.nike-zoom.us
Nike Air Max 270,Air Max 270,Nike Max 270 www.nikemax270.us
Nike Shox,Nike Shox Outlet,Cheap Nike Shox Outlet www.nikeshoxoutlet.us
Adidas Outlet www.outlet-adidas.us
adidas originals www.originalsadidas.us
adidas ultra boost,ultra boost www.adidasultra-boost.us
Adidas Shoes www.shoesadidas.us
Pandora Rings,Pandora Ring,Pandora Rings Official Site www.pandorarings-jewelry.us
Pandora Official Site,Pandora Jewelry Official Site,Pandora Rings Official Site www.pandora-officialsite.us
Pandora.com,Pandora,Pandora Official Site,Pandora Jewelry Official Site www.pandora-com.us
Pandora jewelry Outlet,pandora charms,,pandora bracelets,pandora rings,pandora outlet www.pandora-jewelryoutlet.us
pandora outlet,pandora jewelry outlet,pandora charms outlet,pandora jewelry www.pandoraoutlet-jewelry.us
Cheap NFL Jerseys,NFL Jerseys Cheap,Cheap Sports Jerseys www.cheapsportsnfljerseys.us
Cheap NFL Jerseys,NFL Jerseys Outlet,Cheap Jerseys www.cheapoutletnfljerseys.us
Cheap NFL Jerseys,NFL Jerseys Cheap,Cheap Sports JerseysNFL Jerseys,Cheap NFL Jerseys,NFL Jerseys Wholesale,Cheap Jerseys www.nfljerseyscheapwholesale.us
Cheap NFL Jerseys,NFL Jerseys Cheap,Cheap Sports Jerseys www.cheapjerseyselitenfl.us
NFL Jerseys,NFL Jerseys 2019,Cheap NFL Jerseys,NFL Jerseys Wholesale www.nfljerseys2019.us
Pittsburgh Steelers Jerseys,Steelers Jerseys,Steelers Jerseys Cheap www.pittsburghsteelers-jerseys.us
Dallas Cowboys Jerseys,Cowboys Jerseys,Cowboys Jerseys Cheap www.dallascowboysjerseyscheap.us
NFL Jerseys,NFL Jerseys 2019,Cheap NFL Jerseys, Cheap Authentic Nfl Jerseys www.nflauthenticjerseys.us
NFL Jerseys Wholesale,NFL Jerseys 2019,Cheap NFL Jerseys, Cheap Nfl Jerseys Wholesale www.wholesalenfljerseysshop.us
NFL Jerseys Wholesale,Cheap Nfl Jerseys Wholesale,,Cheap NFL Jerseys,NFL Jerseys 2019 www.authenticnflcheapjerseys.us
Pandora Sale, Pandora Jewelry, Pandora UK www.pandorasale.org.uk
Pandora Charms,Pandora UK,Pandora Charms Sale Clearance www.pandoracharmssaleuk.me.uk
Pandora Bracelets,Pandora Bracelet,Pandora Jewelry www.pandorabraceletsjewellry.me.uk
Pandora UK, Pandora Sale, Pandora Jewelry UK www.pandorauk-sale.org.uk

Salomon UK www.salomons.me.uk


 

It is a great website.. The Design looks very good.. Keep working like that!.
how to preform a website audit


 

I found that site very usefull and this survey is very cirious. I ' ve never seen a blog that demand a survey for this actions. very curious...
Kensington escorts


 

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
digital marketing services near me


 

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
frp bypass apk download 2017


 

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
SEO Agency Los Angeles


 

vogstyle femme manteau cardigan tricot lourd pull ouvert à capuche gilet manches longues chaud avec poches
debardeur imprimé homme. je veux voir plus de tee shirts pour hommes pas cher et biens notés par les internautes ici http://www.matchdateclub.com/market/debardeur-imprim%c3%a9-homme.-je-veux-voir-plus-de-tee-shirts- pour-hommes-pas-cher-et-biens-not%c3%a9s-par-les-internautes-ici


 

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
como bajar de peso con ejercicios


 

Nice to read your article! I am looking forward to sharing your adventures and experiences.
voyance gratuite par telephone


 

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
independent london escort


 

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
elite college


 

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
writing


 

i read a lot of stuff and i found that the way of writing to clearifing that exactly want to say was very good so i am impressed and ilike to come again in future..
Milano accomodation


 

I am definitely enjoying your website. You definitely have some great insight and great stories.
Walmart call in number


 

Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work.
Mythdhr


 

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
بک لینک


 

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
ABC ya


 

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
agen judi terpercaya


 

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
188bet uk


 

Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts.
Magpies Dental


 

Nice to read your article! I am looking forward to sharing your adventures and experiences.
independent escort


 

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. Thanks...
Serving Orange County CA


 

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
judi poker online


 

I have a blog centered on the same information you discuss and would really like to have you share some stories/information. I know my visitors would appreciate your work. friv Games free 2019
kizi car games
games free for kids


 

This is the optimal blog site for each individual that needs to disclose this topic. You recognize a big quantity its essentially tough to say along with you (not too When I would certainly prefer ... HaHa). You, actually, put a brand-new spin making use of a topic that's been covered for numerous years.
friv 2020
abcya xyz
friv 4 online


 

The author of this post is admirable, it brings a lot of emotion to everyone reading it, let's share it more widely. I enjoyed it, thanks for posting it, I hope this post of yours will be more appreciated by it really excellent.
Jogo para menino, jogos online 360, io games net


 

You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant!
SEO Expert Dubai


 

I have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog!
sindrome del ojo seco


 

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
http://indypsychicreadings.com


 

This was a really great contest and hopefully I can attend the next one. It was alot of fun and I really enjoyed myself..
vittorio caso


 

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
casino happyluke


 

Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject.
Roof replacement services near Indiana


 

Add a Comment

These HTML tags are permitted: p, b, i, a, and blockquote. A comment may not include more than three links. Participants in this discussion should note the site's moderation policy.