Lee Butts's blog

Lee Butts's picture

Grails UI Performance Plugin - beware of uiperformance.html.compress

We use the excellent UI Performance plugin (thanks Burt!) to help optimise ShareYourLove.com and on the whole it does a great job.

One option that I have found has an undesirable side effect is uiperformance.html.compress.

This option enables the PJL Compressing Filter to compress the html content of the responses. Unfortunately this adds a Vary: Accept-Encoding header to every response, including images, javascript etc.

This header causes browsers (we especially noticed it with IE) to re-request all resources even when the have far-future expires headers (as added by the ui-performance plugin). This was causing slow page loads for users, especially those on slower/high latency connections. Even though our server would return 302: Not Modified in response to all these requests, the connection overhead (the site has a lot of CSS images) was still a significant performance hit.

By disabling the html compression option, the site caches much better and only the main content of each page (and any new resources not in the cache) is requested each page view. You would need to access whether the smaller download gains of html compression, outweigh the extra server requests for resources when configuring this option on your application.

I tracked this down with the help of Fiddler2 which is a proxy that analyses your browser requests and provides guidance on best practices to improve performance. There is a good page from the Fiddler explaining the Vary header here.

Lee Butts's picture

Grails, Shiro, IE8 and RememberMe

UPDATE: We're still having RememberMe issues under IE8 so there more to this bug than the solution posted here. I will update this when we get to the bottom of it.

I've recently been looking at a bug we had with IE8 and RememberMe cookies not persisting at ShareYourLove.com when users closed their browsers.

The crux of it was that Shiro was not explicitly setting a domain on the cookie which apparently is a no-no as far as IE8 is concerned.

The fix is to configure Shiro's SecurityManager via resources.groovy:

beans = {
    shiroSecurityManager(DefaultWebSecurityManager) {bean ->
        realms = [ref('JsecDbRealmWrapper')]
        //override remember me expiry to 30 days
        rememberMeCookieMaxAge = 60 * 60 * 24 * 30
        switch (Environment.current.name) {
            case 'beta':     
                rememberMeCookieDomain = '.beta.shareyourlove.com'
                break      
            case 'production':
                rememberMeCookieDomain = '.www.shareyourlove.com'
                break
            default:
                rememberMeCookieDomain = null
        }
    }
}

Lee Butts's picture

Grails WebTest Plugin Version 2.0 Released

The latest version of the WebTest plugin for Grails is now available in the central repository.

This is a release to update the plugin to work correctly with 1.2-RC2 and to removed the old run-webtest script in favour of the new test-app -functional integration. If your build server is using run-webtest you will need to change it to test-app -functional

The only known loss of functionality between run-webtest and test-app is the custom test suite behaviour. If you need this functionality do not upgrade (you should also add a Jira to Grails core requesting custom suite functionality from test-app!).

The create-webtest script now re-uses the generation code that comes with Grails and as such supports packages properly but does not generate as much sample code as before (it's basically just a test skeleton). The old method of attempting to generate a basic test for the given domain was not reliable and providing little benefit (imo).

A list of fixed issues is here: http://jira.codehaus.org/browse/GRAILSPLUGINS/fixforversion/16068

Lee Butts's picture

Grails Amazon S3 0.7.4 Released

A new version of the S3 plugin is now available. This was primarily a Hibernate mapping update to improve performance after excessive querying was noticed in a client application using the old version. As such, there are some database schema changes to required when you upgrade your application.

Release Notes

  • Versioning has been removed from S3Asset, as such you should drop the version column from the s3asset table
  • Versoning was added to the S3Asset options collection. You will need to add a version column (bigint) with a default of zero to s3asset_options
  • A foreign key on the options column and index on options_idx have been added to the s3asset_options table. This should increase performance for applications with a large number of assets.
    You may need to remove old rows from s3asset_options that do not reference a valid S3Asset due to the previous mapping not properly cascading deletes in some cases
  • Hibernate second level caching is now enabled for S3Asset and it's options. If you are not using second level caching (you'll get an error if you're not), you can disable this by setting aws.disableHibernateCaching to true in Config.groovy
Lee Butts's picture

Grails WebTest Plugin 1.2.0 Released

Update: latest version is now 1.2.3 containing some installer improvements and test generation bug fixes

The latest version of the Grails WebTest plugin is now available in the main repository. It is a major update to integrate better with the grails test-app hooks and is built using Grails 1.2-M2 (it is backwards compatible with 1.1+). As such there are some manual upgrade steps required (see release notes below). On the plus side, tests will now run as part of test-app and can also access domain classes and plugin code via the groovy step provided by WebTest

There are some trade-offs between using the old run-webtest script and the new test-app support which are outlined below. Hopefully subsequent releases can move all functionality over to the test-app script. Please raise any issues in JIRA against the webtest plugin component.

Lee Butts's picture

Grails Amazon S3 Plugin 0.6.5 Released

A new version of the Amazon S3 plugin is now available.

The new release contains changes to help the plugin play nicely in a clustered environment:

  • Quartz jobs are now non-volatile and durable to stop them being deleted/recreated when a node is stopped/started
  • S3Asset now contains a hostName property (and hence a new column that you will need to add to the DB) which holds the host name of the server that created the row. This allows the plugin job to only try and upload assets where the local file exists on the server that it is running on.
Lee Butts's picture

Grails Amazon S3 Plugin 0.6.3 released

The latest release of the Amazon S3 plugin for grails is now available.

Version 0.6.3.2 provides some bug fixes as well as several improvements.

  • The S3 access/secret key pair can now be set on a per-asset basis
  • The bucket name can be set on a per-asset basis. Note that it will be prefixed with the access key used in order to avoid uniqueness errors.
  • An ACL (access control list) can be specified for passing through to S3 in order to prevent public access to your assets if required
  • Unnecessary default options are no longer created in the S3Asset.options map and they are eager loaded to avoid flushing errors and extra queries
  • The plugin is now built with Grails 1.1.1 and the Quartz 0.4.1 plugin

The full documentation for the plugin can be found here.

Lee Butts's picture

Grails Amazon S3 Plugin 0.6 Released

Version 0.6 of the Grails Amazon S3 plugin has been released. This version adds further configuration options to the plugin as well as making better use of jets3t's multi threaded API methods to improve upload/delete performance (the number of concurrent threads is controlled by jets3t configuration - see http://jets3t.s3.amazonaws.com/index.html for details).

See http://grails.org/plugin/amazon-s3 for the latest documentation.

Lee Butts's picture

Grails Amazon S3 Plugin 0.5 Released

The latest version of the Amazon S3 plugin has been released which incorporates the latest jets3t snapshot library (0.7.1-SNAPSHOT) which has improved compatibility with the Eucalyptus open source EC2/S3 clone and some bug fixes.

The plugin S3 event handling code was also updated to avoid stale object and optimistic locking exceptions being thrown by Hibernate.

Syndicate content