Introduction

Before you bring your application to a live (or even test) environment there are a number of different things you should check. Based on our experience with jZeno in production environments we've compiled a checklist that is hopefully useful to you.


Database indexing

I know... this is obvious - but you don't want to know how many people will forget about this in the midst of a go-live frenzy ! Specifically you want to have at least indexing on the foreign keys of one-to-many and many-to-many relationships, as well as on frequently used search criteria.


Batch fetching

The application model we promote often results in side-objects being swizzled from the database before returning from a business facade to the presentation layer. To make your database access more efficient you should enable batch-fetching on most of your domain model classes (unless you have a good reason not to). It is very important to realize that you should specify something like batch-size="50" on the class tag in you hbm.xml files, as well as on the one-to-many and many-to-many relationships (that's on the list and set tags).


    <class
        name="package.Booking"
        table="capacity.dbo.Booking"
        mutable="true"
        batch-size="50"
    >	
    
	

    
    <list/set
            name="preferredRoutings"
            lazy="true"
            cascade="all-delete-orphan"
            batch-size="50"
    >
	

This will make sure that when you do swizzle side-objects they will get loaded in a single SQL statement as much as possible. You don't want to issue a single select for each individual object. Hibernate will issue :

select * from XYZ where (id=1 or id=4 or id=8 or id=17 or ...)

when batch fetching is enabled.

When you swizzle your side objects through PersistencySupport.swizzle() (and you should), batch fetching will be optimized by doing breadth-first execution of all requested property-paths.


Hibernate caching

A lot of applications will reference a small and relatively fixed subset of it's data during a single execution period. In this type of database access it is beneficial to cache often-used objects in-memory. In order to do so you should add

<cache usage="read-write"/>

tags to your hbm.xml (in both the class tags, as well as the set/list/.. tags), and configure ehcache.xml correctly.

Objects that never change can be cached as well (<cache usage="read-only"/>). And if you have objects that change very infrequently you may want to still mark them read-only, with a time-out period that is acceptable. (if possible ofcourse).

We advise you to specify at the very least a global cache tag in ehcache.xml like this :


    <defaultCache
        maxElementsInMemory="100000"
        eternal="false"
        timeToIdleSeconds="1800"
        timeToLiveSeconds="1800"
        overflowToDisk="false"
    />
	

This allows up to 100000 domain objects to be cached by hibernate, and each object will stay in the cache for a maximum of 30 minutes. Obviously you can gain better perfomance by configuring ehcache more fine-grain, as described on the ehcache site.


Object Precreation

As described in the how-to on object creation, jZeno can largely take object creation away from the interactive request thread (which handles a web request from a user). If you take advantage of this, don't forget to activate this in your production/test environment (configuration.properties) :


	use.precreation=true
	

Winstone

The included servlet engine (winstone) that comes with the download is only intended for development/evaluation purposes. You should deploy to a servlet engine that is supported by your organisation. In most cases this simply requires you to copy your application folder to the deploy target folder of that container.

We use both Tomcat as BEA Weblogic, and we'll explain how we deploy to these 2 below :


Some More Tips