Skip to content

BrowserMob: Load test your applications using the cloud

Via this tweet from Matt Raible, I learned of BrowserMob.  This service allows you to easily load test your web application.

I set it up in about 2 minutes to do a simple load test of a client’s site (though 5 pages).  They make it free to ‘test drive’ their service (though the free not enough to actually stress your site).  It is extremely easy to test a path through a publicly facing system.

The report was good enough; you get screen captures of pages that have failures, and they do a good job of making some of the performance data pretty and intelligible.  Again, I didn’t really load test anything, so I didn’t examine the report as closely as I would have in a real world scenario.  The service is built using Selenium, and I believe they allow you to upload full featured selenium tests (if you have already invested in this technology, but don’t want to build out a cloud network).

This service is of particular interest to me because last year I was part of a project that built a selenium grid on Amazon EC2, using these instructions.

If we’d known about BrowserMob, I’m not sure we would have used them, as I don’t know what our budget was, but it would have been nice to have that in the evaluation mix.

[tags]browsermob, cloud services,load testing[/tags]

Moving data from MS-SQL to mysql

I recently worked on a project where I needed to port data from a MS-SQL database to a mysql database.  There are programs, both payware and freeware that will help with this process, but I didn’t have ODBC access to the MS-SQL database, which these programs require.  All I had were a bunch of insert statements that looked like this:

INSERT INTO
[sample].[dbo].[users_info]([ID],[registration_day],[registration_month],
[registration_year],[registration_time],[first_name],[last_name],
[username],[userpwd],[repeat_pwd],[birth_date],[birth_day],[birth_year],
[street],[state],[city],[zip_code],[email_address],[membership_startdate],
[online],[gender]) VALUES(463,N'15',N'7',N'2009',N'9:13:52 AM',N'Homer',
N'Simpson',N'homerrocks',N'beerbeer',N'beerbeer',N'January',N'1',N'1999',
N'234 Main',N'Alaska',N'Springfield',NULL,N'homer@thesimpsons.com'),
CAST(0x9AE90000 AS SmallDateTime),
CAST(0x00009CD700000000 AS DateTime),N'Man');

I wrote a perl script to turn that dialect of SQL into a mysql friendly dialect (feel free to download it).

The most interesting parts were those CAST statements.  This forum post and this blog post helped me turn those casts into real dates.  (After loading the inserts into mysql, I did some post processing, using the helpful case statement and str_to_date function to rationalize some of the data.)

[tags]mssql, mysql, data migration[/tags]

How to get IE to accept third party cookies

Third party cookies are most often used by ad serving companies, because they are set by an image or other resource that can be pulled from a different domain, they are one way of tracking behavior across websites.

A short example: If I visit site A (www.foo.com) and site B (www.bar.com) and they both pull an image from site C (www.baz.com), it can set cookies for the site C domain (.baz.com), with a value of siteA or siteB.  Then when I visit site C, it ‘knows’ that I’ve been to sites A and B.

This can be sinister (see the wikipedia link above for privacy concerns).  However, if you have multiple web properties, then you may want to tie user behavior together across properties.  Third party tools like Google Analytics offer one way to do this, but if you want custom application behavior, then third party cookies are probably the way to go.

Firefox (at least my version of firefox, without any add ons or options changes) treats third party cookies much the same as first party cookies; that is, they just work.  However, IE requires a bit more hoop jumping, as they check the p3p compact policy.  A compact policy is basically a header you set which looks like this: P3P: CP="CAO PSA CONi OTR OUR DEM ONL".  I looked around for an easy explanation of what the various values are and how to set them in a coherent manner, but didn’t run into anything very useful.  However, I finally stumbled on this tutorial, which points you to this IBM software, which you can use to create a compact policy.  The tutorial also walks you how to use that software, which is not entirely intuitive.

As far as I can tell, IE doesn’t actually check for the existence of the corresponding policy file, nor does it care if the site does what the p3p header says it does, but it does require a valid compact policy.

After you’ve added that header, IE (versions 6-8) will accept your third party cookies.

[tags]third party cookies, compact policy, howto[/tags]

Upgrading to GWT 2

I recently had the pleasure of upgrading from GWT 1.5.3 to GWT 2.0.  The client has a variety of GWT applications–some standalone widgets that integrate into an existing site, an application written with GWT look and feel, and an application written with the GWT-EXT library.

The upgrade to GWT 2.0 was much less painful than I thought it would be.

Even code that was written for GWT 1.0 (the mortgage calculator, written back in 2006) compiled cleanly (well, plenty of warnings, but no loss of functionality).  Classes that have been deprecated (some for good reason; hello HTTPRequest, I’m looking at you) have not disappeared.  I’m not saying that the code I wrote for GWT 1.0 shouldn’t be rewritten, just that GWT hasn’t forced me to do so.  Also, other than changing some switches to the command line compiler, the ant script used to compile the GWT modules didn’t have to change at all.

Hosted mode was a different story.  I never really spent a ton of time in hosted (err, dev) mode, but had it working in that past.  Now, I wanted to get it working fully because of the tremendous productivity gains possible–no minute long compile cycle to pull my attention away from my code.  And the fact that you can run and debug in eclipse in more than just one browser is really attractive.  Since I’d never really had it working fully, there wasn’t a lot of upgrade work; it was more like starting from the beginning.  However, I was unable to use the internal jetty server.  Again, my use case is atypical, with a lot of JSON and JSONP requests for data.

Big pluses for GWT 2.0, right off the bat:

I haven’t yet looked into Speed Tracer or some of the updated widgets (I’d really love to toss the gwt-widgets lightbox we use in favor of the GWT standard PopupPanel).  There’s also the tremendous benefit of being on the modern version of any platform–it is easier to get support in forums and in other venues.

GWT widgets and code splitting, a match made in heaven

If you are writing a typical GWT application, which is monolithic and controls the entire viewport of the browser, you probably don’t want to read this post.  Go on, read something else interesting–you probably have emails or tweets or something better to do with your time.

OK, now we just have the people left who are using GWT to build widgets; that is small encapsulated pieces of functionality that integrate into an existing web based application (case #2 outlined here).  If you’re doing this, and you use the “span to enable” gwt mini pattern, you want to upgrade to GWT 2.0 simply to get the new code splitting functionality.  If you don’t want to read that previous link, the synopsis is that code splitting lets you define a number of pieces of distinct code, using GWT.runAsync.  Then, that code won’t be downloaded until it is reached.

Previous to this feature, if you had a number of widgets, you ended up with a large chunk of code to download on every page (this is an issue with GWT that the monolithic applications simply don’t have to deal with).  Some of that code will be run.  Some will not, but you’re still paying for download and parsing of that code.  You had some unsavory options to deal with this–let all the code be downloaded, or manually split up code into separate modules that you managed (either by hand or with deferred binding).  The second solution led to smaller downloads, but meant a lot more management–if you wanted to add a widget to a page, you not only had to add the enabling span, you had to recompile the entire GWT module–and much longer compilation when you deployed your entire web application.  However, if your widgets were static, this path might have been an option.

My client used the former solution (entire code download on every page), and was very excited about the code splitting, since that essentially automates the second choice above.  In the space of about one half hour, I was able to reduce the initial download size of the GWT javascript by 10%, and there’s scope for much more, since the code is pretty naturally split up into separate chunks for each widget.

It’s not perfect, however. The two concerns I’ve had so far:

  1. The XS linker is not supported.  This means that if any of your widgets need to be cross domain, you need to create an additional module specifically for that.  For example, if I have one module, A, which is used to start up all the widgets on the site, and inherits from both module B, which has some GWT code split calls, and module C, which needs to be cross domain, the compiler will error out when compiling module A.  I need to create a second module XSModuleC which inherits from module C and is compiled by the XS linker, and then use that module for all cross domain purposes.
  2. If you call GWT.runAsync from an event handler, like onClick, you will not have a valid event on the first call (when the module is loaded) but will on all subsequent calls.  This is easy to fix, but was a bit mystifying to me.  Basically, if you have code like this:

onClick(ClickEvent event) {
if (event.getSource() instanceof Image) {
// do something with image
}
}

you need to replace it with:

onClick(ClickEvent event) {
if (event.getSource() instanceof Image) {
// save event.getSource into an instance variable
GWT.runAsync(new RunAsyncCallback() {
// do something with image in instance variable
}
}
}

I'm sure there are other complications I'll find once I do more code splitting.  (Here's an interesting post about code splitting in large applications, and simplifying the API of code that is split (plus, you get to see the word cromulent in context).)  But, for now, code splitting and GWT widget development seem like a match made in heaven.
[tags]gwt,code splitting[/tags]