Configuring MSDeploy in IIS 7

by William March 20, 2010 2:36 AM

I just finished upgrading this blog to the RC of .Net 4 and Visual Studio 2010 and part of the process was to configure 1-Click deploy inside Visual Studio (as demonstrated by Scott Hanselman and Scott Guthrie during the Mix10 keynote).  1-Click is a great feature of Visual Studio 2010 and uses MSDeploy (which has been available for a few months) to do the actual deployment.  I thought it might be useful to share some of the issues I encountered while configuring MSDeploy. More...

Tags: ,

IIS 7

Inserting Binary Data in SQL Server Management Studio

by William March 10, 2010 4:55 PM

Found this useful little SQL script for SQL Server that allows you to insert binary data from a file inside SQL Server Management Studio (not something I need to do very often, but when I do need to do it this can be very useful indeed:)

UPDATE FileType
SET Icon =
  (SELECT * 
   FROM OPENROWSET (BULK N'c:\Upload\Quicktime-icon.png', SINGLE_BLOB) AS [image])
WHERE Extension = '.mov'

Thought I'd post this here so I don't forget it!

Tags:

SQL Server

Image Handling in CMS Applications

by William March 9, 2010 11:01 PM

These days it seems that we are building more and more applications that have some sort of CMS functionality in them (whether the whole web site or just some of the pages that can be edited).  And while this is certainly a good thing, both for the end-user and the site’s developers / designers it does require that we, as developers, give these sites a little more thought than the simple “brochure” sites require.

One area that requires some thought is how images will be handled.  Images are an important part of today’s web and any site that allows dynamic editing of its pages will require the ability to upload and display images.  Where to store these images?  How to serve these images back to clients?  These are some questions I’d like to take a look at (remembering that every site is unique and might require completely different design ideas than those presented here).

File System vs Database Storage

The first question is where to store the actual images, and the debate over this has been going on for years.  The file system is good at handling files, but not so good at handling metadata (at least not too easily) and indexing / searching.  Databases can handle metadata easily, but aren’t necessarily designed to handle larger objects efficiently.  In other words, neither choice is a clear winner, especially if we’re talking about image sizes that average between 256KB and 1MB in size (see the white paper link cited below).

However, with SQL Server 2008’s new FILESTREAM column type and data storage option I think we get a good compromise.  With FILESTREAM columns the actually binary data is stored outside the database proper and can be accessed through the file system, but SQL Server maintains a link to the file data inside the database.  Some advantages that I see with this system include:

  • Database connections aren’t tied up transferring large amounts of data (which might be important as an application scales out).
  • Even though the data is in the file system, SQL Server still recognizes it as part of the database and as such backups will backup the file data as well (thus ensuring image data and metadata is always in sync and easy to restore if needed).
  • Accessing the file data through the file system’s streaming API can reduce memory usage, which again enhances scalability.
  • There are (in theory) no limits to the size of objects that can be stored in the FILESTREAM columns (though I’m not sure how much of an advantage this is in practice).

For more information be sure to read this white paper on SQL Server 2008’s FILESTREAM column type.

Image Sizing (Thumbnails) and Watermarks

It is often necessary to manipulate the images that are uploaded in some way, whether generating images of different  size, added a watermark of some sort, or even more advanced operations such as creating grey scale images.  What is the best way to do this?

Going on the assertion by by job’s IT department that “disk space is cheap, processing power is not” rules out (in my opinion) some sort of on-the-fly manipulation.  Though this could be done, the memory and processing requirements make this type of solution hard to scale.  The same principal applies to adding watermarks to images: doing this on the fly, while possibly easier to implement than storing watermarked images, will result in a solution that is more resource intensive (processor and memory wise) in the end.

Thus, I believe the best solution is to preprocess the images (resize, add a watermark, etc.) and to store those preprocessed images.  This will require more storage space, but in the end it is easier (and cheaper) to scale disk storage than memory or processing power.  Additionally, this will result in the best performance (image download time) for the applications end-users, which is a good thing.

Speaking of which, for applications that need thumbnail images you should definitely create thumbnails on the server and use those as opposed to just setting the width and height in an <img> tag. The reasons for this should be obvious (a 200KB images takes less time to download than a 2MB image).

Caching

One thing that I often see overlooked when people write code for image handlers is setting the HTTP cache headers.  Setting these headers can be an important performance boost for you application, especially if the images are used in multiple places on the site (or on the home page or pages that users will often navigate to.)  Setting the appropriate cache headers (and recognizing headers in the request such as "Is-Modified-Since” and responding accordingly) allow the client’s browser to effectively cache the images, reducing bandwidth usage and speeding up page rendering times.

Other Considerations

There are other considerations to dynamic image handling (like how to identify them: by name, keyword, ID, etc.)  but I think the above three are the major ones to consider when designing an image handling system.  If you get the storage as efficient as possible and enable client-side caching you are well on your way to a well-performing and scalable image handling solution.

до свидания!!

Tags: , ,

ASP.Net

Welcome to William's Blog!!

by William March 4, 2010 1:03 AM

It's officially official, I have decided to maintain a blog.  It's something I've thought about doing for some time so why not get started?

 

Being a web developer it is likely that this will often resemble a "tech" blog as I discuss things I have learned in my day-today coding as well as new technologies that I find interesting.  I am a Microsoft .Net developer so that is the platform I will most often talk about, but I have some experience in PHP so I can't rule that out as well.  Whether you love Microsoft or hate them you can't deny the fact that they have contributed (and continue to contribute) to the internet as a whole, both in server technologies, their new cloud platform (Azure), and of course everyone's favorite (sic) web browser: Internet Explorer!!

 

I'll probably also talk about my place of employment, DiscoverTec.  DiscoverTec is located in Jacksonville, Florida and has been around for 16 years now. It is a great place to work (no, I wasn't even paid to say that....) and has some talented people working there (contrary to what my presence there might indicate....)  

 

That's all for now, I need to get back to styling this blog (and since I'm a "developer" I'm not exactly sure how that will turn out....)  There should be plenty of activity on here next week, however, as Mix10 is fast approaching and I will be attending!  I can't wait for that, there look to be some really great sessions this year (and Molly Holzschlag will be giving a workshop on HTML5, that should be real cool).

 

до свидания!!

Tags: ,

General

Who is William?

William Jerla
MCTS
William Jerla is the Senior Application Architect at DiscoverTec, a Web Design and IT Services firm located in Jacksonville, Florida.
William is a Microsoft Certified Technology Specialist in ASP.Net 3.5 Web Applications.

Recent Posts