The amazing adventures of Doug Hughes

Archive for June, 2008

CFUnited – Images with Flex and CF Files

As promised, I have attached the files form my Images with Flex and ColdFusion session at CF United. You will need to set the webroot of your app to the ‘www’ directory in order for the examples to work correctly.

One question that came up during the session was if its possible to grab an image from a media player. The files include an example of how that can be done when viewing a .flv file. I am working on getting a demo of this up and running, but I am having some issues. I will let you know when I get it working.

Download the files here

It is kind of a mixed blessing that, for me, conference season is over. It is a good thing because I won’t be gone from my family (and work) as much, it is a bad thing becasue I won’t see most people for another 10 months or so. It was a great, albiet tiring experience. I gave 6 presentations and 1 full day class, at 4 conferences, in 3 time zones, in 2 countries over a span of about 6 weeks.

Scotch on the Rocks Review and Materials

I returned yesterday from my trip abroad to Scotland. Andy Allan was kind enough to invite me to come speak at the conference. I feel very fortunate for the opportunity and believe that the conference was well worth the trip.

For those who dont know, Scotch on the Rocks is held in Edinburgh Scotland around this time each year. I cant speak for the previous conferences, but I can say that this years installation blew my socks off.

Firstly, the venue was amazing. The conference was held in the George Hotel in central Edinburgh. The hotel was in the center of everything. You could easily (and I did) walk to Edinburgh Castle, the Royal Mile, the Hollyrood Palace, various parks and monuments, pubs and more. The hotel accommodations were quite nice too!

Then there was the material of the conference. I must say that the conference is very well placed in terms of material presented. There were fairly entry level presentations, such as my two hour marathon presentation on CFCs, and obscenely advanced presentations such as Joes presentation on using Spring and Hibernate with CFML (which was all done on top of an entirely open source development stack), and more in between. I didnt see a single presentation I didnt think was fantastic.

To really make things interesting, we had Ralios announcement about joining JBoss and Adobes reaction to that. This is certainly something interesting to keep our eyes on over the next year. I do need to say that I think Gert handled this beautifully and I think that Adobes positive attitude thus far was terrific.

So, I highly recommend this conference. Even to those who might otherwise go to a conference in the states. Seriously. You may want to reevaluate where youre spending your conference dollars and give Scotch on the Rocks a serious look.

Lastly, for those who attended my sessions, you can download the complete materials for the CFC Crash Course and my Advanced Model-Glue talk.

Scotch On The Rocks CFC Materials

Scotch On The Rocks Advanced Model-Glue Materials

HA – Clustering – Replicating Session Scope

With ColdFusion Enterprise, creating clusters and replicating session variables should be as simple as doing this via the ColdFusion Administrator GUI. However I have found this to be unpredictable at times so this blog posting is a lead-in to what actually is going on, “under-the-covers”.

One of the most sought after features in clustering is finding the best way for a users session information to be replicated across a cluster. Or more succinctly, finding a way to make sure a users session information is preserved if they get moved around from instance to instance, which in pre ColdFusion MX, pre Java days was both limited and resource intensive.

Before getting into the main discussion of this blog piece, I thought it might be useful to discuss what is actually going on relating to maintaining session state and session replication, in the Java world. ColdFusion MX forward embraced the Java Servlet world, in fact JRun, which ColdFusion runs in by default, is a Java Servlet container which is fully J2EE-Java EE certified. In applications running in a J2EE-Java EE environment there are four distinct ways of storing user session information.

  • In the Data Tier – In the ColdFusion world we use the client scope for this.
  • In cookies on the users browser.
  • In the Enterprise Tier – with Enterprise JavaBeans (EJB) using stateful session beans.
  • In the Web tier using the HttpSession interface from the Servlet API

In this article we will focus on the the last item in our list above; using HttpSession from the Servlet API. When using HttpSession, the session is tied to a specific user, but shared across all servlets in a Web application. It would be theoretically possible to have a complete copy of all session information at all times on all instances in a cluster and simply then use a “round-robin” algorithm so that every user request took them to a different instance. My experience is that this is unnecessary and very costly in terms of messaging and networking. I always advocate the use of round-robin with sticky sessions. In this case the user is sent to a particular instance and remains there unless that instance fails.

The next thing to consider is what type of data can or should be stored, via the HttpSession Servlet API. We touched on client variables earlier in this article. The advantage of the client variable scope is that it is stored in a database which can be accessed from any instance in a cluster, the disadvantage is that complex data types cannot be stored directly in the client scope without serialization and de-serialization. In addition, there will be more hits against a database during a users session. We are definitely able to store complex data types at the session level.

As a users session information is stored in memory on a particular instance this data is lost if a user is moved to another instance. The first level and simplest way of dealing with this is by using what are called “sticky sessions”. When sticky sessions are used a user sticks to the instance they first go to, therefore their session information is always available whilst they remain on that instance, as it is in memory on that instance. With sticky sessions enabled (aka session affinity), users are only moved to a different instance if the instance they are on fails. So then, what can we do about users session information in that case? Enter Java J2EE-Java EE session replication, sometimes also known as the “buddy” system.

I have worked with several clients who have tried to use this in ColdFusion applications. They requested my help because they found getting “buddy” replication up and running to be complex and also sometimes unpredictable in ongoing operation. I was interested to read this comment in a library article on the IBM web site. “Some application servers support memory-based replication to “buddy” nodes, where each session exists on one primary server and one (or more) backup server. Such schemes scale better than replicating all sessions to all servers, but complicate the job of the load balancer when it needs to fail the session over to another server because it has to figure out which other server(s) has that session.” In my experience, there has not been a way to specifically notify a clustering device about the location of replicated session information in a ColdFusion – JRun peer-to-peer cluster.

In ColdFusion clustering we are in fact using the J2EE Servlet Container (typically JRun) and for those wanting more detailed information about how JRun uses httpSession, there is some good information.

As a general tip, you will find much more information about all things clustering in the JRun documentation than in the ColdFusion documentation.

Tag Cloud