A few Grails tricks I picked up

I’ve written yet another app on Grails called PatriotRoom.com. It took about six weeks of nights and weekends of work, but it turned out pretty nice. In a nutshell it is a blogging platform of sorts with a few extras and a few common items like recent comments, top commenters, related articles, tagging, etc.

JMX

After I got it all running and the domain name switched over, I started to look for ways to tune it a little bit without going too overboard. Being a fan of JMX, my first step was to see what was available via the jconsole. It turns out there are all kinds of things from hibernate, but none of them are enabled by default.

I searched and couldn’t find anything on the Grails site about it, so it took quite a bit of digging to find it and eventually I found it on the hibernate site. So in your DataSource.groovy file in the hibernate section, just add

generate_statistics=true

and you are good to go.

The nice thing about hibernate’s stats is they provide all kinds of good stuff, but I was mostly interested in the caching side of it.

Caching

After enabling the stats I could see that the cache hits were pretty damn small, as in non-existent. Hmm… I enabled caching using the cache.use_second_level_cache=true setting as advised in the Grails documentation. Nothing.

A few hours of searching later I found a post in Nabble that said the caching is only enabled by default for Domain.get() operations. Well that sucks! That should have been in the docs! For me those kinds of calls are extremely rare. Matter of fact, a good 99% of all my queries are of the Domain.withCriteria variety. Well, sprinkle in a cacheable( true ) call in each of those withCriteria closures and presto I was getting cache hits stats.

What surprised me the most was the number of cache hits I was getting. The site averages about 3000 visitors a day at the moment, and in one 24 hour period I got over 2 million cache hits. That is a lot of saved DB traffic! As I write this, in 2 hours and 8 minutes since the last restart, there have been 1,013 visitors, with 396,917 2nd level cache hits with 86 misses and 55,050 query cache hits with 7,390 misses. That is phenomenal.

The majority of these hits are from articles and comments and thus can afford to be cached. However if the docs had been more clear on this I would have saved a ton of time. Oh well.

User Stats

The visitor stats I got by looking at the sessions from tomcat. That information is available via JMX as well and I covered it more in my Using Groovy to Monitoring via JMX post.

Don’t forget SQL

While the api that grails provides via GORM is pretty nice and I do like it, let’s face it, sometimes SQL is just better for the task at hand. In my case I have a dashboard that shows various statics, like the cache stuff mentioned above, but it also does some basic report-type queries.

At first I attempted these by using criteria calls and manipulating the data as needed. It worked. It was horribly slow. One “query” took about 15 seconds on each call. Just not acceptable. Thankfully Groovy has a nice little SQL api built in and I took advantage of that. I wrote my sql, threw it into a sql.eachRow call and it executes in milliseconds now like it should.

I have about four of these queries, so it was a huge improvement. As for caching, it isn’t important in this case as there are only four people that have access to the dashboard, but speed was important.

Overall the site is running pretty smoothly in it’s first week and half of operation. A few little things here and there are expected of course and we have some plans or expansion. In future posts I’ll elaborate on more things I’ve picked up in working with Grails and Groovy in general.



Don’t miss anything, subscribe!
5 Total TweetBacks: (Tweet this post)
  • en: @juliemorganizer What about shedding people or relationships? Or maybe a better way to say it is shedding others' expectations and dramas? 07/14/09 10:22pm
  • en: Wondering if it makes sense to buy the hit list, or if I should start looking towards Google Tasks. 07/14/09 10:22pm
  • en: Facebook chatting with my son...is this weird or what? 07/14/09 10:22pm
  • en: @LuckyGirl75 How do you like your taco's. Ground or shredded, beef, chicken, or turkey? 07/14/09 10:22pm
  • en: @markhoban hey mark! things are good. Was I in the cruiser or my personal veh? The mall is on my patrol route. how have u been? 07/14/09 10:22pm

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

Comments

Great article

i was wondering about caching, where did you find the nabble post discussing this? could you post the link?

If i use Domain.findAll…. will this be cached?

thanks

c

I don’t have the link handy, however a quick look in Jira shows that you can do this:

Domain.findByXYZ(“param”, [cache:true] )

I found that here: http://jira.codehaus.org/browse/GRAILS-2899

Nice job Bull.

Thanks.

ah, you found my other blog Bill :)

Nice tricks.

Just want to add up.

Add in ?showSource=true (or &showSource=true) in URL Allows developers to view the intermediade generated gsp source code

eg. http://localhost:8080/App1/book/create?showSource=true

* This feature only works when executing Grails within the “development” environment.

[...] well, and unless I’m missing something the cache should survive application restarts. Giving the amount of cache hits the application gets this would be a big [...]

Aw, this was a very nice post. In idea I wish to put in writing like this moreover E taking time and actual effort to make a very good article but what can I say I procrastinate alot and certainly not seem to get one thing done. http://www.airmaxesvip.com

Definitely those are interesting trick that you posted here.

I recently browse your article and have been reading along. fake oakley sunglasses replica oakley sunglasses I want to express my admiration of your writing skill . oakley sunglasses I would like to read some new posts and to share my points with you.

I found so many interesting stuff in your posts especially its discussion. ray bans on sale From so many comments discount watches on your articles, I think I am not the only one having all the enjoyment here! ray bans on sale keep up the good work.

that is what will happen each and every time I consider that and wished to say that I have really liked reading your site posts.
http://www.hotcheapoakleysunglasses.com

Thanks a bunch for sharing this with all of us you actually know what you are talking about! Bookmarked. Please also visit my website =). We could have a link exchange contract between us!

After the servant gave the note to the rich man, he pretended to be reading it and after a while, he said, OK, I know. Go and tell your master, I’ll go myself shortly.

This information is useful to us.That is very kind of you to write this share for us, thanks a lot.

I am not much into reading, but somehow I got to read nice information on your site. Simple to understand and helpful. We will look forward for your future updates.Thanks!

What kind of mood to see the article.
http://www.Fake-replicaoakleys.org

Every woman no amount what age she is needs to accept a abundant handbag. There are so abounding altered styles, colors, and name brands to accept from. It is harder to adjudge what is traveling to be the best one to fit all of your circadian active needs. Sometimes a woman will acquisition that if she purchases a handbag, afterwards a while, she no best brand the way that it looks. You can abstain this by accepting a Gucci Bags and you will never wish to change your look.

Getting a gucci hangbags for any woman’s apparel would be a abundant advance and would accomplish her feel acceptable about the way that she looks. It would not amount if she was traveling to a adorned dinner, plan or just blind out in the mall, gucci-purses would accord her the aplomb and the cocky admire that she needs to accomplish a abiding consequence on the world.

So,if you like it,please link cheap handbags to chose what you want right now

Hi, thank you for sharing this great info. Was just browsing through the net in my office and happened upon your blog. It is really very well written and quit comprehensive in explaining with a very simple language.Louis Vuitton Briefcase

Thanks for the introduction! I am always reading your blog and i like the way you blogged about this topic which is of course very interesting.
http://www.monclervestefr.com/

Great post and very useful code! The info is very open and very clear explanation of issues. Nice! If there is an interest I have too much information that I can share with you.
http://www.chaussureairmaxtnfr.com/

The blog article very surprised to me! Your writing is good. In this I learned a lot! Thank you!

Great blog.Thanks for you published great article. LZW0831

Good article! Thank you so much for sharing this post.Your views truly open my mind.

Straighteners are obtainable in line with the method of hair so buyer could possibly get the silky and straighter hair having an ease wedding ideas. Lots of people just aim to invest in GHD straighteners which will ultimately harm the hair for that reason they need to consider ahead of spending their on purchasing a cheap straightener. pandora jewelry

stressed that the United States is now more concerned about is the military’s portable air defense system Libya.Libya opposition spokesman Tim samak Mahmud Shamam) (August 25, says, the state transition commission opposition leaders have half on the 25 th arrived in tripoli, Libya began to back Mr Qaddafi’s age transition.In an interview with Tim samak AFP said: the government has arrived in here, half today we have and military leaders met.He also said, “samak at least eight members have already arrived in tripoli,peuterey outlet including health, communication, internal affairs, judicial and defense departments all major position here.

Very happy to see your article, I very much to like and agree with your point of view. Thank you for sharing.

You have given us some interesting points . This is a wonderful article and surely worth reading.Excellent point here. I wish there are more and more articles like that. Bright idea, hope there can be more useful articles . This article is definitely eye-opening and inspiring. I appreciate your bright ideas in this monster energy hat article. Great work!

A is everywhere! e.g. Open dictionary, it’s the first letter.canada goose jackets cheap

E-mail, questo si dice che il Pakistan come una roccaforte dell’organizzazione terroristica ovimento della Jihad islamica in Bangladesh (Harkat-ul-Jihad al Islami) ha rivendicato la responsabilità per gli attentati di terribile. Attualmente, secondo le testimonianze, sono raffiguranti il ritratto di due sospetti.Funzionari di sicurezza indiane dicono di aver bisogno di prendere sul serio i messaggi inviati da un’organizzazione terroristica.spaccio peuterey E ‘stato riferito che l’organizzazione richiede per posta dieci anni fa di non partecipare attacco al Parlamento indiano, un uomo impiccato.Secondo il Ministero dei funzionari interni, la potenza dell’esplosione della bomba è una alta intensità, e ha lasciato un cratere sulla scena.

worn by a lot of players. Another aspect of underwear are cricket briefs and trunks – these have to

for extra comfort and hygiene purposes. Trunks have the same purpose, except they fit down the legs as well.

A NFL fans, may need to many a NFL jersey, where there are of good quality and cheap NFL jersey

Wholesale Football Jerseys
cheap Football Jerseys

Wang Mu-sheng 16 years old, had tried to borrow money to make money for the journey to the belstaff online village where, like out of this village, nook, to make a living in big cities.
However, the fact that he is just fantastic, because the village there are fundamentally no money to be borrowed.
Perhaps, if his parents still,belstaff then perhaps something can scrape together money for the journey to find ways to Pinlelaoming to him, let him out of this nook village to big cities in the popular hot drink.

What surprised me the most was the number of cache hits I was getting. The site averages about 3000 visitors a day at the moment, and in one 24 hour period I got over 2 million cache hits. That is a lot of saved DB traffic! As I write this, in 2 hours and 8 minutes since the last restart, there have been 1,013 visitors, with 396,917 2nd level cache hits with 86 misses and 55,050 query cache hits with 7,390 misses. That is phenomenal.

for extra comfort and hygiene purposes.

What kind of mood to see the article.

The perfect place for adult personal who want be in voyeur in this related site. You can get more information about voyeur from this site…..

Jinhan song books in the school volunteer family relations, especially issues a grandfather is president of the column filled with gold.” The report also said that in the last six years, Song has been in Macao Jinhan school, contact with students of different backgrounds,Moncler Online but each summer he would return to Korea, contact the community of a small town locale.An Site in southern Denmark, the old civil defense camp 8 am explosion occurred has resulted in two police deaths.Danish at 18: 00 local time to confirm, at least two people Were Killed in the explosion, the scene May find more dead. Police near the scene of the explosion has evacuated residents of the region, the cause of the accident is under investigation.Danish TV2 News Channel’s television show, most of the barracks buildings razed to the ground Have Been, the explosion scene is a mess, filled with smoke, large concrete slab was thrown around.Moncler Doudounes Dan News Agency quoted an eyewitness as the Remaining Saying Were shattered barracks building windows, a car is out of the garage to Powerful explosive, thrown to the ambulance workers are still ground.Firefighters and on-site rescue. Denmark disaster relief center warned the explosion of smoke That May Be toxic, it is recommended That area residents stay at home, close all doors and Windows.The local reporters said the explosion in the barracks put Could Be Caused by Fireworks of memory ignited by accident

Well said. I never thought I would cheap oakley sunglass agree with this opinion, but I’m starting to view things from a different view. cheap oakleys I have to research more on this as it seems very interesting. One thing I don’t cheap oakley sunglass understand though is how everything is related cheap oakleys together.

French warplanes and a US Predator drone on Thursday morning attacked a giant convoy of more than 100 four-wheel drive vehicles fleeing west out of Muammar Qaddafi’s hometown of Sirte.

le due parti hanno anche aumentare significativamente le dimensioni di swap in valuta tra i due paesi, Giappone e Corea del Sud di libero scambio accordo il più presto possibile per riprendere i negoziati, intensificare gli scambi culturali e di personale e in altre aree dei giovani di raggiungere un consenso. Le due parti hanno anche concordato di continuare a rafforzare la stretta collaborazione sul nucleare della RPDC issue.In parla della giornata, Yoshihiko Noda anche tornare a Lee Myung-bak ha fatto?? Fuori dominio coloniale giapponese dei rituali coreano reale e altri rari books.Yoshihiko Noda è arrivato in Corea del Sud il 18 di due giorni visit.US Segretario di Stato Hillary Clinton, il 18 ottobre una visita a sorpresa nella capitale libica Tripoli.

Because the pattern design with series bag with cloth to make a regularity, and each bag is in accordance with the work piece at the time of the production process and a match, and at first glance it each bag similar to the design and color, but scrutiny under just will find that each bag bag has its unique arrangement!

“This is the first object of this kind we have ever seen,” said Stephane Erard of the Paris Observatory. “For virtually the first time, we have found a witness to the formation of the planets.”

Your website is so much nice i would like to see all the posts but i have dont enough time to do it. Over all i loved your all the articles

Hi, the article is so wonderful, I am interested in it. I will pay attention to your articles.

Thank you for your articles!

Sky from a ship.Field from the hills.
Your memory is made of light,of smoke,of a still pond!
Beyond your eyes,farther on,the evenings were blazing.
Dry autumn leaves revolved in your soul.

Quite good points!Thanks for your share!~~~

“Mme?” He started back. “I know naught of it.” as he moved she saw something else. She leaned forward,to the empty at his girdle. “Where is your, my lord?” she asked him sharply. “My dagger? Ha! How should I know?”

“Ah!” She looked at with cold repugnance. “What have you done with Davie?” He shrugged, yet his eyes quailed before her own.”He’ll be out yonder,” he, grimly evasive; and he took the wine one of his followers him. “Go see,” she bade the Countess.

Its Pleasure to understand your blog.The above articles is pretty north face jackets on sale extraordinary, and I really enjoyed reading your blog and points that you expressed. I really like cheap oakleys to appear back over a typical basis,post a lot more within the topic.Thanks for sharing. Strange this post is totaly cheap oakley sunglasses unrelated to what I was searching google for, but it was listed on the first page. I guess your doing something right if Google likes you enough to put you on the cheap true religion jeans first page of a non related search. You certainly have some agreeable opinions and views. Your blog provides a fresh look at the subject. keep writing!!!

Our political leaders have made a mess of a most basic municipal service and left commuters despaired about the prospects of early relief.

I think the author’s writing is very good, although the point of view a little bit different, but really is a good article, and the author can hope to have time to discuss some problems.

This is a very good idea! Just want to say thank you for the information, you have to share. Just continue to write such a position. I will be your faithful reader. Thank you again.

Ukraine, a large number of visitors to a temporary shelter set up by the Government. Longchamp Bags According to figures released by the emergency departments, the cold death of 101 persons, most of the victims froze to death on the streets, some people were taken to hospital due to hypothermia died.Polish parts of the temperature dropped to minus 32 degrees Celsius on the 2nd. Police said that as of the 2nd,Longchamp Outlet cold death toll has risen to 29 people.Romanian Ministry of Health said eight people, plus the night before freezing to death, cold death a total of 22 people. Some areas the school has not yet reopened.Bulgaria, at least 10 people died of cold. Local media reports, automated teller machines to stop the service,Longchamp Sale the public money in the capital, Sofia also been frozen. The cold also resulted in the Danube part of the river ice. For the protection of vessels, the Bulgarian authorities had to transfer some of the ship to the other ports.Latvia only Riga, the capital surrounding there are 10 people were killed in other regions the number of deaths has yet to be statistical.Lithuania, a 55-year-old homeless become the country’s nine victims.Longchamp Le Pliage Italian meteorological agency said that the Italian experience the coldest weather in 27 years, a baby, a 76-year-old and a tramp died because of cold. Northern Italy and central, low temperatures and heavy snow caused a wide range of traffic chaos, hundreds of people trapped in the middle of stopping the train and had to spend the night inside.Estonia due to temperatures as low as minus 30 degrees Celsius, three national ski tournament was postponed.Serbia can not find shops in the capital, Belgrade, only shelters, some homeless people choose to escape the cold in no rail or tram. In neighboring countries in eastern Bosnia,Longchamp Online the transport of many small villages have been cut off, forcing the authorities to send helicopters to drop food and supplies to the villagers.France’s 101 provinces, 41 provinces announced to enter a state of alert due to snow or cold. In the capital city of Paris, the military has about 600 military buildings vacated for the homeless shelter cold.

I have never read such a wonderful article and I am coming back tomorrow to continue reading. I really like this website , and hope you will write more ,thanks a lot for your information. cheap oakleys You have a great web site here. If you would like you can see my web site. Hey Every one how are you doinging. cheap oakley sunglasses hope you are haveing a wonderful day? Excellent, but it would be better if in future you North face outlet can share more about this subject. Keep posting.

What surprised me the most was the number of cache hits I was getting. The site averages about 3000 visitors a day at the moment, and in one 24 hour period I got over 2 million cache hits. That is a lot of saved DB traffic! As I write this, in 2 hours and 8 minutes since the last restart, there have been 1,013 visitors, with 396,917 2nd level cache hits with 86 misses and 55,050 query cache hits with 7,390 misses.

cheap oakley sunglasses outlet online.oakley sunglasses are sold in the market for all age groups and come in a whole range of colors, styles and designs. No matter what kind of individual you are, there are always sunglasses that is designed for you.oakley sunglasses outlet are definitely a class of their own which has turn out to be a fashion craze and have found their way into some famous Hollywood movies. oakley sunglasses sale are available as very light weight models and resist to many impact like flying stones, etc. They are pricier than no name brands, that is for sure, but they are so much more worth the money! If you are searching for oakley sunglasses discount,you’ll then surely find there are far too many discount oakley sunglasses,our online store 100% Quality Guarantee,Low Price,Fast Shipping & No Sales Tax,Fast Service,Safe Transaction,Good Reputation! oakley sunglasses cheap are your best choice.

Welcome to monster energy hats store
online site,my dear friends!As a sports brand, Frogskins fashionable sport caps dominated international position in addition to streamline beautiful appearance outside.It could take away the interference cheap monster energy hats of outside light, so that oakley sunglasses you might have clear vision of nature. Its main products include skiing kerchief mask, cross-country motorcycle, golf series, kerchief mask recreational series and special series 5 types, in addition and BuMao, sweaters, handbag and peripheral products.
Our company is cheap new era hats manufacturer & supplier online,we have been
at work on sunglasses for 9 years.Here u can get the cheapest price and the high quality hats in our company sites,waiting for u visiting.In summer season, the hats Sun shades Outlet is a reasonable option for your out-of-doors activities.welcome to buy the
new era hatsin our company.our company let you enjoy your life withour paying high prices,and our daily necessities have been sold all over the world for many years and influenced by the customers’ approval. If you want to buy or import daily necessities,our products can be your best choice.. cheap red bull hats

It lives upon their nectar, and dwells only in the climates where they perennially bloom.

Sorry, the comment form is closed at this time.