Blog #6 in How I Successfully Upgraded eBay to SharePoint 2010 – See Previous Blog In Series
One of the requirements of our upgrade was that the upgraded system would perform better than the current 2007 production environment. This included the latency to Europe and other non-US countries. Their are many options that one would have to do this, these include the following:
- Increased bandwidth
- Decrease latency
- Page Weight
- Caching (Server, F5, Proxy, CDN)
Increased bandwidth:
In our case, bandwidth was not an issue. In your circumstances, that may or may not be the case. If you have a small pipe, you won't be able to get too many requests going through it. In the end, this really isn't a big deal.
Decreased Latancy:
SUPER SUPER important. Latency is the time is takes for the html packets to get to the client. If you have high latencies, your users are going to hate your intranet/SharePoint and call it slow. Even though you spent millions on hardware and it is able to generate the HTML faster than any other system, it can't get it to them fast enough.
Decrease Page Weight:
If you were to fire up Fiddler and watch the typcial traffic flow for a request to SharePoint 2010. You will see several requests are being made to the server. Because there is an order to the madness, their is a multiplier effect to the time it will take for a user to fully load a page (even with async requests occuring). YOUR NUMBER ONE GOAL IS TO MINIMIZE THE HTTP REQUESTS FOR A PAGE. How do you do this? You can do this in several ways:
-
Compress CSS
-
Minify Javascript
-
Evalute Picture Usage
Compress CSS:
The CSS classes between 2007 and 2010 changed A LOT! If you had custom CSS that overrode the out of the box CSS, it very likely will not have any effect in 2010. It should go without saying….you should remove this CSS. You should also attempt to determine how many different CSS files you have being downloaded from your pages. If you can consolidate those into one CSS, then you are going to be in a very good position moving foward. Steps:
-
Find all CSS classes used in your pages
-
Evaluate if they can be combined into one CSS file
-
Determine what CSS is used
-
Remove un-used CSS from your CSS files
-
Compress the CSS (remove all white space)
How does one find out is CSS is used or not? Here's the steps:
-
Get all your CSS classes used in your CSS files
-
Export all ASPX files from SharePoint to the SharePoint Root
-
Run a search on all the files for each CSS
-
Any CSS that is not found can be deleted
1. How does one export all the CSS? Heres a handy script:
$templateDir = "c:program filescommon filesmicrosoft sharedweb server extensions14 emplate"
del "$templateDirASPX" -recurse -force
mkdir "$templateDirASPX"
#export all aspx files to temp directory
$cdbs = get-spcontentdatabase
$count = 0
foreach($cdb in $cdbs)
{
"Processing " + $cdb.Name
$conn = new-object system.data.sqlclient.sqlconnection $cdb.legacydatabaseconnectionstring.replace("Timeout=15","")
$conn.open()
$cmd = $conn.CreateCommand()
$cmd.CommandTimeout = 4000
$cmd.commandtext = "select dirname, leafname, content from alldocs ad, alldocstreams ads where ad.Id = ads.id and ads.id in (select id from alldocs ad where extensionforfile in ('aspx')) and ad.internalversion = ads.InternalVersion";
$reader = $cmd.executereader()
while ($reader.read())
{
$filename = $reader["leafname"].replace("/","_")
$fileContent = $reader["content"]
$dirname = $reader["dirname"]
$temp = $count.tostring() + "`t" + $cdb.Name +"`t" + $dirname +"`t" + $filename
add-content "Files_ASPX.txt" $temp
[System.IO.File]::Writeallbytes($templateDir + "ASPX" + $count.tostring() + "_" + $filename, $fileContent)
$count++
}
$reader.close()
$conn.close()
}
2. How does one search for the CSS? Here's another handy script (note it will take a while for this to finish):
$classes = get-content "Css.txt"
cd "c:program filescommon filesmicrosoft sharedweb server extensions14"
foreach($_ in $classes)
{
dir -r -i *.aspx | select-string $_ | select filename, linenumber >> $_.txt
dir -r -i *.ascx | select-string $_ | select filename, linenumber >> $_.txt
dir -r -i *.css | select-string $_ | select filename, linenumber >> $_.txt
}
3. Create a list of all the CSS classes used in your CSS,
4. Compare the output of the last script and your CSS list, determine what is not used. I'll leave it to you to write the script for that. Just use a hashtable 🙂
5. Compress your CSS, tools for that:
Minify Javascript:
SharePoint 2010 will cause your page weight to go up. This is because of its heavy use of JavaScript. They did think ahead and minify the javascript files, so that ensure you don't take a huge hit on the files. If you have your own custom JavaScript and you haven't minified it, you are causing a higher page weight and your remote users will not have an optimal experience.
Tools to Minify are here:
Evaluate Picture Usage:
Does your site have a lot of pictures? Doesn't look like SharePoint anymore? That's both a good and bad thing. The more pictures you have, the large the page weight. Here's what you can do to decrease the page weight:
-
Ensure that buffer images are width 1 and heigth 1 – I can't tell you how many times I have seen an image created that is 10K and is used as a buffer image. It only needs to be a few bytes and a 1×1 image!!!
-
Use sprites – make lots of small images into one to reduce your HTTP requests
Caching:
There are lots of ways to do caching. And there is a ranking of most benefical and easy caching methods…here they are:
-
Proxy Server
-
Content Delivery Network (CDN)
-
Hardware compression
-
F5 Load Balancer
-
Web Server
Proxy Server – The proxy server method *really* is the best one. You can put a proxy server in each of your geo locations. The job of the proxy server is to cache common elements like CSS, Images and Javascript and do it on that side of the "pond". This makes such a HUGE difference its not even funny.
Content Delivery Network (CDN) – very similar to the Proxy server in that it keeps a local copy of the content, but you have to factor that into your web page design/HTML. I'm not a fan from an
easy of manageability standpoint, but it would match the proxy server in the performance increase you would see.
Hardware Compression – By deploying devices on your network edges, you can compress the WAN traffic. This tends to be a very costly solution and requires a lot of testing. In larger organizations, good luck with getting the network guys to mess with anything sitting next to the routers!
F5 Load balancer – an F5 can act like a proxy server by caching files, but typcially the F5 sites in front of the web servers on the Farm side of the network. It is very cost prohibative to have an F5 in each data center in each geo location acting as a proxy server. That being said, it can still site on the Farm side and cache the CSS, Images and Javascript. It still is exposed to the latency of your network, but the files will be in memory and be served up faster to the clients because they won't have to be fetched from the web server file system or content database.
Web Server – You can have the web server cache HTML from the execution of the ASPX pages. This does NOT help with the latency issues, but it does help with the actual execution performance. As we will see in the next blog post, Object Caching KILLS SharePoint 2010 so you have to be careful where you implement it. You can also implement Blob caching at the web server level. This is very beneficial for publishing sites as it will keep SharePoitn from hitting the content database every time to load images, CSS and Javascript.
In the end, we were able to increase the visible and technical user performance for Eurpoean users by over 30%. They have made alot of comments of how much faster it is, even if their are weird quirks with the sites, they are still amazed at how fast it is! Chalk one up for the CJG-mister!
Enjoy!
Chris
See the next blog post in this series HERE