Wednesday, 30 September 2009

Web site performance monitoring tools

Having gone through the pains of learning about web site performance and applying that understanding to a MOSS site (www.westernaustralia.com), the latest post on the SharePoint Team Blog about optimising sharepoint.microsoft.com caught my eye. I’ve been meaning to cover the performance nitty gritty from our experience for ages now but, for the moment, suffice it to say we fixed most of the problems faced by our global audience and now use a commercial performance monitoring service called Gomez to keep an eye on things. Gomez competes with the likes of Keynote if you’re in the market.

Commercial solutions like this cost a lot of money because they’re essentially distributing test agents all around the world and measuring full page load times from your site at a configurable interval. Response metrics are stored for trending analysis and comparison with other sites. Despite the cost, these tools are worth the money if you know your site is experiencing performance issues (if not the data gets boring really fast).

Firebug, YSlow, and Fiddler are great tools for analysing performance and will give you both page load time and page weight but they’re all executing from your desk; if your web server is down the hall or in the same city (or country) you may not have a clear picture of how latency is affecting your site users on the other side of the world. If you’re targeting a domestic audience that’s obviously not a problem but if you’re targeting a global user base and you’re attempting to do so with SharePoint you need to ensure everything about your site is optimised—not just just the server configuration. The SharePoint Team Blog post highlights the fact SharePoint (MOSS 2007) is not optimised for internet sites out of the box.

As the cost of these performance measurement services is prohibitive—especially in this tough economy, it’s interesting to see where the free services are going feature-wise. I mention the SharePoint Team Blog post specifically because the author cites a new tool I hadn’t yet come across: http://www.webpagetest.org/ I’ve previously evaluated Pingdom but their offering was still developing a year ago (they offer both free and paid services).

The webpagetest.org site is painful on the eyes but the data they provide at no cost is comprehensive. The site currently allows you run tests from one of three nodes (the US, UK, and New Zealand), meaning an adequate global coverage (we test westernaustralia.com from seven locations matching the site’s target markets).

The tool reports the results from a full page test, meaning the page and all of it’s supporting resources are requested, providing a realistic picture of how long it takes to load the page and all CSS/Javascript/images/XML files/Flash files/etc. Some of the freebie offering I’ve seen in the past only reported the page HTML load time, which will often be negligible.

In addition to giving you a screenshot of the page, which is often useful to compare what the world sees versus what you think they’re seeing, you get full waterfalls of data for a first visit and what they call a repeat view (a subsequent request for the same page with a primed browser cache), and an item by item optimisation checklist.

webpagetest waterfall and optimisation

I’m impressed!

Thursday, 24 September 2009

Removing the shutdown details prompt in Windows Server

If you’re anything like me, chances are you’ve got dozens of virtualised dev servers hanging around and you shut them off at the end of the day; you also have no idea what to put in the Shutdown Event Tracker Comment box. The event and comment do get written to the event log for future reference so I usually comply and specify an exact reason where applicable or with my standard comment “a” for “all good” or “a-team” or something like that!

In practice, I’m the only one using my dev environments and I’ve never had the need to remind myself why I shut down the server. The specific event is likely buried among the shut down/start up events anyway and it’s probably safe to say this feature was intended for multi-admin production environments.

The shutdown event tracker is just an extra hassle as a developer but it can be turned off:

  • Run –> gpedit.msc
  • Browse to the Local Computer Policy / Computer Configuration / Administrative Templates / System node
  • Locate and open the Display Shutdown Event Tracker policy
  • Set it to Disabled

Life = that little bit easier.

Tuesday, 25 August 2009

westernaustralia.com site re-launch on MOSS 2007

westernaustralia.com today gets a facelift on the coattails of the corporate site relaunch a few weeks back. The westernaustralia.com site is Tourism Western Australia’s premier consumer-facing web site and targets visitors seeking quality, unbiased information about Western Australia.westernaustralia.com rebrand

This is the first major visual change to the site since TWA launched WA.COM on the MOSS 2007 platform in May 2007. The site is regularly cited as an early, shining example of how far you can take custom branding and SharePoint. Under the covers, the site employs all the SharePoint tricks you’re used to: master pages, page layouts, web parts, content types, lists—you name it. The only thing we don’t make use of that might otherwise factor into a WCM site is SharePoint search and the BDC (we’ve built a custom solution for that).

The English-language sites alone delivered more than eight million page views in the last twelve months to an international audience. We currently run the site on the back of a single Windows 2003 x86 web front end (which also hosts the tourism.wa.gov.au site as a separate web app) and SQL Server 2005 database server shared by all of our MOSS-based web sites. Site traffic is additionally accelerated by Akamai and cached by regional Akamai nodes to ensure visitors can access the site quickly and reliably from all over the world.

The new changes are part of an interim visual shift as Marketing prepare for a new brand launch later this year. Apart from the look and feel, which was aimed at reducing clutter and softening existing brand elements, the site is moving towards dynamic (i.e. social) content (see the twitter feed!) and the home page in particular has been positioned to display fresh content like events and deals.

Want more? For some more examples of the heavily branded sites we’ve rolled out on the MOSS platform over the last year, check out the side bar on this page (“Some of the MOSS sites I’ve worked on”) and watch the videos (1, 2).

Disclaimer: I’m a contractor working at TWA. Mediawhole is not directly affiliated in any way with the agency or the web sites; when I say “we”, I mean the royal We.

Friday, 21 August 2009

Seeking an Experienced DBA with Strong T-SQL Skills

We’re looking for an experienced database administrator to start initially on a short term (three month) contract at Tourism WA’s Perth office. If you match this description, you do quality work, and you’re not a cocky git, please get in touch asap: info@mediawhole.com.

Required Personal Skills

  • The ability to work independently with initiative and self-drive
  • Excellent interpersonal skills
  • Excellent verbal and written communication skills
  • A sense of humour

Required Technical Skills

  • Practical experience writing Transact SQL scripts and applying relational database concepts
  • Practical experience installing, maintaining and migrating SQL Server 2000, 2005, and 2008 on 32 and 64-bit platforms
  • Practical experience configuring and maintaining SQL Server 2008 clusters
  • Knowledge of general performance testing and environment optimisation approaches
  • Practical experience performance tuning existing code (stored procedures, user defined functions, views, other queries)
  • Practical experience tuning indexes and configuring maintenance plans
  • Practical experience implementing a database server health monitoring and status alerting system
  • Practical experience with high availability techniques for SQL Server (mirroring, log shipping, etc.)
  • Knowledge of deploying C# CLR assemblies within SQL Server

Desirable Technical Skills

  • Experience maintaining product-specific database environments (specifically SharePoint/MOSS 2007)
  • A working understanding of network concepts as they relate to database administration (firewalls, TCP/IP, performance)
  • A working understanding of SAN and RAID technologies
  • Experience tuning storage subsystems
  • Experience installing and maintaining SQL Server Reporting Services (SSRS)
  • Experience creating and maintaining SSRS reports
  • Basic understanding of source control concepts

Tourism WA Corporate Site Relaunched on MOSS 2007

With the agency's first sites launched on SharePoint 2007 more than two years ago, it was recently time to give the flagship Tourism WA sites a facelift! The corporate site (http://www.tourism.wa.gov.au) is the first site to move across to an interim look and feel as Marketing prepare for the formal brand re-launch; the consumer site (http://www.westernaustralia.com) will be following next week.

Tourism WA Corporate Homepage MOSS 2007So how much effort was involved on the Corporate side? With no major content changes, it was really a question of modifying the existing CSS and and some of the images and other resources; all up, about a week's work—including a stack of minor content tweaks. Consumer has been more involved but I'll save that story for another post ;-)

Tuesday, 18 August 2009

Open Command Window Here in Windows 2008

It used to be a Power Toy now it’s baked into both Vista and Windows:

Hold down shift and right-click a folder and behold, the Open Command Window Here menu item is revealed.

Monday, 17 August 2009

Zoom for presentations

Sysinternals: what’s not to love?!

I was setting up for a demo today and noticed the client’s projector was too close to the screen and the overall result was a hard-to-read display. The Windows screen magnifier (whatever it’s called) doesn’t really cut it so on a whim I hit Google and came up with ZoomIt.

http://technet.microsoft.com/en-us/sysinternals/bb897434.aspx

129KB later and no installer I can hit CTRL+1 and this thing zooms in to my mouse; wiggle my mouse around and the zoom follows. Esc to zoom out again.

Simple. Beautiful. Perfect.

Sunday, 16 August 2009

Invalid data has been used to update the list item. The field you are trying to update may be read only.

Apparently, in my specific case today, this error message actually meant the equivalent of a runtime type mismatch.

In the context of a list event receiver, I was attempting to update one of the list item’s properties. AfterProperties is an SPItemEventDataCollection, which seems to really be a collection of strings. In trying to cram a Guid in there, I forgot to call ToString () or Convert.ToString (); the compiler didn’t complain but at runtime my friendly Guid was jailed in the bowels of SharePoint’s exception handlers. SharePoint simply returned

Invalid data has been used to update the list item. The field you are trying to update may be read only.

with nothing but a menacing smile on its horrible, scarred face.

Sunday, 9 August 2009

Event receiver doesn’t fire

It’s been a long, busy weekend and the brain’s gone to mush—so I’m making silly mistakes.

Starting with an existing, functional SPItemEventReceiver attached to a content type, I needed to add an extra event handler. I had ItemAdding and ItemUpdating wired up and debuggable but wanted to add a new ItemAdded handler.

On my first attempt, I simply added the extra handler method to my existing class derived from SPItemEventReceiver. When that didn’t work, I recalled originally wiring the individual handler methods within the content type definition so I added an extra Receiver element.

I realised my mistake when it dawned on me I was testing my changes against an existing list instance: having been provisioned using the original content type definition with only the ItemAdding and ItemUpdating event handlers, SharePoint will never update that instance retroactively without some custom code.

After creating a new list from the modified template, all three event handlers fire correctly.

Retrieving a list item’s attachments

As you might expect, accessing a list item’s attachments in SharePoint isn’t straightforward. While SPListItem.Attachments returns a string-based list of attachment names, you’ll probably need to translate that into a URL at the very least, if not manipulate the attachment itself.

It helps to understand where SharePoint stores attachments after they’re uploaded. As usual, SharePoint Manager 2007 provides some insight:List Item Attachments Location

Notice in the screenshot, I’m inspecting a list named “Announcements” and that list has one item (Hello Attachment—highlighted at the bottom). You’ll also notice there’s an Attachments folder sitting among the list items and it’s been expanded with to reveal another folder with the odd name of 2; below that you can actually see the attachment itself (My First Attachment.txt).

Before I get any further, I’ll point out the magical “2” folder isn’t magical at all: it relates to the list item in this list with the Id of 2—in this case, the Hello Attachment item (the first item in the list was deleted but, if it had attachments, there would be a corresponding “1” folder). It’s sensible to assume this structure exists to accommodate multiple attachments.

If you were to now try to access the Attachments folder in code using SPListItem.Folder, you’d be faced with a null reference exception. Instead, you need to ignore what SPM tells you about getting to the Attachments folder and arrive there instead using the parent list’s RootFolder property.

Assume you’re working within the scope of a foreach or have retrieved a list item via some other means:

SPList announcements = …Lists [“Announcements”]

foreach (SPListItem currentItem in announcements)
{
// we’re here
}

Before you do anything else, you’ll probably want to muck around and ensure you can actually access a list of attachments in some form. To identify the attachments by name, SPListItem.Attachment (SPAttachmentCollection) will return a collection of strings:

foreach (string currentAttachmentUrl in currentItem.Attachments)
{
}

At this point you’ve retrieved, from the example discussed earlier, a string like “My First Attachment.txt—not of much use on its own. As mentioned, you’re probably after the full URL at the very least.

To access the actual attachment and not just it’s name, retrieve the list item’s parent list (SPListItem.ParentList) and then the parent list’s RootFolder. From there you can use the SubFolders collection to retrieve the “Attachments” SPFolder. Beware the SubFolders indexer expects the URL of the folder, not its name.

Finally, you need to retrieve the numbered folder specific to the list item. Here’s the complete mess:

SPFolder attachments = currentItem.ParentList.RootFolder.SubFolders ["Attachments"].SubFolders [currentItem.ID.ToString ()]

The SPFolder object’s URL property can now be prefixed to the attachment’s name retrieved previously or you can enumerate the SPFiles within the SPFolder.

Back in the day, Eric Shupps posted a way to do this by walking down the structure from the Lists folder. I think the above code is a slight improvement since the code’s a bit more manageable and you don’t need to retrieve the Lists folder or the parent list by name.

Ps. RootFolder is actually quite interesting as its Name property is actually the internal name of parent SPList object.