November 2006

Monthly Archive

Resurrecting Amber

Posted by Edison Macabebe on 22 Nov 2006 | Tagged as: Articles

What is dead that needs to be resurrected?

There was a time when dreaming big was an idyllic pre-occupation of mine. It was also a time I recall wherein a chapter of my life is coming to a close and I knew will be a disastrously unhappy one. It will be a hard fall, I told myself then. In anticipation of the impending pain, I asked myself over and over, what needs to done or what could to I do to cushion the impact of the fall? Eureka, a serendipitous moment gave me my answer: Amber!

How could a pre-historic, rare brownish orange hardened resin provide me the mattress that can soften the fall and will not break me completely? Good question. As a matter of metaphor, Amber, if you have watched or read Crichton’s Jurassic Park is that orange crystal-like thing that encapsulated and thus preserved by accident a mosquito filled with dinosaur blood, henceforth securing the present an adulterated copy of their DNA – so the story goes. The idea is my lifesaver, you will know in a while.

Excited, I rushed on to build Amber in 2003. If you don’t mind please allow me to give you a slight detour. Kindly indulge and take time to visit http://jboxim.dev.java.net. I tried to push completing it up to Beta stage so that I could sell it to the right market (say, in Sandhill St.) in 2005, but lost steam due to lack of funds. Dragging the development slowly up to summer of 2006, a second persistent call from a friend working with a huge IT firm conveying a job offer compelled me to shelf the project for the time being. At that junction, I have completed armorex, a complementary project that will provide the Amber-like protection (cryptographic) to the core Amber object.

Now that 2006 is almost over, the same friend encourages me to give it another try even if I am now technically on a leash courtesy of the giant IT firm – a bigger vessel so to speak whose core driver is to satisfy a client by running some of their business operations. A smaller ship, however, like www.javaero.org, a non-profit NGO is more than willing to back me up by hosting the project while we all pool our expertise in a collaborative community setting. The vision is to keep this smaller ship anchored unto the bigger ship for the meantime. Making sure that we can steward the bigger ship accordingly to where it wants to head and our smaller boat will just tag along where we can freely use our skills to help increase the knowledge capital of the younger students at the marginal sector of our society and at the same time do something that the World will need (if not now, ultimately).

The Amber resurrection will require a face-lift from the ground-up. Expect a new look, functionality and coverage that is far-ranging. Talk of J2EE, J2ME, AJAX, JSF, MAVEN, Eclipse, Netbeans, SOA and AI, these are the core technologies that we will leverage in order to give Amber a new lease of life. An abtract design for the new and improved Amber will be posted here soon, so keep on staying tuned.

JAVAERO Seminar on Eclipse Plugin Dev and Performance Theory

Posted by Clint Barbosa on 19 Nov 2006 | Tagged as: NEWS

JAVAERO - The Javaero held it’s fourth seminar last November 17, 2006 featuring topics in eclipse framework and performance theory. Oliver Yanto presented to the group how to extend eclipse capabilities using the plugin development tool. On the first part of the presentation he covered on the design of eclipse, the parts of a workbench and the plugin development environment. The second part was spent on a demonstration of an actual plugin which he coded especially for this presentation.

Mr. Yanto called his plugin the ImageViewer. It has the capability to view images on the workspace by right-clicking on the filename and choosing view image.

imagemenu.PNG

The plugin will open a new window that will display the image at the center. At the top of this image is arrows that point to the left and right. Below the image is a small region which gives a preview of three images. At the center you will see the current image being viewed, the left and right images correspond to the images that will appear on the image region when you click on the right and left arrows on top.

imageviewer.PNG

The second topic of the seminar was presented by Bobby Corpus. He showed the theoretical basis of the 2/3 design rule for computer systems performance. He also showed why performance degrades when utilization approaches 100%. A table of values showed how this degradation is very non-linear. Scaling effect was also demonstrated by comparing the capacity of a given server to a twice-as-fast server. It was shown that you can load the faster server up to 3 times it’s capacity while still maintaining the same level of service provided by the slower server.

The next seminar will discuss the hard-core approach to AJAX and some useful plugins of Maven.

Performance Arithmetic 2

Posted by Bobby Corpus on 15 Nov 2006 | Tagged as: Performance

In the previous article, we learned the various performance laws that we can use to do quick and dirty calculations related to performance. In this article, we will learn how to compute the lower bound on response time. Let us start with a little known law.

Suppose you are a manager of a restaurant and you want to know how many people are dining in your restaurant during a certain time period of the day. Suppose you observe that on the average 3 people leave the restaurant every 30 minutes. Furthermore, the average time a customer spends on your restaurant is 1 hour. Let us denote this time as R. We can compute the throughput of the restaurant as

\begin{align*} X &=3/30 \\ &=0.1\end{align*}

person per minute. If the customers will remain for 1 hour (or 60 minutes) on the average, then we can expect to have 0.1 *60 = 6 customers at any time in the restaurant.
This result is very intuitive and is known as Little’s Law:

\[N = XR\]

where N is the number of concurrent transactions on the system and R is the response time.

Example 1: A financial institution has a server that computes the financial indicators for the day for all stocks in a certain stock exchange. Suppose there is 5 jobs are always running for this task. If a job is finished for a company, another job is launched to compute the indicators for another company. In other words, there are always 5 jobs doing this task at any given time. If each computation takes about 15 minutes to complete, how may stocks can be processed in a day?

Using little’s law:

\begin{align*}N &= X_0 * R \\ X0 &= \frac{N}{R}\\ &= \frac{5}{15 * 60}\\ &= 0.0055\end{align*}

jobs/s

In one day, only \[0.055\times 24\times 3600 = 480\] stocks can be computed.

In a call center there are 50 operators that each receive a query from a customer. There is a backend database that supports the query of the operator. Let us call the duration of time where the operator receives a call and composes a query to the database as the think time \[Z\]. The time that elapses from the time the operator presses the submit button to the time it receives the response from the database as the response time \[R\]. We can view the operators as alternating between two states namely “thinking” and “waiting” for response. Let \[\bar M\] be the average number of operators in “thinking” state and \[\bar N\] be the average number of operators “waiting” for response. Then since an operator can either be “thinking” or “waiting”, we have \[\bar M + \bar N = M\], where M is the number of operators.

Applying little’s law to the operators in “thinking” state, wehave:

\[\bar M = X_0 Z \]
and
\[\bar N = X_0 R\]

Adding the two equations we get:

\begin{align*}\bar M + \bar N &= M \\ & = X_0 Z + X_0 R\\ &=X_0 (Z+R)\end{align}
Solving for R we get

\[R=\frac{M}{X0} - Z\]

This is known as the interactive response time Law.

Example 2: Suppose we were to design a system in which the response time is not to exceed 2 secs and we have 50 operators. If the average think time is 5 minutes, what is the throughput of the system?

From the interactive response law we have:
\begin{align*}X_0 &= \frac{M}{z+R}\\ &=\frac{50}{5*60 + 2} \\ &=0.1655\end{align*}

transactions/s
or 0.1655 * 24 * 3600 = 14304.64 transactions per day.
We now come to an important consequence of thelittle’s law, that of estimating the lower bound of
the response time of a system.

From Little’s Law, the response time is give by

\begin{align*}N &=X_0 R \\ R &= \frac{N}{X_0}\end{align*}

The lower bound for R occurs when the throughput is maximum, or when

\[R >= \frac{N}{1/\text{max}\{D_i\}} = N \times \text{max}\{D_i\}\]

Example 3: A webserver serves images and other static files in disk1 with a service time of 15msecs and its dynamic content is put it disk2 which is faster with a service time of 5msecs. On a peak period of 3 hours, there is an average of 50 concurrent users and the CPU utilization is observed to be 35%. A transaction visits disk1 3 times on the average and disk2 2 times. The webserver completes 50000 transactions in 3 hours. Compute the lower bound of the response time of this system.
\begin{align*}D_\text{disk1} &= S_\text{disk1} V_\text{disk1}\\ &= 0.015 \times 3 \\ &=0.045\end{align*}
\begin{align*}D_\text{disk2} &= S_\text{disk2} V_\text{disk2} \\ &= 0.005 \times 2 \\ &=0.01\end{align*}

\begin{align*}D_\text{cpu} &= \frac{U_\text{cpu}}{X_0} \\ & = \frac{0.35}{50000/(3*3600)}\\ & =0.0756\end{align*}

Since the CPU has the greater service demand,it is the system bottleneck. The maximum throughput this system can attain is 1/0.0756 = 13.22 transactions per second and the response time this throughput is 50 * 0.0756 = 3.78 seconds.

Performance Arithmetic

Posted by Bobby Corpus on 09 Nov 2006 | Tagged as: Performance

When analyzing performance issues in computer systems, it is always a good thing to have a feel for the overall picture and be able to make back-of-the-envelope calculations. In this article, we are going to familiarize ourselves with the various performance metrics and how they relate to one another. We then apply these concepts to be able to compute the maximum throughput and minimum response time of a given system.
Performance can be viewed from different perspectives. For a manager, the most important metric is the throughput. How many transactions can be completed in an hour. The greater the throughput, the more money for the business. On the other hand, for a customer, the most important metric is the response time. How fast can I get the response? Do i have to wait forever to get the next page?

Throughput is defined as the number of completed transactions per unit of time. This unit of time is usually in “seconds”. For a website, throughput can be the number of requests in a day. If a site can complete one million transactions per day, then the thoughput is 1,000,000/(24*3600), since there are 24 hours in a day and 3600 seconds in an hour. We denote throughput by X and define it as:

X_i = C_i/T

where C_i is the number of completed transactions of resource i and T is the observation time.

A system can be composed of more than one resource connected with one another. The overall system throughput is denoted by X_0 and defined similarly as above:

X_0 = \frac{C_0}{T}

where C_0 is the number of transactions completed by the system.

Throughput depends on how fast a resource can complete a transaction. The time it takes for a server to complete a transaction is called the service time S_i. If a CPU takes on the average 30 msecs to complete a computation, then the service time for that type of transaction is 30 msecs.

In a typical 8 hour day, an employee does not really consume the whole 8 hours working. There are periods where the employee is idle, or is not doing useful work. The number of hours he/she is working on the average is less than 8 hours. If we denote the number of hours busy as B, then the Utilization is defined as

\begin{equation*}U=B/T\end{equation*},

where T is the total working hours. If in a one hour observation period, the CPU is utilization is 40%, then it was busy 0.40*(3600 s) = 1440 seconds and idle the rest of the time.

There is an interesting relationship between the utilization, service demand, and throughput. This is known as the Utilization Law:

U_i=X_iS_i

for a given resource i. This can be seen easily by dividing the numerator and denominator of the utilization by \[C_i\]:

\begin{align*}U_i&=\frac{B_i}{T}\\&=\frac{B_i/C_i}{T/C_i}\end{align*}

But $B_i/C_i$ is average time per transaction completed, which is precisely the service time. Therefore

\begin{align*}U_i&=\frac{S_i}{T/C_i}\\&=\frac{S_i}{1/X_i}\\&= X_iS_i\end{align*}

If a website should process 1,000,000 requests in a day, how fast should the CPU process each request in order to maintain a utilization of 15%? Using the utilization law we have,
\begin{align}S_i &=U_i/X_i\\&=15/(1000000/(24*3600)) \\ &= 0.01296\\ &= 12.96\text{msec}\end{align}

Consider a web server that is composed of a CPU and 2 disks. A typical transaction may use the CPU and both disks one or more times before completing. Let us denote the number of times a transaction visits a resource i as V_i. Then the total time a transaction spends on a resource i is V_iS_i where S_i is the service time of resource i. This is called the Service Demand D_i of resource i:

D_i = V_i S_i.

There is an interesting relationship between the number of times a transaction visits a resource i and the system throughput. If V_i is the number of times a transaction visits resource i, then

\begin{align}X_i &= V_i X_0\\ V_i &= \frac{X_i}{X_0}\\ &= \frac{C_i/T}{C_0/T}&= \frac{C_i}{C_0}\end{align}

By definition of the service demand:

\begin{align}D_i&=V_i S_i\\ &= \frac{C_i}{C_0}S_i\\ &= \frac{C_iSi/T}{C_0/T}\\&=\frac{U_i}{X_0}\end{align}

The above result is called the Service Demand Law:

D_i= \frac{U_i}{X_0}

The service demand is a very important quantity. It enables us the compute the maximum throughput of the system. Since X_0=U_i/D_i, as the utilization increase to 100%, the throughput also increases. However, when U_i=100%%, the throughput cannot be increased any further. Therefore, the throughput is bounded above by

X_0\le\frac{1}{D_i}.

Therefore, in a given system, the resource with the highest service demand limits the throughput and is therefore the bottleneck.

Let’s have an example. Suppose that the utilizations of the CPU,disk1 and disk2 are measured and given as 15%, 35% and 30% respectively. Furthermore, suppose that the current throughput is 500,000 transactions per day. Calculate the maximum throughput of this configuration.

The system throughput is X_0=500000/(24*3600)=5.79. The service demand of the CPU is

\begin{align*}D_\text{CPU} &= \frac{U_\text{CPU}}{X_0} \\ &= \frac{0.15}{5.79}\\&=0.026 \end{align*}

Similar computations for disk1 and disk2 yeild:

\begin{gather*}D_\text{disk1} = 0.06\\D_\text{disk2}=0.052\end{gather*}

Since disk1 has the highest service demand, this resource limits the throughput. The maximum throughput this configuration can attain is:

\begin{align*}X_0 &\le \frac{1}{D_\text{disk1}}\\ &= \frac{1}{0.06}\\ &= 16.67\end{align*}

In one day, the maximum number of transactions is therefore

16.67\times 24\times 3600=1,440,000

In the next article, we are going to learn the minimum response time this system will attain. It can never do faster than that minimum.

Google Windowing Toolkit for RIA

Posted by Edison Macabebe on 06 Nov 2006 | Tagged as: Articles

Rich Internet Application is a web-based thin-client with a rich-user interface that is event-driven in a paradoxically stateless container such as HTML in a web browser that can hook-up agnostically into n-tier services.  Such a challenge can only be realized through the asynchronous capability of the XMLHttpRequest javascript function also more popularly known as AJAX.  Keeping in mind that javascript is not Java per se, the Google developers provided a Java API for non-javascript programmers to effectively develop AJAX without learning its nooks-and-crannies.  This API is called the Google Windowing Toolkit.  To use it, the developer is expected only to be familiar with Swing basically, and voila, a potential to develop an RIA in the class and standards in some respects to Google mail, Yahoo mail or both their Map programs.  Any Java IDE from Sun’s Netbeans 5.5 or IBM’s Eclipse 3.2.1 may be used to develop an RIA using GWT.  However, the quickest way for a would-be AJAX programmer to using GWT would be to go to http://code.google.com/webtoolkit/gettingstarted.html.  A more sophisticated developer may also opt to using a 3rd party Netbeans module plugin that can recognize an eclipse GWT project for importation to NB.

 

During the 2nd Javaero break-in session, yours truly presented how to kickoff a “Hello World” GWT project using Eclipse.  I also showed how to extend it and demonstrated its other built-in widgets.  I will be presenting a more advanced in content GWT topic in our soon to be announced first ever roadshow this November in a University in Laguna.  We will post the details as soon as we get it finalized here in this site, so please stay tuned folks.

Next Page »