Archive for February, 2010

Feb 12 2010

Nginx Rocks at Proxying

Published by jfrank under internet, open source

I was pushing out the magnolia-railo-demo and was looking at the site performance. It was amazing by itself, sending back magnolia-railo built pages in 100ms including wire time from Portland to Dallas raw from Tomcat. On this box I have one IP though and I wanted to use a subdomain for the demo which means proxying vhosts.

When I proxied it through Apache’s httpd it took about twice as long for the page to load! (roughly 130-150ms for the base page) It seemed totally ridiculous… Now in all fairness I’m no Apache expert, but I decided to drop in nginx as a proxy on the front end and its cost as a proxy is nearly unnoticeable. I wouldn’t be able to tell it apart from hitting tomcat directly as far as speed is concerned.

I’ll have to give this a closer look for my other projects…

One slightly tricky thing is that if you need Apache’s ProxyPreserveHost in Nginx you need to use proxy_set_header Host like this:

location / {
   root   /usr/share/nginx/html;
   index  index.html index.htm;
   proxy_set_header Host $host;
   proxy_pass http://127.0.0.1:80;
}

Sometimes I wonder what it will be like when apache’s gone. I will probably find myself cding into /etc/httpd/logs and cat access_log over and over… just to remember old times.

No responses yet

Feb 11 2010

Magnolia and Railo Part 2 Redux

Published by jfrank under coldfusion, magnolia, open source

Here is the example app live from Magnolia and Railo Part 2. I fixed something in the config that was blocking import as well… so if anyone tried it let me know.

http://magnolia-railo-demo.joshuafrankamp.com/

If anyone is interested in logging in, let me know and I will give you some credentials to log in and poke around.

For some reason, this is performing crazy fast right now. On the order of 100 ms, across the country network lag included, on an extremely underpowered rackspace cloud machine (256 megs of ram, running mysql, php, httpd, ngnix and tomcat for this app).

Turn on your firebug or chrome inspector and compare it to your CMS…

I defy any other pure Railo/CFML CMS from topping that for a single uncached hit with three custom cf paragraphs…

No responses yet

Feb 08 2010

Magnolia and Railo Part 2: Templating and Paragraphs

Published by jfrank under coldfusion, magnolia, open source

This is part two in a three part series on how to make Magnolia CMS and Railo work together beautifully.

If you missed part one you’ll need to have read it and done all steps to get anything out of this.

Step One: Wipe out your repositories folder

We’re starting over with content, so at this point I am assuming you dont have anything in your website tree that is not replaceable. If you have something you want to keep, export it first. This is /repositories in the webroot by default, and is the location that magnolia has stored its derby database. Delete it.

Step Two: Get the magnolia-railo-sample files

Export some sample files and configuration with subversion.

svn export https://www.joshuafrankamp.com/svn/incubator/magnolia-railo-sample/trunk/ tempWebroot

Step Three: Merge the sample files

Copy the contents of tempWebRoot into your webroot, this will overwrite the two files we wrote last time, and add many more.

Step Four: Start up your container

Bootstrapping of the app will occur. While it does, lets go over some of the files that I have prepared for you in this sample.

  1. Adding a template renderer
    1. config.modules.templating.template-renderers.cfm.xml
    2. This is required to bind the cfm type to a backing class. We will use the JSP renderer, because it is a dispatch model that is native to Railo since it is a web app.
  2. Creating a template definition node, and backing cfm
    1. config.modules.templating.templates.sampleTemplate.xml
    2. template.cfm with some assets/ that it needs to render properly
    3. This is a specific template instance, that in a normal magnolia application would represent one of many template choices. For this example, we will create a simple template.
  3. Creating a cf include paragraph definition, dialog, and backing cfm
    1. config.modules.templating.paragraphs.cf.xml
    2. config.modules.templating.dialogs.cf.xml
    3. cfinclude.cfm
  4. Creating an example content style “Whats New” paragraph, dialog, and backing cfm
    1. config.modules.templating.paragraphs.whatsNew.xml
    2. config.modules.templating.dialogs.whatsNew.xml
    3. whatsnew.cfm
  5. Creating a page dialog, this will be an editor for page level properties
    1. config.modules.templating.dialogs.page-properties.xml
  6. Example Page
    1. website.index.xml
    2. This page uses the sampleTemplate, and pulls in the example paragraph types in paragraph instances that show them off.  It also allows access to the page properties dialog.
  7. Magnolia Tag Libraries
    1. cms-taglib.tld
    2. These are typically in the magnolia jars, but we need them out where CF can get ahold of them.

Step Five: Hit /index

Magnolia will render the node at the path /index. Since this node is configured in the magnolia administrator to use the simpleTemplate template, it will include the definition of that template to render the page. The templatePath for simpleTemplate is /template.cfm which is a traditional CFML file on disk. At this point the standard Railo request lifecycle will start, including Application.cf(c|m). Then the file will execute, with one signifigant difference. The magnolia context has been set up, and some request scope variables have already been set for easy access to magnolia state information about the page.

A few notes about parts of the example template.cfm

  • The tag libraries give simple access to magnolia controls and data structures. These allow you to render magnolia chrome inline in CFML.Example:
    <cfimport taglib="/tags/cms" prefix="cmsmod" />
    <cfimport taglib="/META-INF/cms-taglib.tld" prefix="cms" />
  • There are three ways to read information from the content repository. The tag library, request scope context objects, and instantiation of singleton magnolia api objects. They all get the information from the same underlying jcr, but with varying levels of complexity and power.Example:
    <cms:setNode var="page" />...
    <title>#page['title']#</title>

    This pulls the properties from the current content node into a Java Map (struct) whose keys and values give you access to the properties. You can also get at the same information through request['state'] which the reader could dump out and traverse to find all kinds of wonderful things in the api

  • Paragraphs are at the heart of everything in Magnolia. They are the single reason for having templates, is the content you want to put on them. By default, Magnolia dispatches the requests for paragraphs to paragraph handlers which in turn for Java technologies, dispatch them as includes through the web app container. This is the point of failure for a technology like Railo, because each request in Railo assumes that it is the beginning and end of that request. It tries to read multi part data on the inbound request, it tries to set headers and response sizes on the outbound response. That is problematic for paragraphs and a big sticking point in the integration between Railo and Magnolia, and it is also not a problem anymore!
    Fortunately, Railo includes its own custom tag concept, and it is simple to implement around the problem. Replacing container includes with calls in a reimplementation of (contrary to its name, this is the tag responsible for including paragraphs, not templates). Look for <cmsmod: includeTemplate /> custom tag calls, in a different namespace. That is the custom implementation of the <cms:includeTemplate /> that would have required going outside the current Railo request.Example:

    <div id="center">
    	<cms:contentNodeIterator contentNodeCollectionName="main">
    		<cmsmod:includeTemplate />
    	</cms:contentNodeIterator>
    	<cms:newBar contentNodeCollectionName="main" paragraph="cf,whatsNew" contentnodename="mgnlNew"/>
    	<hr />
    </div>

7 responses so far

Feb 07 2010

live blogging the superbowl

Published by jfrank under food

7:00 Etrade’s babies are creepy and not cool anymore. chunky.com is for soup.

6:48 Gold wins based on valor.

6:46 Imminent gatorade splashage

6:40 Blue leader just can’t do it! Gold holds them off right at the target!

6:38 Godaddy proves again that domains make women hot. Chickens scream again.

6:36 Blue leader is trying again. He is serious this time. Throws all the way down the green.

6:34 Announcer says “When moments are critical in a game, you go with what you do” Stupid men will even sit through a book club to get Bud Lite.

6:32 Doritos are worth killing for.

6:30 Gold took Blue leaders ball and ran it all the way down the field!!!

6:26 Green dystopia prosecutes the non green for using plastic and incandescent bulbs. Unles you own a green car! Barkley raps taco bell.

6:24 Blue leader has angry eyes!!!

6:22 Small digital squirrels love cars. Chickens scream like people, so we are supposed to want to eat them. So unappetizing.

6:20 Gold has a challenge about some kind of tricky play. They win it and for cunning get 2 points.

6:16 There is a hell emulator as a game. Bulls and horses are friends.

6:12 Gold scores again. There is much valor!

6:10 Gold ruins Blue’s day, and now they are pushing back the other way.

6:06 Emerald nuts are crazy, producing unbelievable feats of athletics.

6:02 Blue is moving down the green.

5:58 Comcast wants you to know how much HD they have, their HD is way WAY bigger than satellite’s

5:56 CBS wants you to watch the ads more

5:54 Roundup is creepy. It will kill things even after its done killing things.

5:48 A bad tape job can ruin a man.

5:44 A man sleepwalks through Africa facing dangers but eventually gets a Coke. Babies are creepy.

5:42 A man with hearing loss would trade his wife for his awesome tires.

5:40 Men are really good exercisers and they drink michelob ultra

5:38 The Blue leader is so upset that he is driving down the field for revenge! And he gets it!

5:30 Girls post pictures of themselves on the internet, and men everywhere get in trouble for looking at them.

5:28 Gold ones score a quick win.

5:23 Gold ones did some tricky move on the kick off. They got their own ball.

5:22 JayZ wins the superbowl… ? At least he has the trophy, and he runs this town. Good luck with that one. It is a full on brawl on the field.

5:20 Ford vehicles are literally made of water, and are self assembling.

5:16 Gold has 6 and Blue has 10. tv.com wants to be hulu. Toyota is now safe and trusts you.

5:15 Lots of new tv shows. “From the guy who brought you all those boring CSI knockoffs”.

5:02 The half time band is a bunch of old guys, who are reminding the world about an archaic game called pinball! A more timely message could not be found for the United States. But it turns out it is a medley.

5:00 Halftime report is awesome. Five guys with stick mics yelling incoherently at each other. It is almost as if if they had head mics they wouldn’t know what to do with their hands.

4:56 30 minutes of play, in merely two hours!

4:52 Fred Meyer’s has the single worst commercials… ever. (Billboards too)

4:49 Robots can’t handle derisive opinions. Intel has robot employees.

4:47 Women eviscerate men, and remove their spine. But if men have a portable tv, they regain their spine.

4:46 Harry Freaking Potter is a real place.

4:42 Little people commercials back to back. Little people 2010!

4:38 They are putting one of those crime dramas in space. CIS Moon will be next.

4:36 Men have a terrible life because of the things they put up with and do for their women. But they use it to negotiate with their spouses to buy an expensive car.

4:32 Gold does a good job getting down the green.

4:26 Women have good ideas, but men find the beer and everyone loves them better because they are easy going. If you succeed at being a man you can use some dove specialty soaps.

4:23 Back to back pantsless commercials. Pants are out in 2010!

4:22 A dude has a message for women. He thinks they are important if they watch football. And wants them to know their heart attacks are different.

4:18 Nothing rallies a town like beer. People will form a human bridge to get the truck through!

4:14 Gold makes some serious forward motion with much valor. Perhaps points are in order?

4:09 A good bachelor party requires an endangered species (in this case a killer whale).

4:06 Bud Lite makes you sound like TPain, women get the groceries and you just have to party!

4:04 Domain names excite women!

4:03 We should be kind to mean rich people when they lose their money.

4:02 Its not looking good for gold.

3:58 Somewhere in the past the blue ones were awarded three points for cunning and valor.

3:54 The blue ones have many tricky moves.

3:50 Slapping people on the back of the head is so cool.

3:46 Boost moble scares the !!!!! out of me. Dogs hurt people.

3:44 Focus on the Family hurts women. But they are really ok!?

3:42 The oldest man ever just kicked the ball.  Snickers hurts old people.

3:38 The blue ones seem pretty good at throwing, while the gold ones scurry about.

3:34 The gold ones had the ball, but now the blue ones have it.

3:31 Broadcast is also in Spanish.

3:29 The Hundai Sonata is less than 20k. You can quote them on that.

3:36 Modern NBA players don’t know who Larry Bird is.

3:34 Wife says snarky comments should go to the Internet not her. Rogain is gross.

3:21 PST Lots of sound problems so far. Queen Latifa had to take out her ear monitor. The intro videos for each team had a lot of mumbling.

One response so far