A while ago I updated my exchange rate sites (Dollars2Pounds et al) to use the "new" ASP.NET Chart control, after some initial testing every thing appeared to be going well and the live websites were updated with the chart control.
Shortly after deploying the servers event log filled up with messages along these lines:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 5/19/2009 1:17:59 AM
Event time (UTC): 5/19/2009 12:17:59 AM
Exception type: ArgumentException
Exception message: The image is not found.
Request URL: http://www.yuan2dollars.com/ChartImg.axd?i=chart_6_6.png&g=e036ff271be14badb39473c8d04f8609
Request path: /ChartImg.axd
T Stack trace: at System.Web.UI.DataVisualization.Charting.ChartHttpHandler.ProcessSavedChartImage(HttpContext context)
at System.Web.UI.DataVisualization.Charting.ChartHttpHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I've been trying to get to the root cause for some time concerned that visitors to the websites were seeing blank images and I followed various suggestions based on image cache lifetime, temp folder permissions, phase of the moon and so on.
It wasn't until just recently when I followed Scott Hanselman's top tip of implementing elmah that the real cause of the problem became obvious.
It's Google causing all the exceptions! Well googlebot and other search engines.
Their right in front of me under the ALL_RAW heading of the server variables was the answer "Connection: Keep-alive Accept: / Accept-Encoding: gzip,deflate From: googlebot(at)googlebot.com"
I should have guessed that!
What happens is googlebot request the page, so the charting control creates the image and renders a image tag for it, caching the image for a predefined period of time. Naturally googlebot does what it does best, it saves that link to the image and tries to re-index it time and time again at a much latter date (weeks), by the time googlebot comes back for the image a second time the cache has long since been updated and naturally the image no longer exists and the naming convention of the image means that it's not going to get the replacement.
Recently I also ran some performance test with the charts in place using LoadImpact, they provide some limited and basic performance testing for free, but its more than enough for simple sites like mine to see that I had serious performance issues on my sites when more than a couple of visitors were hitting the site at the same time.
The charts on each pages were taking about one second to render (it's not surprising as I'm trying to render something like 26,000 data points for the 3 month USD/GBP chart and 7,000 for the other 3 month charts on a 2.4GHz P4). With the CPU fully pegged for a second trying to produce those charts it doesn't take long before the delay hits in if more than a couple of users access the page at the same time.
My fix for this has been fairly simple, the charts are now updated in the background by a cache expired event and are written to a static .png file with a fixed name. The charts are stored in a Charts folder and existing files are replaced with fresh images, the page is rendered with a normal img tag so when googlebot visits it can get the latest chart using the correct name and page rendering now happens in about 6ms.
Interestingly this performance fix has also seen a 10% increase in traffic.
- Watch your servers event logs.
- Implement ELMAH, it's crazy simple and very useful.
- Take advantage of the free load testing from LoadImpact, even if you only try it the once.
- If you are running IIS/Server 2k3/2k8 have Perfmon run in the background as you run the Load Impact tests and look at:
- CPU usage
- Error Events Raised
- Requests Current
- Requests Queued
- Request Execution Time
- and others that might be relevant.
- In perfmon save the setup somewhere easy to get to (i.e. the desktop) so you can just double click it to get your perfmon setup back quickly
Apologies for the recent outage of Dollars2Pounds and the other exchange rate sites. You may not have noticed if you or your ISP had the DNS values in cache as the site was actually up and running.
Just a couple of days ago I updated Dollars2Pounds to use the DNS servers of the host I have the server with, thinking that it would reduce the load on my servers and that they would be less likely to go down than my servers.
How very wrong I was, earlier this evening I got an email from the site monitoring service I use (site up time) telling me that Dollars2Pounds was unreachable.
A quick check and the site was up and running but the DNS servers were not returning anything and the host providers main web site was down as well.
Hopefully this is a rare occurrence, however since EV1Servers got taken over things have gone badly, not least the 3 day outage recently when a transformer blew up.
Lets hope things improve as it's really painful to change hosts and you don't really know what will happen at a new hosts.
I've also managed to accidentally knock the odd site off line over the past week whilst I've been setting up the accounts on the new server.
The good news is that all my exchange rates sites (Dollars2Pounds, Pounds2Euro etc.) are now on a more powerful server and using a more up to date exchange rate source which is updated every 15 or 60 mins. dependent on the currency pair.
Today the Pound has broken the 2 Dollar exchange rate, this is apparently a 15 year high for the Pound against the US Dollar.
Dont forget if you want to check out the exchange rate on your mobile phone or other mobile devices you can browse to D2P.mobi, Dollars 2 Pounds for your mobile.
Screen shot from Dollars2Pounds showing todays rate above the 2 dollar point:
The BBC is reporting that the Pound reached a 14 year high against the US Dollar during Monday.
I dont have 14 years worth of data in the Dollars2Pounds exchange rate database, but heres a chart of what the last 5 years looks like.
(Apologies for the Y axis label problem, Excel has decided not to allow me to show the full label I have no idea why, Ive tried allsorts).
I'm currently working on adding charting to Dollars2Pounds.com, however this is in a big queue with lots of other things I need to be working on so isnt happening as quickly as I would like its also reliant on me finding a charting package that I like, and Ive not had much luck so far.
If you want to play with a chart in Excel your self you can use Dollars 2 Pounds exchange rate history page and Excels Web Query.
From Excel select :
Data -> Import External Data -> New Web Query
In the Window that opens enter the Rates History URL.
Select the arrow pointing to the date title of the rates table, it should turn to a tick
Click on Import, select where to import the data to in the Import Data window and wait whilst Excel gets the data.
Your spreadsheet should now look something like:
Now, if like me your in the UK, its a great time to buy software, components, domain names and the like from US sources as everythings practically half price!.
Please remember the actual exchange rates you receive from your credit card, money transfer or other currency conversion will differ from the rates published, please check the rate offered by the company converting your currency first and remember that conversions are an approximate indication only and cannot be guaranteed by Analysis UK.