Warp factor 9

Workbooks is accessible worldwide, with any modern browser.  We have users in Europe, the USA and as far afield as the South Africa, Thailand and Mauritius.  The Desktop is a large amount of JavaScript, together with many assets.  So why is it still fast to load the Desktop?

  • We’ve gone for extremely high-capacity network connections – recently upgraded by our provider to 10 Gbit/s – with low latency to our nearest major peering points and especially through LINX.
  • All our assets are packaged and do not cache-expire – built using Scott Becker’s excellent Asset Packager plugin. So once they are downloaded they are not re-fetched until we release a new version of our software.
  • Most interestingly, and most recently, we’ve adjusted our TCP/IP parameters to follow some neat tricks Google and Microsoft have been adopting recently…. I’d like to explain that here.

TCP/IP connections on a standard network stack often stall over high-latency (often this means “long distance”) network connections because the sending client waits for an acknowledgement packet after a small number of packets have been sent. Worse, this number doesn’t increase much and for very long: it reduces even on TCP connections which use HTTP keepalive.

The initial TCP window size has been bumped right up to 10 packets, which is a full 15K bytes (standard “slow start” settings would allow only 1 or 2 packets to be in transit before an acknowledgement is received).  So we can have up to 120K bits in flight before we need an acknowledgement packet back from the far end. This is almost always long enough for all the data in a server response to a client request so windows get drawn on the Desktop with the minimum of delay.

Finally we’ve now adopted a congestion-control technique called ‘CUBIC‘ which is much better for high-bandwidth but long-distance connections than our previously-adopted ‘Reno‘.

Background reading:

Advertisements

Unexpected logout, expired cookies, sessions and the CKeditor

The Workbooks Desktop, different though it is to most web applications, is typical in that it uses cookies to track sessions. So when you log in a session cookie is stored in the user’s browser and from then on each request from the Desktop has the cookie included in the request.

But, starting a couple of weeks ago we started getting strange behaviour: some users reported getting logged out at various, seemingly random, times. We ruled out all the obvious causes, went through all the changes in our most recent release, but could not see what was going on. It wasn’t specific to any particular user, browser, request, network, operating system or time of day. Or anything else we could think of. We added diagnostic code and all that told us was that after a few hundred perfectly normal Ajax requests suddenly and without any apparent cause there was no cookie included with a request and our Desktop would respond by asking the user to login again. After a few logouts this rapidly becomes unfunny.

Eventually we discovered that we had literally dozens of cookies stored against our domain name in the affected browsers with names like scayt_1__options. A quick search through our source found that our new version of CKeditor had changed so that now the ‘SCAYT’ (Spell Check As You Type) plugin is enabled by default – and that integration creates literally dozens of cookies to hold your spelling preferences!

The browsers didn’t send all these cookies to us every time – they have different Paths to most of our app – but those browsers did discard the much more important Session cookie randomly – because browsers guarantee surprisingly little with regards to the retention of cookies.

Once we’d identified the problem the solution was easy: disable the plugin.

Essential TextMate Plugins

[tweetmeme service=bit.ly]
Our development team has now got upwards of 20 man-years experience with TextMate so we thought it would be a good idea to share with you the most useful bundles we’ve come across so far. If you feel there are any glaring omissions, then please leave a comment!

AckMate
http://github.com/protocool/AckMate

If you have worked with TextMate for any period of time, you will come to realise that the Find in Project is woefully inadequate. Fortunately, the plugin architecture means that a much superior alternative is available. Most programmers will have come across Ack, but for those of you who haven’t, it’s a technology that harnesses the power of Perls’ regular expressions and is very good at working with large trees of heterogeneous source code.

Once installed, the selected folder in the project drawer will be the root of the search and Ctrl + Alt + Cmd + F will open up the AckMate window. Results are displayed with a line above and below the matching text giving some context to the results.

See http://betterthangrep.com for more information on Ack.

RubyAMP
http://www.ruby-lang.org

RubyAmp adds a few productivity aids to TextMate. The most useful I find being the “Complete across tabs” (Ctrl + ; ). This works in a similar way to how pressing Escape will autocomplete within a file and provides the same functionality across multiple open files showing a popup list of possible matches, with the first 10 mapped to the number keys. Another really useful feature common amongst IDEs for statically typed languages is the ability to easily jump to method definitions, classes etc by using shortcuts.

ProjectPlus
http://ciaranwal.sh/2008/08/05/textmate-plug-in-projectplus

This bundle adds a few bells and whistles to the project drawer in TextMate. Instead of the standard fly-out drawer, ProjectPlus gives you a pane which remembers the state of your project tree and open tabs between opening and closing projects. One key feature adds SCM badges to the files and folders in the project drawer giving a quick and clear indication of files and folders within your SCM. Other small features include: “Show folders at top” instead of the default alphabetical order, “Sort by filetype”, Finder colour labels and QuickLook.

Installing Bundles

To install a .tmbundle file, place it in ~/Application Support/TextMate/Bundles and then select “Bundles > Reload Bundles” from TextMate. If you use TextMate with multiple OS X user accounts then .tmbundle files can copied to /Application Support instead.

Final note

On the subject of TM additions, by far my favourite syntax colouring scheme is the one used by railscasts.com available from here. Also, if you use code within presentations, it’s often really useful to copy blocks of code whilst retaining their style when pasting into another application. This is easily achieved using “Copy with style” available from here.

Long-holding shortcut keys in OS X (and other cool combos)

[tweetmeme service=bit.ly]
I switched to Mac around 10 years ago and have picked up a variety of shortcuts over the years to streamline my workflow. But, something I only found out about this weekend was the “long-hold”.

What’s a long-hold?
Hit your Dashboard key. Your dashboard appears. Hit the key again and it disappears in an equally pleasing manner. Now try it this way: press your Dashboard key (and keep it held), your Dashboard will appear. To make it disappear simply let go of the key!

Where else does this awesome trick work?
Well, since I’ve only just found this out, I’ve not had a huge chance to uncover many goodies, but here’s what I’ve found so far. Leave a comment if you know of any others.

  • Dashboard
  • Exposé
  • Dictionary lookup (Ctrl+Cmd+D)

What other shortcut modifiers don’t I know about?
Clicking menu items, or shortcut keys whilst holding shift or option can do slightly different things, here’s a list of things I’ve discovered, some of which are useful, some not so much:

  • Hold Shift while changing volume to suppress the system click
  • Hold Option while clicking on the volume or wireless menu items changes the menu items
  • Hold Shift while opening Spaces, Dashboard or Exposé – I’ll let you try that out out (very cool)
  • Holding Command allows you to reorder icons on the menu bar by dragging them about
  • When using Command+Tab to switch windows, holding shift as well allows you to move right to left
  • For fine-grain control when dragging scrollbars, hold Option to scroll one pixel at a time
  • Want to drag a window in the background without activating it? Hold Cmd

Those were cool, are there any other shortcuts that need a place in my life?
Yep. Some of these are amazingly handy, some not so much!

  • I find windows users complain a lot about the lack of Home and End keys which on a PC keyboard are tucked away somewhere 3 feet to the right of the keyboard.  Life with a Mac is easier as these keys are under your fingers already: Ctrl+A and Ctrl+E (should be familiar to you unix peeps) and Cmd+Left and Cmd+Right for beginning and end of line.
  • Here’s a couple for Safari that I use a lot: Ctrl+L puts focus in the Location bar and Ctrl+Shift+L will open a new window having Googled for the highlighted word 🙂
  • I covered it earlier, but to bring up the dictionary definition of a word in a Coco app: highlight the word and press Ctrl+Cmd+D
  • Ever wanted to blank the screen? Ctrl+Shift+Eject will turn brightness down to nothing.  Moving the mouse or typing will bring it back.  This works with long-holding too.
  • I’ve also noticed Windows users are very familiar with pressing Enter or Delete when highlighting icons in Finder.  On a Mac, the keys you want are Cmd+O to Open the item and Cmd+Delete to move it to the trash.

Please leave a comment if there are any other hidden gems you want to share with the world.

Reading Geek Night

[tweetmeme]
An open community event for techy-types is getting underway in Reading.  These events are for people to get together in an informal setting, share knowledge and have a couple of beers!

The first of these monthly events is happening next Tuesday on the 10th November.  Add http://readinggeeknight.com/ to your bookmarks and check it out regularly for updates.  You can also follow @rdggeek on twitter or the #rdggeek hashtag.

Talks lined up for the first event are:

Who do you think you are? Ben NunneyThe internet is everywhere, and all of us in the tech community are connected in some way, shape or form. But how powerful is your digital identity, and what does it actu- ally matter to you? The talk will be a brief look at what your digital identity is, was, and can be – who are you, in the eyes of the internet? Does your boss really care what you had for lunch?

A practical introduction to Ruby on Rails Chris TingleyThis live code demonstration will take you from your first line of Ruby code, through some fundamental features of Rails with pit stops in MVC, CRUD, REST, automated testing and meta-programming, crossing the finish line with a functional web app! Hold on to your hats, all this WILL happen in 15 minutes.

What Is Windows Azure? Dom GreenWhat is Windows Azure? How will cloud computing change how we develop applications, manage our IT infrastructure, or even set up an online business? This whirl-wind talk will introduce Windows Azure, Microsoftʼs cloud computing platform.

Coding for kids Jim Anning – Coding is not routinely taught in UK schools until 6th form level. How can we encourage a new generation of kids to code? A quick introduction to MIT’s Scratch programming environment.

Tracking down a stolen laptop

[tweetmeme]
This is a bit off-topic, but worthwhile sharing.

I recently, rather unfortunately had my laptop stolen and now I have a replacement; I remember hearing about software that could use the built in iSight to take photos of the thieves and mail them back to me.

After looking on the net and finding some rather good, but pay-ware applications, I came across the Prey Project offering an open source free alternative. I went about installing the software and after checking that it worked went about tweaking it to work with how I have my laptop set up.

I use file vault (thank God it was switched on the laptop that was stolen) and have a password on wake so my personal files are secure. However, even with crontab running Prey once a minute, I figured that if the thief couldn’t log into my laptop, it was a bit pointless. So I have used two tactics that will hopefully result in my getting some pictures if the unfortunate were to happen again:

  1. Enable logging in of the Guest account. This means if the thief reboots the laptop (to try and log in as a different user rather than get the password screen from wake), they can log into a sandboxed account with Prey happily snapshotting away.
  2. Put Prey in the crontab that runs for the login screens:

in /private/etc/crontab (this may not exist):

*/1 * * * * cd /usr/share/prey; ./prey.sh

Of course, there are no guarantees, but it’s better than nothing.

Welcome

Workbooks is developing a new application, delivered using the “Software as a Service” model. Eventually we’ll no doubt post more about what the application does, and who it’s aimed at – if you want to know more go to the Workbooks website. This is the blog of Workbooks’ development team; as we discover things which may be useful to the community in general we’ll publish them here.

Technically, we’re using Ruby on Rails and ExtJS as a starting point. We’re fans of the Apple MacBook Pro and use it to run VMware Fusion as a host for 64-bit Linux development systems.

There are a lot of blogs which are quickly created and become moribund. Then there are those which have a community of subscribers in the millions. While I doubt this will be the latter, we’ll do our best to fill it with useful technical information.