on May 25th, 2012Scaling Grails – a checklist for tuning your grails application

I have been using Grails for almost a year now and have fallen in love with it. If you are looking for a good rapid application development framework, and are comfortable with Java, then Grails is definitely something you should check out. Given that it has the patronage of the Spring community (now VMWare) , I can surely bet on Grails to become even better and deliver greater value to developers. If you are familiar to any of the RAD frameworks, you know they are extremely good for prototyping and turning ideas into code. They are not however things that don’t scale well instantly, primarily because they are designed with convenience in mind. This is called the convenience – functionality trade off. This is imminent irrespective of the RAD framework you are using. But there are some simple ways in which a Grails application can be tuned to perform better irrespective of your set up. I will go one step further and call this a checklist that every Grails developer must go through prior to deploying a Grails application. I take most of my points from the Tuning a Grails Application Screencast by Peter Ledbrook, which I have linked to at the bottom of my post. If you are a Grails developer, this video is a must watch. So here is the checklist:

  • GORM caching – Turn on hibernate’s second level cache which caches entity fetches. For static functions like permission/access checkers , Listing cities from the database etc this speeds up GORM operations significantly.
  •  One of the facets of GORM is to eagerly fetch related entities. Use Lazy fetches whenever possible by defining the fetch type for an association. Also, for large associations of type M:N, do not use the hasMany and belongsTo way of associating. Use a custom defined mapping instead to stop GORM from ensuring validity of the association for each DML operation. Burt Beckwith talks about it here in his Advanced GORM talk at SpringOne.
  • Query Caching : You can cache all dynamic finders and criteria queries by adding the cache:true parameter to each function. There are multiple types of caches, like read-only and read-write etc, ensure you use the right kind of cache.
  • If you need to profile your application to see what functions (user defined & Grails defined) are the ones hampering performance, use the Spring Insights module with your Tomcat or use the Insights module in STS. You can track how every request is serviced, see and debug problem areas, view everything from the call stack to the SQL query generated and profile your Grails application.
  • Use the resources plugin (now bundled into Grails 2.x.x), this automatically web optimizes your javascript and CSS files. It also allows you to defines modules that can bunch up different js/css files together for optimizing delivery times of the page render. There is a video on how to get a perfect yslow score using the resources plugin, be sure to check that out.
  • The good part about running on the JVM is that you can always fall back to Java. To increase the execution speed of a method, you can use the @Typed annotation and write static typed code to increase performance.
  • Continuing my point about benefiting from the JVM, enable page compression in Tomcat for faster page responses. Other vendors have their own Page caching and compression mechanisms, be sure to enable them.
  • Use Spring Caching (depends on ehcache) for controllers and services methods which get used very often.
  • Tune your application server’s memory settings. A simple look up will bring you hundreds of pages on how to achieve this for the container of your choice. Adding a little more heap space and memory to an app server can do wonders.

When you find the time, do watch Peter Ledbrook’s video on tuning a grails application

on Feb 8th, 2012Design improvements to car and bike headlights

There are many unlit roads and curbs in Bangalore and other places. I have had lots of near-miss accidents while turning into a dark curb or alley. The reason for this is that the headlights on a car and bike don’t light the way in the direction of your turn. Let me explain with a diagram.


Representation of car hadlights

Image courtesy bmw.com


Given above is a diagram of traditional car headlights. The red cone represents my field of vision when I am about to turn and the green cone represents what I should be seeing. When I am turning right, I need to see what’s on my right, along with what is in front.

Given that we use a steering wheel in a car and handle bars on a bike,  both motion based electromechanical systems which control indicators and speed, why not make that work for lights as well?

Well it turns out, only BMW comes with an optional feature for this, called adaptive headlights. I don’t know if it is patents that is holding back other companies from doing this, but like seatbelts, this needs to become essential for all vehicles on the road. Here are some thoughts around this:

1. It is important for a car/bike to let the person coming in front know that he/she is about to turn. We have indicators but when people drive on Dip lights, it’s hard to spot certain sleek looking indicators. One design improvment can be to automatically switch lights to the dim mode while turning or after switching on indicators. Serves two purposes: firstly, the person on the oppposite side can see the indicators, secondly, because of the DIM mode, drivers will natually slow down while taking sharp turns.

2. Another possible implication of having lights that spread to the side of turn is that you might blind the person coming on that road. The automatic dimming of the lights should stop that as well.

If any of this doesn’t make sense or if I have missed out on something, please let me know. Here is a video of the BMW adaptive lights in action. Isn’t this something that should be available by default?



on Jan 20th, 2012How to pick a domain name for your next web product – Tips

Picking an effective domain name for your web product/service/company is currently at the top of on my list of the hardest things to do for a web startup. For a web startup, domain names can make or break a business. You don’t want a name like expertsexchange (figure this out). Here is a simple checklist for picking a good name:

  • Sit with 3 people at least, preferably from different backgrounds. They will tell you what a shortlisted name signifies to them. FlagTrue, the proposed name of my company was picked by a biased set of computer science students, but we did it specifically to appeal to the computer science audience. I had a hard time explaining it to my mom.
  • Use a bulk name checker instead of trying a single one each time. It can get annoying and demotivating trying out individual names. GoDaddy has a bulk search option. Works well but it doesn’t store stuff well, make sure you have a backup.
  • Every domain name you can think of will be taken. Domain squatters  are the plague of this earth, but don’t fret. Try combination of words or clever plays on words.
  • A good domain name is one which is short (preferably under 10 characters), sticky (meaning people will not easily forget it), unique in the line of business and something that conveys what the product is about. Keep a score board of all these attributes for each domain name you pick.
  • Do not use numbers or short forms. People won’t know whether the number is written as numerals or characters. For ex: If I say level3.com on the phone, the other person might think it is levelthree.com. If you are going with the name level3 then ensure you buy levelthree also and redirect it back to the original name.
  • Same goes for names in languages other than english. When we picked the name Samparkh, we aded the trailing ‘H’ but a lot were expecting the domain to just be Sampark. These minor cultural differences can send traffic to a totally different website. A classic example of this is to spell “Agarwal”.
  • Check if there are any premium names that squatters are selling for a good deal. It might be worth investing in a good domain name if it can mean better reach. Also, it’s better if you can negotiate something before your product/service/company launches and makes some noise.
  • Try to get a .COM as most people and browsers default to it. This is not a deterrent thought; Del.icio.us with its quirky and confusing name was still a hit.
  • Once you decide on a name, disable auto transfer and buy it for 2 to 3 years.  Most popular domain provider’s mails are borderline spam and you might miss important renewal mails. It is always good to add a reminder on your calendar about 10 days before the domain expires.

These are just suggestions. This template is what has helped me and many others pick a good name for their web business. Best of luck!

on Dec 12th, 2011Robotics – Awe inspiring demonstrations

The advancement in robotics is breathtaking. Take a look at these two videos, the first one show a robot that flies like a bird.


This next video is what I have nightmares about. A humanoid robot that runs at 6 Kms per hour. Reminds me of the Terminator series.





Watch this TED talk where Robert Full explains robots that can climb walls, navigate underwater and practically tread any surface or obstacle. He also ends his talk by saying that we must conserve ecology to ensure these secrets from the biological world are not lost.


on Oct 19th, 2011Google Nexus S – My Experience

I ordered my first Android phone, the Google Nexus S about a 4 months ago. Part of my phone was paid for using the prize money I won for building our Augmented Reality Android application.

This is my first smart phone and I thought I should share my experiences around my phone.

Google Nexus S

I live in India, a country with an abundance of power outages in the name of load shedding and repair. A feature that I never thought I would use came to my rescue during these dark times. The Wifi hotspot tethering feature. With my 2G connection, on multiple occasions, I was able to connect my laptop to the internet to do some just in time work.

I also use Twitter a lot, so without question the Twitter android app has probably been my most used application. I was able to use applications like FourSquare, PicPlz etc to post pictures and to check for tips and tricks at a given location. My wife and I went to this place where I ordered a dish from a FourSquare tip and loved it.

I have also started fulltime on my own software venture. With my Android, I have been able to stay on top of all the important emails that I get. Helped me a lot when I was meeting investors and prospective customers; Blackberry wielding folk who prefer Email to texting or calls.

I cannot forget Google Maps, that has helped many a times when I was lost in the outskirts of Bangalore and Pune(A city which I knew nothing about, direction wise). I also downloaded an app to control PowerPoint slides which I used once. And thanks to that critical Rackspace app that I once used to restart a cloud server in distress. Special mention to Shazam and SoundHound that I use ever so often to identify those familiar sounding tunes I overhear.

Now with the new Ice Cream Sandwich launch, I am really excited about the reworked OS and can’t wait to get it on my phone.

Go Android!