Open Menu

Synergex Blog


Why is That First WCF Operation SO Slow?

By Steve Ives, Posted on June 25, 2015 at 12:06 pm

If you have ever developed and worked with a WCF service you may have noticed that the very first time you connect to a newly started instance of the service there can sometimes be a noticeable delay before the service responds. But invoking subsequent operations often seems almost instantaneous. Usually the delay is relatively short, perhaps even just a fraction of a second, but still noticeable. Well earlier this week I encountered a WCF service that exhibited this behavior, but the delay for the first operation was almost three minutes! Something had to be done.

Some time later, after much debugging, web searching and more than a little head scratching, we realized that the “problem” that we were seeing was actually “by design” in WCF and was related to the generation of metadata for the service. It turns out that if “metadata exchange” is enabled for the service then WCF generates the metadata, regardless of whether anyone is currently requesting it or not, at the time that the first operation is requested by a client. Often the generation of the metadata takes almost no time at all, but as the size and complexity of a service grows (in terms of the number of operations exposed, the number of parameters, the number and nature of complex types exposed, etc.) the time taken to generate the metadata grows. In the case of this particular service there were over 800 individual operations defined, with lots and lots of complex types being exposed, and the service was still growing!

The only time you need metadata exchange enabled is when you need to access the WSDL for the service, so in simple terms whenever you need to do an “Add Service Reference” or “Update Service Reference”. The rest of the time having it enabled is just slowing things down at runtime.

I can’t tell you exactly how to enable and disable metadata exchange with your service, because there are several different ways it can be configured, but it’s likely going to be one of these:

  1. A <serviceMetadata/> token used in the <serviceBehaviors> section of a Web.config or App.config file.
  2. An <endpoint/> token that uses the IMetaDataExchange contract defined in a <service/>section of a Web.config or App.config file.
  3. Code that does the equivalent of one of the two options above.

So the lesson learned was to enable metadata exchange only when it is needed, for the purpose of creating or updating client proxy code; the result was an almost instantaneous response from the service once metadata exchange had been disabled. Of course it goes without saying that metadata exchange should NEVER be enabled on production services.


Free Stuff!

By William Hawkins, Posted on March 14, 2011 at 2:46 pm

It’s a rare occasion where anything is truely free. Most of the time it’s simply a way for a marketing company to obtain information about you, so they can provide (or bombard) you with information about products that you have no interest in purchasing. However, there are some occasions when “free” really does mean that there’s no additional cost. The Synergex CodeExchange is (IMHO) one of those gems.
In may last blog, I discussed the process of validating a large number of the CodeExchange submissions with Synergy 9.5 and Synergy for .Net. In this blog, I want to highlight a couple of new submissions that you may find useful.

SynArrayList – this submission contains a couple of subroutines that allow you to sort an ArrayList in Synergy, either using a bubble sort or dynamic memory/qsort. You probably won’t need to use both methods of sorting, but they provide code examples to allow you to create custom sort routines of your own. This submission also contains an example of extending the ArrayList class, and creating a new class that processes Synergy alpha types natively.  This allows you to avoid the requirement to box/unbox your alpha variables as you process a collection.  Of course, the underlying arraylist still requires object types, but you don’t have to be concerned about that. And it has sort() and reverse() methods and some other ArrayList method that are part of the ArrayList class in .NET

SourceTree – this submission builds a utility that will parse your source code, and generate a data file that records the subroutine/functions in your application that call other subroutines/functions.  This allows you to create documentation on where routines are used in your application.  It can also be used to generate a list of routines called by a particular subroutine/function/mainline and all the routines that are called by those routines.

I’m also working on some other CodeExchange submissions – examples include a file I/O class and a utlity to create the xfNetLink attributes that can decorate your code.  Watch this space!!!


Windows Live SkyDrive

By Steve Ives, Posted on June 28, 2010 at 5:13 pm

Have you ever wished there was an easy way to view and edit your documents on different computers, in different locations, in fact … from anywhere, and without having to carry USB thumb drives, or log in to a VPN. Well there is, and it’s free.

For some time now Microsoft have offered a free service called Office Live Workspace, (http://workspace.officelive.com) which went part of the way to solving the problem. Office Live Workspace essentially provides 5GB of free on-line storage, and a web-based portal, which allows you to upload, manage and view your files. It’s primarily designed to deal with Microsoft Office files, although other files can be stored there also.

Office Live Workspace worked pretty well, but it did have some restrictions, which meant that the experience was somewhat less than optimal. For example, when viewing a document it would be converted to an HTML representation of the actual document and displayed in the browser. You do have the option to edit the document of course, but doing so required you to have a recent copy of Microsoft Office installed on the computer that you were using. This is probably fine if you are using your own system, but was likely a problem if you were using a public computer in a hotel or an airline lounge.

On the positive side, if you did happen to be working on a system with a recent copy of Microsoft Office, and had the Windows Live Workspace extensions installed, it was possible to interact with your on-line storage directly from within the Office applications, similar to the way that you work with files on a SharePoint server, and this worked really well.

So, using Office Live Workspace from within Microsoft Office was a good experience, and at least you could get to, view and download your files from any Internet browser.

There is also another interesting product called Windows Live Sync, which kind of approaches the problem from another angle. Sync allows you to synchronize the files in one or more shared folders with one or more other computers. If you add a file on one computer it is replicated, pretty much instantly, to the other computers that “subscribe” to the shared folder. This is a very different approach, because although your documents clearly flow over the network (securely of course), they don’t get stored on network servers. So this is a great solution if you want to be able to edit a document at home, and have it magically appear in a folder at work so you can work on it the next day. But there is no access to the files via a web browser on some other computer.

Enter Windows Live SkyDrive (http://windowslive.com/online/skydrive), which seems to combine the concepts of both Office Live Workspace and also Windows Live Sync … and then adds even more.

SkyDrive is a free service providing 25GB of on-line storage. Like Office Live Workspace it has a web-based UI, which allows files to be uploaded, viewed, downloaded, etc. It is also possible, of course, to edit your files directly using your local Microsoft Office applications. So far so good … so what’s different?

Well, perhaps the main different is that as well as allowing documents to be viewed in your web browser, SkyDrive also integrates Microsoft’s new Office Web applications. So, not only can you edit your Word Documents, Excel Spreadsheets and PowerPoint presentations locally, you can also do so directly in the web browser! You can even create new Office documents directly on the server in the same way.

Of course the new Office Web applications are somewhat cut-down versions of their desktop counterparts, in fact they only have a fraction of the capabilities of the full products, but never the less they are very usable, and allow you to do most of routine editing tasks that you likely need to for day to day work on your documents. Remember, this is all for free – pretty cool!

But there’s more … SkyDrive also provides Sync capabilities also. Not for the full 25BG of on-line storage, but there is also a 2GB “bucket” that you can use to setup synchronization of documents between computers … the difference is that the documents are also available on the SkyDrive. So now you can edit your documents locally at home, or at work … on your own computers, but still have access to them via a web interface when away from your own systems. Unfortunately the Office Web apps can’t be used on these synchronized files (hopefully that will change at some point), but you do have access to them from any browser.

By default everything that you upload or Sync through any of these products can only be accessed via your own Windows Live login … but you can setup shares and give others access to all or part of your storage too. And there is specific support for creating shared on-line photo albums too.

Oh, I almost forgot, if like me you use a combination of Windows and Mac computers then all of these products work just great on Mac too. In fact, personally I think the Office Live Workspace experience is actually better on the Mac than the PC! I have just finished testing SkyDrive on the Mac too, including Sync, and it works wonderfully well.

SkyDrive is currently a beta service, but is in the process of transitioning to full production use about now. I’ve been playing with it for a little while now, and it seems to work extremely well. Check it out.


Don't miss a post!

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Recent Posts Tag Cloud Archives