Tuesday, June 26, 2012

A .NET guy @Velocityconf 2012 - Day 1

Thanks to my company, this year have the honour to attend VelocityConf - a conference about performance and optimizations organized by O'Reilly. Needless to say, that there are very few .net developers here beside me and my colleague - in fact we are still looking to find the first :). Still, the topics discussed here are general enough to apply to our developers that deal with web development regardless what technology and framework is used. This is my first conference outside Bulgaria and there are lots of everything stuff going on here in Santa Clara.

The first day was an optional one and consisted of four time slots with four different tracks. These had to be workshops, but I think almost all of them ended up like a regular sessions. Nevertheless, the topic and the speakers were very interesting, so I will try to present some useful abstract from those I attended.

The day started for me with the session "Understanding and Optimizing Web Performance Metric" by Bryan McQuade from Google. He explained in greater details how the browser's render works and showed us the most frequent problems we might get into it. He played with the PageSpeed Insights Tool and showed what usually slows the downloading, rendering and displaying of the typical web pages. We took a look at the Critical Path Explorer feature that will be of great help when optimizing the loading of your web pages. It now only shows you how many time each resources takes to load, but also reveals which resources is blocking the rest of the page, how much time it takes to apply the css for example to the web document and many other useful properties. Another great new thing I learned was the Navigation Timing API, which is basically a library that gives you information about how much time takes to get to different events while loading your web page. It starts with the DNS lookup, TCP connection establishing and ends with the completely loaded page. This API is part of a W3C specification and is implemented by most modern browsers - it's there to help you meassure the latency and find possible bottlenecks. My takeaways from this sessions are:
  • to be very careful with the document.write as this might greatly degrade the webpage rendering speed by blocking the processing of other resources. 
  • to be make redirects for mobile content cache-able per user as this will save some round-trips to the server (and round-trip to the server when browsing with mobile device can be quite expensive)
  • to include the complete certificate chain when using SSL in order to save additional requests
  • to specify the encoding of the resources in the response headers
The day continued with "Taming the mobile beast" by two guys from Google - Matt Welsh and Patrick Meenan. They presented a lot of tools for mobile development and more precisely performance measuring and optimization. The remote debugging feature of Chrome is something that worth mentioning. You can debug you web site by attaching your mobile device to you dev machine with USB cable. From there you can browse the website using your mobile connection (or WiFi one) and this way troubleshoot the real mobile experience (traffic is going through mobile carrier, rendered by real mobile browser, etc.). You can even inspect the DOM and you will get the selected element right on your device - really neat. In iOS 6 there will be similar feature for Safari. Those guys showed also numerous bookmarklets (bookmarklet is unobtrusive JavaScript stored as the URL of a bookmark in a web browser or as a hyperlink on a web page. "Wikipedia") like Firebug lite, ySlow mobile, jdrop (for sharing bookmarklets), dommonster (for inspecting the DOM), docsource, csses, snoopy, spriteme, navigation timing bookmarklet (that utilizes the mentioned above navigation timing API) and many others. Some things to have in mind when developing for mobile:
  • JavaScript is a lot slower when used in mobile browser (mainly because of the slower processors)
  • Mobile carriers use proxies that behave differently depending on the hardware and configuration used in the particular mobile operator. Testing with mobile connection is essential and WiFi cannot be a replacement.
  • Caching behaviour is different on different devices - in general it's much smaller, sometimes is not persisted after closing the browser or restarting the device.
  • Initiating a TCP connection is much slower operation, moreover it has different round-trip time in different countries
  • The LTE standard is getting popular and will get things better ... but not much, since the real bottleneck is not the speed, but the latency. It takes a several seconds for the devices only to negotiate for a radio channel with the cell.
  • Because of the above point - more parallel connections are not always coming for better. We get a performance penalty for negotiating for new connections.
After the lunch break Ian White from Neustar gave us the "Dev vs. Prod - Optimizing your site without making your build process suck). A great introduction in nginx - a lightweight server used mainly for serving static content. We have already discussed using this server for our resources with my colleagues and this session was a great demo of its features. Nginx proves to be a lot faster than IIS when comes to serving static content like images, stylesheets, etc. You get a great control on what is served to the client with what particular headers and properties. I hope that we will soon get the chance to put it into practice.

Last, I visited Baron Schwartch's session about "Benchmarks, Performance, Scalability and Capacity - What's behind the numbers?". Nice talk to gain general knowledge into the topic of preparing benchmarks and analysing charts and statistical data - not a big practical use for me, though. 

This great first day ended with a party by the pool area. I'm really excited and looking forward to day 2.