Posts

Showing posts from 2013

Using Xamarin Sharpie to build a Flurry assembly

Image
The main project I work on is a series of Xamarin based apps for iOS devices.
To help track usage stats we use Flurry Analytics which gives us a handy dashboard showing us session usage, device & OS breakdown, error logs, etc.

With the iOS 7 release, Flurry required a update:







Flurry doesn't have a .Net assembly out-of-the-box, so we needed a way of converting the native library into .Net.

When we had added Flurry to our project ages ago, we started with the Flurry monotouch-bindings to get things started. However this time Flurry had changed something in their library and the monotouch-binding no longer worked correctly. Trying to run the app with the built assembly resulted in build errors including:
Undefined symbols for architecture armv7:
  "_SecItemAdd", referenced from:
      -[FlurryKeychainWrapper setData:forKey:] in libFlurry.a(libFlurry.a-armv7-master.o)
  "_SecItemCopyMatching", referenced from:
      -[FlurryKeychainWrapper dataForKey:] in libF…

Intro to using the Windows Debugger

Image
Windows Debugger can be downloaded as part of the Windows SDK. I would install both the 32 and 64bit versions.

I used it in the past when diagnosing why a website was performing poorly during peak periods. Users would hit the website url, wait for 30+ seconds and then the site would appear quickly. Even the home page which did nothing (i.e. no db hits), was slow to appear.

I got a memory dump from the server and using the analysis approach below could see that all available IIS worker threads were in use and all were busy rendering. The server was starved of threads and user requests were ending up in a queue waiting to be processed.

I tweaked the IIS settings and added more worker threads. The problem went away. Thanks Windows Debugger!

How do you to get a memory dump? 1. Open a command prompt
2. Get the list of worker process ids:
%systemroot%\system32\inetsrv\APPCMD list wps This is a useful page describing how AppCmd works: http://www.iis.net/learn/get-started/getting-started-wit…

MVC HTTP Headers for CDN caching

Image
On a recent project I added upgraded our systems to use a Content Delivery Network (CDN). The project supplied content to users and we wanted to offload the 'heavy-lifting' of the content supply away from our PROD server onto a more robust delivery network.

The mobile clients would request the content from the CDN. If the CDN hadn't cached the content yet, it would grab it from our PROD server, cache it, and respond back to the clients. For this caching to work, though, some HTTP Header magic was required.

Which headers should you watch out for?Cache control should be publicFor the CDN to cache the content on behalf of your origin server, set the Cache-control=publicExpires DateTo stop the CDN regularly requested the same static content from your PROD server, set the Expires-Date setting to be in the far future (e.g. > 1 year) Vary Watch out for the 'Vary' header. MVC3 had initially defaulted to adding the "vary=*" http header which stopped the CDN fr…