Archive

Author Archive

Stress Testing the application!

April 13th, 2010

Yesterday I needed to quickly test one of web modules for performance. Easiest way was to do some stress testing, simulate real world environment (100 users hitting url at the same time) and then checking the service response time. It looked simple, I just needed a stress-testing tool, which could take url of my webpage and return me the performance data. But it turned out much more complex than that.

First shock came when I came to know that not many professionals are doing stress testing for their applications. I checked with some of my friends and got the same answer that they were not doing stress testing. How could I blame others when I did stress testing for one of my applications like 4 years ago.

Anyway, I knew that I would have to figure out things from scratch. I was told about Apache Benchmark (ab).  That looked promising to start with and I was able to get some performance data for static sites. But I was not able to look at the output, that ab was bringing back from the site. I tried to figure out how to check it for some time, but it turned out to be complex process, and I wanted to get over with the testing as soon as possible as other pending work was waiting.

So I though of using some UI based tool rather then command based (that’s the disadvantage of getting used to Windows). I googled around and found Jmeter, which looked very promising, and my kind of tool (open source). Again it started off well. And this time I was able to get back the output. The Jmeter could show the output in multiple formats, including HTML. This also helped to see that the output I was getting back from website was actually an error message instead of the correct page. The tool was showing the test case as success, because the error message was actually embedded in the correct HTML page (based on some conditions, it was to be shown or hidden). Now I figured out that this was because the tool was not able to set values in session for multiple test cases. Jmeter looked promising and I was sure that there must be some place where I could set the session settings (it had a lots of settings options for cache/ cookies etc). But too many setting options could only confuse. I again spent a couple of hours on this tool before giving up.

Time was running out, and I needed a tool that could help me testing my application without much complexity. So I thought of trying trial version (14 days or some limited features) of some paid software, when I figured out webserver stress tool’s. That worked like piece of cake. All the required settings were just 3-4 screens. Setting up sessions meant just checking the check-box for cookies. Clear output files with detailed logs, Summary log, and logs for each user simulated, url logs etc made it easier to compare different performance parameters. The paid version is also cheap (less than 250$) for this.

Anyone has better ideas for load/ stress/ performance testing of the application?

kamal Java, Testing, coding

Problems are meant to be fixed.

March 7th, 2010

Sometimes things go terribly wrong. Its life, it is not meant to be perfect and smooth. When everything around you start falling into pieces, you might feel now this is the end of road, but actually it might just be a small hurdle and who knows, it might actually be a new beginning.

I remember a very beautiful incident in my life. I was working on an important project as a technical lead with a team of 4-5 developers. The day we moved the application to production; it bombed. Nothing was working. It was an important multi million dollar piece of software, which we had tested and retested multiple times before moving to production, but it refused to work on the d-day.  Obviosly clients were furious and emails started pouring from each side. As a tech lead it was my responsibility to make sure no technical issues should be there so I had a strong feeling that my career is over. My reporting manager would give me a call anytime and.. no idea what was in store for me. Anyways I tried my best to fix the problem, meanwhile I got calls and emails from client managers and directors, discussing issues, setting up meetings. But my manager never contacted me.

So the next day in morning, I went to my manager, thinking that he might actually have not read the emails. I was at his desk even before he came and waited for him. I was ready to take the responsibility of whole thing and was ready for any consequencies. So when he came, I tried explaining him the issue, but he told me that he had seen emails yesterday. So I asked him 

“So what should I do now?”

(He, matter of factly) “Go and fix it!”

Thats it. Does he not understand the problem. I might lose him business, client might now want to do business with us again. So I again tried to emphasize on the seriosness of the issue. He just  told me

“Kamal, you are handling that project and I trust you. What ever is required to be done,  you will do it. If we lose business becuase of this, I will not care as I know you tried honestly. so Go and fix it”

Wow! I was so amazed and felt very  confident after that. Afterall, if such an experienced man is telling me to fix it, there must be a solution out there. So I went back and met with all  the managers from different teams and asked for help. To my surprise, everyone was more than ready to help  me and my team. It took us 3-4 days, but we were able to fix the software. And while we finding the fix, we actually came up with many new processes to make sure others do not face similar issues in future. So at the end we were appreciated by the clients for our sincere efforts. The  project which we thought would lose us business, eventually helped us improve our relationship with clients.

One very important lesson of my life I learnt from this incident, that even if the problem you are facing is scary and you are sure that this is end of road. Think again. There must  be a way out. After all, every  problem has a solution, and who knows, what  looks like a problem, might  actually be an opportunity. So whenever such a problem comes, I just tell myself, “Go and fix it”. cos there is no other way to deal with problems.

Nayi Subah hai, Chal uth naye safar  ko chalen
zindagi udasi ke pehloo main padi achchi nahi lagti

behtar hain toofan se takra kar bikhar jaayen
kashtiyaan sahil pe khadi achchi nahi lagti

kamal General

System Design and documentation

October 27th, 2009

Found some old notes of mine on system documentation. What all documentation you will deliver to customer

1.Business Process Model (The broader picture)

2.System Process Model (How does the system work)

3.Business Concept Model (Business Rules, Requirement Documents)

4.Use Case diagrams

5.Use Case Narratives

6.Solution analysis (Analyze various solutions)

7.Application Architecture Overview (existing components, new components, users, systems and subsystems, responsibilities, files queues, databases)

8.Solution Option Comparison (Business Criteria, Technical Criteria)

9.Deployment Diagrams- Network, Systems, subsystems, application servers, database servers versions

10.Database Diagram

11.Component Architecture- Interactions, Interfaces

12.Infrastructure Architecture- JDBC driver, DB2 driver version etc

13.User Interface UI

14.Test Cases

15. Class Diagrams and Sequence Diagrams

kamal System Design and documentation

Home Coming..

October 1st, 2009

Everything was planned. I was dreaming about driving back to Delhi, my home town, from Chandigarh, while singing “Country roads! take me home. To the place I belong”. But as always is the case with my life, I had to prepone my travel date because of a family urgency. Drove at 120 kmph on Delhi - Chandigarh highway. And finally I am Delhi.

After 3 and a half years. Out of which I spend some part in Bangalore, some in U.S. and last 11-12 months in Chandigarh, I am back home (laut ke buddhoo ghar ko aaye). Things were not always as I expected, infact they never were as expected. But still.. main zindagi ka saath nibhata chala gaya…

kamal General

Spam bhejna band karo!

September 10th, 2009

Spammer bhaiyo aur behno.. please stop sending spam comments. Evertime I check my comments section, it is full of spam. ‘Get hot date’, ‘cheap Viagra’, ‘Free nude ladies’. Abey characterless aadmi samjha hai kya.. aur koi link chalta bhi nahi hai isme se..

Koi baat nahi beta.. aise aise filter lagaunga na.. ke reverse spamming ho jayegi, aur tumhare mail boxes bhar jayenge spam mail se.. and I am serious..

kamal General

Driving experience

August 25th, 2009

I did it again last Saturday.. Volunteered to take my Mother to temple in the morning, you know the early morning time, around 6, when driving in the cool wind gives you feeling that heavens can’t be different from this. And add some good soft music, and you know what life is all about.

But the feeling can be engrossing one and you can forget the actual purpose of your drive. Like after traveling for half an hour I released that I was supposed to drive to temple, which I had left like 10 Kms behind.

Not all driving experiences can be same fun, for example my drive from Delhi to Chandigarh yesterday, upto Karnal it was fun, but after that, AC of the car refused to oblige and heat outside was not making a good picture for driving. so last 100 Kms or so were pretty tiring. But again, that is more like life, not always good.

Looking forward to driving back to Delhi this weekend.

kamal driving

Object Oriented JavaScript- 4

August 12th, 2009

We have talked about Basic OO concepts, Objects and Classes, and Inheritance in JS. Today, let me look at polymorphism in JS.

Now polymorphism is a criteria which can help me create multiple method with the same name, with the program deciding at the run time, that which method to be called, based on signature of the method. The signature of methods can differ by number of arguments it takes, or type of arguments. In Js, we can not differentiate between methods based on type of arguments, because every type in JS can be treated as type ‘var’. But yes, JS supports polymorphism using different number of arguments, though indirectly.

In a way, polymorphism in JS is simpler than in OO languages. In JS you don’t even need to create multiple methods, in the same method, you can have different handlers for different number of arguments. arguments.length does the trick for you. Enough of talking, here is your example

<script language=”JavaScript”>
//trying to create a closed figure

function closedFigure()
{

this.createFigure=function()
{
var length = arguments.lengt
h;
if(length<3)
{
alert(”atleast 3 sides are required to close the figure”);
}
if(length==3)
{
alert(”you are trying to create a triangle with “+ arguments[0]+”,”+arguments[1]+”,”+arguments[2]);
}
if(length==4)
{
alert(”you are trying to create a quadrilateral with “+arguments[0]+”,”+arguments[1]+”,”+arguments[2]+”,”+arguments[3]);
}
if(length==5)
{
alert(”you are trying to create a pentagon with “+arguments[0]+”,”+arguments[1]+”,”+arguments[2]+”,”+arguments[3]+”,”+arguments[4]);
}
}

}

var figure=new closedFigure();

figure.createFigure(1,2);
figure.createFigure(1,2,3);
figure.createFigure(1,2,3,4);
figure.createFigure(1,2,3,3,5);
</script>

kamal AJAX, DOM, JavaScript

Object Oriented JavaScript -3

August 6th, 2009

In the last post I talked about how to create objects and classes in JS. The next step is to go for Inheritance.

Continuing from our previous examples, let’s say you want to create a class for rectangle

function rectangle(length, breadth)
{
this.length=length;
this.breadth=breadth;
this.area=setArea;
this.perimeter=setPerimeter;
this.test=function()
{
alert("hi! you are in test function");
}

function setArea()
{
return (this.length*this.breadth);
}

function setPerimeter ()
{
return 2*(this.length+this.breadth);
}
}

let’s save the above code in a file called rectangleScript.js

Now there is a HTML file where you want to use this JS file code. You will simply add

<script type=”text/javascript” src=”rectangleScript.js” language=”javascript”></script>

Next let’s say you want to add some properties and methods to this already existing class. The ‘prototype’ keyword of Java comes into help here.

<script type="text/javascript" src="rectangleScript.js" language="javascript"></script>
<script language="JavaScript">
rectangle.prototype.color="red";
rectangle.prototype.setColor=function(color)
{
this.color=color;
}

rectangle.prototype.isSquare=function()
{
if(this.length==this.breadth)
return true;
else
return false;
}

var rec=new rectangle(2,6);
alert("area here:"+rec.area());
alert("is it a square:"+rec.isSquare());

alert("color:"+rec.color);
rec.setColor("yellow");
alert("color:"+rec.color);

var rec1=new rectangle(3,3);
alert("area here:"+rec1.area());
alert("is it a square:"+rec1.isSquare());
alert("color:"+rec1.color);

</script>

You might still argue that we have not actually inherited a class by another class, this is just adding properties. Yes, even inheriting a class by another is possible in JS. Again prototype keyword is the magic word. Additionally, we will see how method overloading works with JS. Look at this example

<script type="text/javascript" src="rectangleScript.js" language="javascript"></script>

<script language="JavaScript">

function goldenRectangle(length, breadth, someProperty)
//rectangle with length/ breadth=1.618
{
//this.rectangle=new rectangle(length, breadth);

this.length=length;
this.breadth=breadth;
this.newProperty=someProperty;
}

goldenRectangle.prototype =new rectangle();

//Method Overloading

goldenRectangle.prototype.test=function()
{
alert("hi! you are in goldenRectangles test function");
}

var myGoldenRectangle=new goldenRectangle(10,6,1);
alert("area:"+myGoldenRectangle.area());
alert("test property:"+myGoldenRectangle.newProperty);
myGoldenRectangle.test();
</script>

kamal AJAX, DOM, JavaScript

Rakshabandhan and Future planning

August 5th, 2009

Today is the festival of Rakshabandhan (haan wahi! jab behne bhai ki kalai pe pyaar, i mean rakhi bandhti hai aur unki jeb dhili karti hain). Almost on every year this day, the words of a 7 year old kid comes back to me. Even I was 7 at that time. Yes, some things you just can’t forget (20 saal ho gaye!). So that was the age when you talk to girls only if there is no other option (hoo jee! ladki se baat kar raha tha), and Rakshabandhan was one of those days. Anyways, girls were tying Rakhi to all the boys, and this dude, my friend at that time, was hiding in a corner. I asked him “Kyu be! tu kyu nahi bandhwa raha rakhi” and the reply was “Abey! rakhi bandhwaonga to ye meri behan ho jayegi. aur agar bade ho ke inme se kisi se meri shadi ho gayi to?”

Dude! that is some serious future planning. I am pretty sure this Guy has made big in his life.

kamal General, kool stuff

Object Oriented JavaScript -2

August 4th, 2009

Continuing from my first post about this topic, where I mentioned why we need OO JS. First of all let me see what do we picture the moment we say that a language is OO. Here are some basic necessities of OO
Encapsulation: Usage of Classes and Objects
Inheritance: Extending Classes, Overloading methods
Polymorphism: Same method with different number of arguments

Now without wasting further time, lets get on with how these OO principles can be applied to JS

Creating Objects in JS

1. Using Inbuilt Object type:

var myRectangle=new Object();
myRectangle.length=2;
myRectangle.breadth=4;

myRectangle.area=function()
{
return (myRectangle.length*myRectangle.breadth);
}

alert(”area:”+myRectangle.area());

2. The JSON (JavaScript Object Notion) way
var myRectangle2={
length:2,
breadth:4,
area:function()
{
return(this.length*this.breadth);
}
};

alert(”area2:”+myRectangle2.area());

Creating Classes in JS

You might argue that so far we have only created Objects, but in an OO language we first create a class and then create object. Well, that is very much possible in JS as well.

The good news is, that in JS, functions can be treated as classes. How? Let’s check this example.

//Creating a class in JS
function rectangle(length, breadth)
{
this.length=length;
this.breadth=breadth;
this.area=setArea;
this.perimeter=setPerimeter;

this.test=function()
{
alert(”hi! you are in test function”);
}

function setArea()
{
return (this.length*this.breadth);
}

function setPerimeter ()
{
return 2*(this.length+this.breadth);
}
}

var rec=new rectangle(2,6);
var areahere=rec.area();
alert(areahere);
alert(rec.perimeter());

var rec1=new rectangle(1,1);
var areahere=rec1.area();
alert(areahere);
alert(rec1.perimeter());
rec1.test();

More on OO JS (Inheritance and Polymorphism) later

kamal AJAX, DOM, JavaScript