Profiling and debugging, when they mix

image

Normally, you debug, and when that’s done, you profile to speed things up.

That said, today I was confronted by a problem where profiling actually helpped the debugging.

A page, that should be working 100% from memcache was hitting mysql, 2 million times a day.

This page was on a serveur that couldn’t be debugged remotly. Two options were available, I could either put “print”s everywhere, and hoped to get lucky, or I could run the pager through xdebug’s profiler.

Loading the resulting profile into KCacheGrind, I had a detailled run down of every code path taken available to me. All that was rest was to lookup all mysql calls and work back up from caller to caller to identify the bug.

Posted in english, linux | Tagged , , , | Leave a comment

Nginx and disk starvation

A quick note that will help someone I hope.

If you have a high bandwidth site, and are seeing high load, lots of time waiting for io and nginx processes in the D state a lot, here’s something you could try:

First of all, install iotop and make sure nginx is the culprit (lots of IO for nginx, not much for the rest)

Then, go and have a look at your NGinx configuration, (nginx.conf), especially the worker_processes

You can try pushing the value up to (and maybe even over) the number of cores you have in your system. This spreads the load more evenly, and allows you to dramatically increase disk throughput (doubling isn’t uncommon).

This worked for me (going from 3Mb/s to 7Mb/s peak). That said, YMMV.

Feel free to leave a comment to say if/how this was (un)helpful ;)

Posted in english, linux | Tagged , , , , | Leave a comment

Troisième coup gagnant

Septembre 2010…..

Ça en fait du temps. Depuis, on a démenagé dans le sud, j’ai lancé 2 sociétés (ok, 1 et demie, c’est presque pareille), et globalement plus rien n’est pareille.

Durant ces 18 mois j’ai également progréssé de point de vue technique, et c’est pour ça que je compte raviver ce blog.

Il y aura des articles en anglais et en français, et je veux tenter de tenir le rythme d’un par jour.

Et c’est partie…

Posted in français, personnel | Leave a comment

Anti-spam take 2

Since the last system was marginally effective, I’ve just upgrade to
a) (re)capture
b) Askimet

Hoping that this can keep the blog clean

Posted in Uncategorized | Leave a comment

IE session bug

I’m just reposting this here so that it can help someone else.
Internet Explorer doesn’t honor php sessions if the domaine name isn’t valid (hint: _ isn’t a valid caracter in domaine names).
This can explain some hard to find bugs where your session works fine on FF, chrome or Safari, but not in Internet Explorer.

Posted in english, php, programming, work | Tagged , , | Leave a comment

Changes and uptime

Will be back soon, upgrading to wordpress 3.0 and changing hosting at the same time…

Stay tuned

Posted in Uncategorized | Leave a comment

A Quick Note to the link spammers

I don’t have much google cred, so I can’t really understand why you are so insistant.

That said, you’re ruining the fun for everyone else, so please go play on someone elses lawn.

It doesn’t cost me much to spam your comments, and to change the challenge response, so don’t think I’ll just give up.

Regards

Posted in english, personnel | Tagged , | 1 Comment

DynDNS and uptime

Anyone who has tried to get into touch with me or read this blog these last few days can atest to the fact that I haven’t been reachable.

My deepest apologies :( .

To understand what happened, here’s a quick lowdown on how my setup works:

I’m self hosting this blog as well as my mail on a converted EasyGate that I got as a beta tester. The machine is connected onto my internet router (a Trio 3D antique) and then onto the internet. My ISP provides a temporary IP address, and as such, I need to use a dynamic DNS record to be able to keep things updated.

Now, the Trio 3D (as with most of it’s features) has a half assed (excuse my French)  DynDNS system built in. I say half assed because it doesn’t accept any provider except the historic DynDNS and because it quite often forgets to update. Last week it completely stopped updating, and as an added bonus, I couldn’t get back into DynDNS to do things manually.

As a work around, I set up OVH (who are my registrar) to route my DNSes manually until I got a permanent fix. That worked until the IP changed Tuesday or Wednesday.

Now things are sorted out. I’m using OVH’s own DynDNS servers (much simpler) and am using a home built client to avoid all the dependancies other clients bought in.

The client is written in bash and depends on bash, sed and wget to work. It’s best used in a cron job, but can also be run on interface specific events if need be.

It uses a web based IP fetcher to work out your IP adresse, and if it’s changed since you last run the script, it updates your DynDNS records for you.

Without further ado, here’s the code:

#/bin/bash

USERNAME='myusername'
PASSWORD='mypassword'
HOSTS=('first_url.test.com' 'second_url.test.com')
SERVER="www.ovh.com"

#
#
#

CURRENT_IP=`wget -O - 'http://checkip.dyndns.org/' 2>/dev/null | sed -e 's/.*Address: \([^<]*\).*/\1/'` if [ -f /tmp/my_ip ]; then 	OLD_IP=`cat /tmp/my_ip`; fi # # Don't update unless ip has changed # if [ "x"$CURRENT_IP == "x"$OLD_IP ]; then 	exit; fi; echo "IP changed from " $OLD_IP " to " $CURRENT_IP echo "Saving new IP" echo $CURRENT_IP > /tmp/my_ip

for HOST in ${HOSTS[@]};
do
	echo "Updating " $HOST " to " $CURRENT_IP
	wget -O - "http://${USERNAME}:${PASSWORD}@${SERVER}/nic/update?system=dyndns&hostname=${HOST}&myip=${CURRENT_IP}&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG" 2>/dev/null
	echo ""
done

Et voila, I hope this helps someone out there

Posted in english, linux, personnel, programming | Tagged , , , , , , | Leave a comment

Histoire de nous veillir tous un peu…

Je ne pense pas être le seul pour qui ce genre de chanson rappelle des souvenirs….

Posted in français, personnel | Tagged , | Leave a comment

Nouvelle an

2010 est avec nous, la dernière année de la première décenie du deuxième millinaire (vas tenter de dire ça trois fois de suite…).

Comme chaque année, il est traditionel de faire de bonnes résolutions, je vais mettre les miennes ici histoire qu’on m’en teinnent rigueur si je ne les respect pas.

Bon, sans plus attendre:

En 2010, je m’engage à:

  1. Faire plus de sport (traditionel celle là ;) , et non, les Fest-noz ne comptent pas :P
  2. Me mettre à la cuisine (Merci Mateo)
  3. Devenir entrepreneur (plus d’infos vers le mois de mars sans doute).
  4. Écrire plus souvent dans mon blog

Voila

Bonne année 2010 à tous, et que tous vos voeux se réalisent

Posted in français, personnel | Tagged , , | Leave a comment