When I was working for my previous employer, one of the applications that we had developed was based on the "Software as a Service" (SaaS) premise. I was at the client site (a school district), at a VERY remote location with no AT&T cell phone service, and loading their data over the internet into our system. This was our first attempt at SaaS so we were learning as we went along. At one point, we had about 5 different people loading data into our system by scanning the serial numbers on the items. During our testing, within our network, the application was scaling just fine and we were thinking that we will gain insight into what else we need to do to make it scale even more.
Since the application was written in ASP.NET using the 2.0 Framework, every scan required a postback. As it turned out, the internet connection was slow at the client site but not that slow. They were using a dedicated T1 amongst the school district and it was summer time, 1 week before the start of fall session. There should have been enough bandwidth to enter the data without any noticeable latency but we were waiting about 20 seconds per scan. My first thought was that the internet connection back in the office was having troubles (yeah, we were sharing our T1 in the office with this application!). After confirming back at the office that we were not having any issues, I had to turn my attention to the amount of data being chunked back and forth. I used the excellent Fiddler tool to figure out the data transfer and the roundtrip time. SQL Server Profiler also came in handy as I was watching the tables being hit. Each scan was posting back about 100K of data in about 10 seconds. That means that the application was taking 10 seconds to process the information which, to me, was unacceptable. Since this was our beta test customer, nobody was panicking except for me and my boss.
After the first week at the client and nowhere being done, something had to be done as I didn't plan on not being ready when the school opened. So, over the weekend my first stab was at "fixing" the indexes. That helped…just a little. Now, each scan was taking about 7 seconds to process. Still not good! After looking at the code, (I was not the original developer and was only helping out since "the dude" had gone on vacation) I realized that NHibernate was not setup correctly and it was issuing N+1 queries. I fixed that as well and the application started humming. The data was getting loaded in less than half a second now.
This was only half the battle. We had to load thousands of items and at this rate it would have taken us forever. There was still the issue of sending 100K of data across the country. OK, I have done enough development to know that pages can be g-zipped. On the java side, I had written custom filters to compress the jsp pages and expected to find something on the ASP.NET side as well. First reads of the symptom were discouraging as it was hard to turn it on IIS5 (Windows XP) and it has issues, but luckily at home I use Win2K3 for my main machine and was able to find several documents that showed how to turn it on IIS6. After messing with the settings, I was able to get things going. 100K of data transfer was history; IIS6 was doing an excellent job of compression the data and we were only transferring about 30K of data. This made my week bearable and we were able to load all of the data that was required before the week was over.
Of course, I turned on AJAX in the coming weeks and the application ran just as fast on a dialup as on broadband (except for the initial load) but that wasn't bad either on the dialup due to compression.
I am writing this blog 9 months after the fact and I the site that came in really handy was Scott Forsyth's blog especially this post
http://weblogs.asp.net/owscott/archive/2004/01/12/57916.aspx
To Turn On IIS6 Compression
- From the IIS snap-in, right-click on the Web Sites node and click on Properties
- Select the Service tab - Enable Compress application files
- Enable Compress static files
- Select a new Temporary directory or leave the default in there
- Make sure The IUSR_{machinename} has write permissions to this directory. This is the id that IIS runs as
- Save and close the Web Site Properties dialog
Create a Web Service Extension
- In the IIS snap-in right-click Web Service Extensions
- Add a new web service extension
- Call it HTTP Compression
- Point it to c:\windows\system32\inetsrv\gzip.dll
- Select Set extension status to Allowed
Changing Metabase.xml
- Shutdown IIS
- Backup %windir%/system32/inetsrv/Metabase.xml to your desktop or another directory away from inetsrv directory
- Open Metabase.xml for editing
- Find "<IisCompressionScheme" section in the xml file. There should be 2 entries for this. One for deflate and one for gzip. Both these sections will need to be edited
- Update HcDynamicCompressionLevel to 9. Valid values are from 0 to 10. 10 is not recommended by Microsoft.
- Make sure to follow the already entered format for the below sections
- Update HcScriptFileExtensions and add aspx and axd
- Update HCFileExtensions and add css and js
- Update HcScriptFileExtensions and add aspx and axd
- Save the file and restart IIS.
- Once IIS is up and running, make sure to browse the deployed websites to make sure everything is running as expected
There should be some files in the temporary directory. If there are no files in that directory, browse some pages with css files. If there still aren't any files in the temporary directory, you may have to restart this process again.
Afterwards, I found out that you can use the Metabase Explorer from Microsoft to edit the Metabase file as well.
0 comments:
Post a Comment