Random Thoughts

Raj Rajendran’s Blog

Detecting Client’s timezone in Java Web Apps

I wish I can enter it here, but keep getting errors when I try to save..

Sheesh!

May 6, 2008 Posted by Raj | Uncategorized | | No Comments Yet

Load Testing Web Applications

Last couple of days I spent on Load Testing the S2T2 application, and wanted to share my experience.

In evaluating a good load testing tool, I tried commercial products like e-Tester/e-Load, and Open source tools like JMeter, Selenium and Grinder.

Empirix e-Tester/e-Load: Too complicated, results inaccurate. (A test setup to simulate 100 users would show that a lot more than 100 sessions were created in the server)

Selenium: Great for functional testing, lacks load testing capabilities by itself

Grinder: Requires recording with Selenium, and a Python/Jython script to create load/run the test. While Python was easy to learn for the basic stuff, the level of knowledge needed to write a load testing script requires a steep learning curve.

In the end, the best choice was Apache JMeter. It is free, open-source, has great manuals, and support from user groups.

http://jakarta.apache.org/jmeter/index.html

I had tried JMeter in the past, but was it was lacking recording feature to develop a test script. Ideally, a load testing tool should be able to record the users action of logging in, performing different actions on the applications, and logging out etc. Even better would be a master script which would have sub tests with different users (with different roles) using the application. JMeter was perfect for these requirements.

An excellent tutorial to start is here:

http://jakarta.apache.org/jmeter/usermanual/jmeter_proxy_step_by_step.pdf

Now, a few gotchas on JMeter:

  • To record multiple scripts as multiple users:For each user, add a new Thread Group. (Right Click on “Test Plan”, “Add”, New Thread Group”. You can then use the proxy server to record the actions.Do the same for multiple different logins.

For the test plan, add “Listeners” (“Summary Report”, “Graph Results” etc)

You can choose the option to run Thread Groups consecutively, or all at once. I chose to run them at once.

  • If you are simulating 100 users (Threads), there is no way in JMeter to know how many threads it has created so far, while the test is executing. The top right shows how many tests are remaining but doesn’t tell how many threads have been created. You can do it programmatically in your webapp by adding a SessionListener and registering it in web.xml

import javax.servlet.http.HttpSessionEvent;

import javax.servlet.http.HttpSessionListener;

public class SessionListener implements HttpSessionListener {

private static int activeSessions = 0;

public void sessionCreated(HttpSessionEvent arg0) {

activeSessions++;

System.out.println(“NEW SESSION CREATED.”);

System.out.println(“Current # of Active Users : “ + getActiveSessions());

}

public void sessionDestroyed(HttpSessionEvent arg0) {

if(activeSessions > 0) activeSessions–;

System.out.println(“SESSION DESTROYED.”);

System.out.println(“Current # of Active Users : “ + getActiveSessions());

}

public static int getActiveSessions() {

return activeSessions;

}

}

And in web.xml

<listener>

<listener-class>com.sybase.it.class2.SessionListener</listener-class>

</listener>

Now you can see in the server log how many sessions have been created.

  • Web applications usually use cookies for session tracking. When concurrent tests are running, each for a different user, and hence a different JSESSIONID cookie, how do we make sure that this cookie is used by all the tests for the same user. The trick is to use “Cookie Manager”. After the test is recorded, the login page link would show a URL with an appended “?JESSIONID=xxxxxxx”. Because servers have no idea if the client browser has cookies enabled or not, they rely on URL rewriting to ensure Session tracking. We can take this Session ID and use Cookie Manager (Right click on Thread Group, Add -> Config Element -> Cookie Manager)

Be sure to do this for all the Thread Groups with their corresponding cookie value.

  • For JSF applications, there is another tweak needed. The JSF View State has to be passed as a request parameter in all the requests. It is a hidden input that has the name “javax.faces.ViewState” and will have a unique value for a Session. You can handle this in JMeter by RegEx Extractor. The detailed instructions on this can be found at http://wiki.apache.org/myfaces/PerformanceTestingWithJMeter
  • To monitor the hardware itself when the load test is running, there is the “top” command (/usr/global/opt/bin/top) which is really handy. The amount of memory allocated to the JVM, memory used, CPU usage etc can be obtained.
  • Another tip learnt was to keep the JVM Min Heap Size and Max Heap size the same, which would save cycles when more memory needs to be allocated to the JVM.
  • One thing that I miss in JMeter was a Response Time Vs No. Of Threads graph.

From the Graph results, we can get Average Time Vs # of Samples, but you cannot get the # of threads in that graph.

These were just scratching the surface. There is still so much that can be done with this excellent Open source tool.

May 5, 2008 Posted by Raj | JSF | , , | 2 Comments

Santosh Subramaniyam

If “Bommarillu” was dumb, this movie is DUMB. period.

Weak story line with no plot, Jayam Ravi as usual as with the nasal voice, and a shrieking Genelia. Admit it, there is no girl in real life like this one portrayed as “innocent”. The behaviour is comparable to a mentally retarded, or at best to a 6 year old. Blame Mani Rathnam who started this, with Amala’s character in Agni Natchathram, and what’s-her-name in Idhayathai Thirudaathey. The most hilarious scene is the climax, where Genelia gets to “act”.

The lesser said about the movie, the better.

May 5, 2008 Posted by Raj | Movies | | No Comments Yet

Arai Enn 305-il Kadavul

I haven’t written about any movie before. Something about this movie gripped me. Not

many movies make you think after you are done watching it. This one makes your brain

work, but only if you want it.

This is not a movie review, but alert: Spoilers ahead!

What I loved about it is not the comedy part, infact I think the jokes were weak. But

what I loved is the way the director (Simbudevan) subtly conveyed messages, and not

too many of them were oratorial lectures.

The scenes following Santhanam and Karuppu abducting the God-power, very practically

proved money cannot make anyone bring happiness. Infact it makes things worse. The

extended family of Kanja Karuppu sure evoke laughter but the significance of the

message has been unsermonizingly rendered.

The guy who needed a heart surgery, eventually dies, not because of his health, but

killed by fellow humans in a communal clash. Without any long dialogues, it was a

rivetting scene, and just the images portrayed the value of life, or lack thereof,

where we live.

Albeit a long conversation, the one between PrakashRaj and Rajesh on atheism was

another gem. Focus on the man-made social inequalities than argue if God is to be held

responsible. The Communist thinking of the director is unobscuringly palpable here.

The director very unambiguously lets the audience know he is against begging. He

emphasizes any kind of labor to make money. I tend to totally disagree with him when

he consecrates prostitution, Infact this is a major negative point of the movie and

that too in the climax. He does make amends in a different way by showing the hero

marrying her.

Superstitions is another subject matter he strokes with ease, with the character

played by God himself questioning these beliefs.

In all, I thought the movie was worth watching just for the director’s brilliance in

parading his idealogies with masterminded subtleties.

April 29, 2008 Posted by Raj | Uncategorized | | No Comments Yet

An NRI’s perspectives of Trichy

Being a born-and-brought-up in Trichy, I can proclaim myself a “thorough-bred

home-grown Tiruchian”, and have done my fair bit of been there, done that, in and

around my city of citizenship all those golden years.
Now, having spent 10+ years out of the country, figured why not share my perspectives

of Trichy as can be perceived now, and aptly named this blog entry so.

I have now been in Trichy for 3 months. In the last ten years, I have been here on

five occasions each with a three weeks span each with its own hectic schedule.

Therefore starting with a huge disclaimer: several observations may fall under a

“yeah right, so what?”, or “he didn’t knew that?” eyebrow raisers, or even a “that’s

how it is anywhere in India” smirks.

The first thing that would strike anyone visiting a hometown after such a prolonged

period would be a “wow, so much changed around here!”. Not so much for me. And that’s

not necessarily a bad thing. Trichy has preserved its identities. The vendors in

teppakulam, the buzzy Chathram Bus Stand, the solicitors at Samayapuram, the traffic

in Thillai Nagar Main Road, the prasadam at Srirangam, the cost of living

factor..nothing has changed much.
I do agree there are several noticeable changes, but I stress on the fact that Trichy

still remains the same old city, in a good way, on its rich heritage and feel. On the

cost of living part, this is still a middle-class oriented city. Agreed no one can

live on the same amount of earnings that was a decade back, factor in the income

growth and inflation, and you know what I mean. Real estate has appreciated, not so

much as the metros like Chennai and Bangalore, but still affordable for Non-NRIs. It

remains to see what the proposed IT SEZ park can do when(if) it takes off.

Ten years back, an internet browsing centre was an unknown identity. Five years back,

there was one every street. Fast forward to now, thanks to the global network

revolution and India’s own progress in the communications sector, there is one every

block, right next to hair dressers and tea-shops. The browsing cost is cheap (Rs. 8

per half-hour) and more than once I noticed school kids either playing games or

looking at porn.The ones that are not seen doing this are probably doing the same in

their own bedroom. Internet has penetrated most house-holds, what with a variety of

providers to choose from: government entities like BSNL to private guys like Airtel,

Hathway, Tata Indicom to name a few. Speaking of internet, I needed to get a high

speed broadband connection due to my work commitments. While I was initially

frustrated by the 512 kbps from Hathway (about Rs. 600 pm), I was pleasantly surpised

to learn about the 2 Mbps from Airtel (Rs. 1300 pm). I have no qualms about Hathway,

just the speed wasn’t suffice. With both, I have had about 99+ % uptime. The Customer

Service was surprisingly good and comparable if not better than the West.

Okay enough of internet. My five year old kid gave his unsolicited opinion of Trichy,

that it seems to have a lot of temples and doctors. Oh yes, Trichy has a lot of

temples we know that. From the well-knowns like Malai Kottai, Srirangam, Samayapuram,

Vayalur to much less knowns like Vekkali Amman, Panchavarneswarar temples in Woraiyur,

Naachiyaar kovil, Ayyapan Temple in Cantonement etc.you can spot a temple every

quarter kilometer no matter where you are. Trichy can aptly be called the “City of

temples”. Any time I wonder where to go out for an evening leisure trip, the mind

incongruosuly starts thinking about temples. Mind you, I have nothing against temples,

religion, or God, but after visiting so many temples in so short timeframe, there is

no way to stop thinking.. another temple, another deity, another pooja, another

prasadam. What intrigues me at temples are the architectural brilliance, and the

devotees. Different walks of people ..financially, professionally, physically,

mentally, so many different people all arriving there with elements of faith and fear

of the unknown. Rivetting, at times.
My personal favorite has been the Panchavarneswarar temple where true serenity

associated with temples can be found. The other one is Samayapuram for solely personal

reasons.

Coming to the other aspect of the 5 year old’s opinion: doctors. I am positively

convinced our people are now medically aware than the John Doe of America. Either

that, or people are now more sick than ever. Not so sure although I tend to lean

towards the awareness part rather than the sickness part. Every doctor in every cross

road and its inroad, is holding patients more than it can hold. Doctors do not want to

accept new patients as they are already working whole night. ( I am not making this

up, this is true. I did meet a doctor who works until early morning). Anytime a doctor

appears on TV taking public calls (and he could be a optician, anaesthesian or a

paediatrican doesn’t matter), the calls are flooded from the public. Self-health scare

prevails among these calls, also need to mention much love, affection and care can be

felt when questions are related to their dear ones.

For kids, and by that I include babies, toddlers, kindergarteners, pre-teenagers, and

teenagers, there is absolutely NO entertainment. Over in the US, I have observed that

in small towns where such is the case, there are malls where kids hangout as last

resorts. But over here, there is nothing, nada, zip, zilch, a big fat zero. Where can

a kid go to enjoy a slide, a swing, or just run wild on a big lawn? Comparing with

Chennai, there is a cheap and best entertainment in the form of beach. I honestly

believe that the tax amounts paid by public need to be spent to provide an oxygen

space. Trichy has a Femina Shopping Mall (FSM). But if you call it a mall, all real

malls of the world would feel insulted. Consider FSM as Big Departmental Store,

Jewellery Mart, fabric outlet, and a food court rolled into a cramped stinky cluttered

space. If you can call the Go-kart in Besant Nagar beach a “Mini Go-kart”, the one

here is a “Incredibly stupid to be called Go-kart”. No offences, just my sincere

observations.
For the rest, if you need entertainment, a surprise element is the “Cauvery bridge

under lights”, Trichy answer to Hyderabad’s Tank Bund. Mobile vendors selling masala

groundnuts mixed with mango (don’t miss this), or water-melons or chaat are not to be

missed. A walk from the bridge watching the scarce “water under the bridge” and

reminescing pasts distant and not-so-distant are not to be missed . Another evening

trip for those with kids and not minding spending exorbitant money is “Odyssey”, the

book store on Cantonement road. A few hard to get books, toys, audio and video can be

found here that can be found only in metros. On a personal note, I found that toys in

Odyssey are 10x the price of their counterparts in the US.

Another “almost” clean family fun can be movies. Only wish it were fully

family-friendly. The seats are not fully elevated from the front seats, so less taller

people (read kids) have a blocked view ending in them sitting on parents’ laps. The

snack bar is open only during the interval, or “intermission: as they put it, so no

way to get an icecream or a soda during a song break. The corridors are still

smoke-filled during any song-break. On a personal note, I was disappointed that

“Sippy” theatre has ceased to be operational. So many good memories’ ember glow there

- the admirations of hollywood super heroes like Arnold Schwarzenegger, Silvester

Stallone, Bruce Wills all grew there. Another one was to learn that the Maris theatre

complex was now screening in just two theatres. In its heydays, the lines to movies in

these theatres would well stretch to the main road. Any one in a town bus can

interpret if it was showtime end by just looking at the headcount on Salai road. I

heard the theatre has been poorly maintained hence causing this windfall.

Switching gears, Trichy has been popular internally for its own vegetarian

restaurants, with Vasantha Bhavan leading the way. But a new found “Kannappa”

restaurant is a treat for the meat-lovers. An authentic Chettinad style restaurant. my

humble food critic in myself says this is the best Indian Non-Veg restaurant in the

Universe. The Biryani is unmatched, while the pepper chicken varieties are uniquely

spicy and a treat. Easily the best place to eat when you are hungry. In the past I

have been a lover of “Banana Leaf Restaurant” but haven’t tried it now. “Pandian” in

Thillai Nagar is mediocre, but service and ambience are excellent. While on the topic

of food, it consistently amazes me how even B grade restaurants in Trichy can produce

Idlies, Chutnies and Sambars of the highest grade.

Having said all the above, I finish by saying Trichy is a city I love and want to call

it my home. There is something for everyone here.

April 27, 2008 Posted by Raj | Uncategorized | | 1 Comment

Ramesh Mahadevan

Back in 1997, I accidentally stumbled across Ramesh Mahadevan’s humorous articles and instantly became a fan. His humour and lucid writing skills have been unmatched by anyone else. Days when my mood was gloomy I would go read any of his articles (for the umpteenth time) and get cracked up and all would be normal then. I wrote to him at that time, he even replied back and said he was working on a script for a tamil movie.

Anyways, I just found today that he has a website and a new blog and that he has returned to India for good. Wow ! His post “Some Random posts on Reverse Migration” was very insightful with a tang of his characteristic humor.He has posted that he would write once every 2 weeks approximately.

Looking forward to more stuff from him !

July 24, 2007 Posted by Raj | Uncategorized | | No Comments Yet

SunRocket closes doors

This made me mad. SunRocket is officially out of business. No warnings to customers. Nothing.

Don’t they have a lawsuit waiting ? What if there was a medical emergency and I couldn’t call 911 because SunRocket just picked a day to cease to exist ?

I want my money back !!!!

:=(

July 17, 2007 Posted by Raj | Uncategorized | | No Comments Yet

TechWave 07

My submission entitled “Case-Express: Using Sybase tools and bleeding edge technologies for a feature-rich web application” on “Case-Express” has been accepted for TechWave 07, a Sybase conference that will happen in Las Vegas, Nevada from Aug 6-10.

Cool !

I am waiting for a co-speaker, and should start working on the slides soon. I am looking forward to this. This will be the first time I will be a speaker at a big conference, I have attended JavaOne for 4 years and always wanted to present a session there. I hope this will give me a good start and confidence to achieve that goal. I am not really nervous as I designed and developed the application. But who knows what happens on the D-day ?

June 22, 2007 Posted by Raj | Sybase | | No Comments Yet

Chennai expensive than Bangalore

And is expensive than the moon !

Read this article on IBN

I am pretty darn sure this is a bubble and is going to burst soon. Look what happened to the real estate bubble in US. India follows the trend in US whatever it may be , like dot com boom, bust, stock market crash, real estate bubble. The bubble should burst as it did in the US. Not that I would love for that to happen, but it does need a correction. If a Software engineer working in US for 10 years can’t afford to buy land, then I think something is wrong.

We’ll see !

June 21, 2007 Posted by Raj | India | | No Comments Yet

RichFaces

There were a couple of times RichFaces was mentioned in some JavaOne sessions on JSF, so I decided to take a quick look at it and try it out. The Online demo looked impressive, there are some really cool AJAX components like Drag n Drop, Auto Complete, Ajaxed Tabbed pane, Tree etc. Very quickly I was able to get the demo running in Sybase EAServer 6.0.1

Ofcourse, from my experience before, there are a couple of hacks to make it work in EAServer. The load-on-startup for the Faces Servlet had to be set to 0 in web.xml.

<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>

This is because, EAServer calls servlet init() before the ServletContextInitializer. Not an EAServer bug, this is in Servlet 2.3 spec.

In a few minutes, I was able to use these RichFaces components in my web app. Great job Exadel, you rock.

June 21, 2007 Posted by Raj | JSF | | 2 Comments