Saturday, April 30, 2011

Intermittent HTTP 500 Error (Response Code)

In this blog post, I would like to write about intermittent HTTP 500 Error happening in AJAX based application. This error is not the typical internal server error thrown by the application server, which also shows as HTTP response with 500 as response code. Typical symptoms are that the request did not even reach the back-end server, bu the 500 response code is returned.

The application is an AJAX application, built using GWT in the front end and Spring in the back-end. The application was accessed using Internet Explorer in the client desktop.
The back-end infrastructure has Apache Web Server, routing the request to the Websphere application server. The application is a heavy user interactive application which make makes multiple RPC (Remote Procedure Calls) to the back-end to fetch the data . This essentially means that the application was making large number of HTTP requests to communicate with the back-end server.

The issue that we were facing was that 1% of the requests was getting a 500 response code.

We tried analyzing the reason for the 500 response code.To understand the issue, we need to know the details about the communication between the browser and the server. When the browser makes an HTTP request to the server, the browser sends the HTTP Request Header and the HTTP Request Body. The Web-server at the back-end, receives the header and body, transfers it to the back end server. In the case where the HTTP 500 status code was returned to the application, it turned out that the error was thrown by the Apache Web-server. Apache has a thread (connection) waiting for the request header and body to arrive and then forward it to the back-end server. In very rare scenarios, the header of the request arrives and the request body never arrives. Apache waits for 1 minute (timeout duration) and then responds with a 500 Error Code.

The next challenge was to find out as to why the request body was not arriving and only the request header was arriving in some specific cases.
We found that this was happening only with the Internet Explorer browser (IE6/ IE7 & IE8) and not with Firefox. After placing a network monitoring tool at the client side, we figured out that the issue was happening with IE when it was trying to retransmit the data on a new connection after the attempt to send data on the first connection fails. In the scenarios we saw, IE was trying to send request to the back-end server on an open connection (HTTP 1.1 compliant) with the back-end server. However this connection was already closed by the back-end server , after the keepalivetimeout period was reached. IE, without knowing that the connection is closed, attempted to send the data on that connection. Per design, IE should then retransmit the data on a new connection with the back-end server. In some scenarios, IE forgets to send the HTTP Body and sends only the HTTP Header. (IE Bug #). Though this IE Bug is reported only in IE6, we found that this can occur in all versions of IE including IE8.

There are multiple fixes to the problem

The first and the preferred one is the one recommended by Microsoft in the bug details. This involves registry changes and a headache of applying it across the end users machines.

The second fix is to ensure that the IE is made to work with only valid connections (i.e connections not closed by the back-end server). This is possible by increasing the keepalivetimeout value in the back-end to a value more than 60 seconds. The 60 seconds value is due to the fact that IE has a default setting of 60 seconds after which it removes the unused open connections with the back-end server. However, a higher value of KeepAliveTimeout also means that there would be large number of idle connections in Apache which would be reserved to a client.

Keukenhof (Botanical Garden)- Land of Tulips

What I had heard was that Holland (Netherlands) was famous for its flowers, especially the Tulips. So this year (April 2011) we visited the Keukenhof Gardens to see the beautiful flowers. It wasn't bad, there were lots and lots of flowers - in various shapes, colors and fragrance. There were tulips and other flowers in violet , orange , pink and just think of the color and it was there. I had expected to see the long row of flowers in different colors ( remember the Silsila Hindi movie songs!). Though it did not meet my expectations, it was still good. I still had a option to rent a bicycle outside the farm and go to the fields (to rent a cycle you don't have to buy the tickets to Keukenhof, the renting place is just outside the garden gate)





Keukenhof is a botanical garden with lots of flowers - both outside and inside (in glass house), lakes and an old Wooden Windmill. But, let me make it very clear - its not tulip farm where you can see a long row of same colored flowers. For that, you should visit the flower farms. However, from the Keukenhof garden you can have a look at the farm just outside the garden.






My take on the garden
a. Garden is beautiful, in fact very beautiful - you can see a lots of flowers
b. Do not expect flower farms - manage your expectations ;-)
c. Rent a cycle to visit the farms
d. You have an option for Boat ride from the garden - (do the boat booking as the first thing inside the garden as it gets full easily and then roam around in the garden)
e. Do not miss the glass houses, where you see lots of different flowers

Switzerland Trip

In this blog, I would like to share the route that I took for my Swiss trip of 5 days. I'm very positive that this would be helpful for those who intend to visit Switzerland.



The Plan

Our plan was to spend 5 days in Switzerland
Day 1: Land in Geneva Airport and then travel to Interlaken in the Golden Pass Train. We would stay in Interlaken for the night.
Day2: The entire day would be spent in the Jungfraujoch Peak travel . We would stay in Interlaken for the night.
Day 3: We would visit the Schillthorn Peak during the first half of the day and during the second half, we would go to Luzern via boat to Brienz and then in the Golden Pass train. We would spend the night in Luzern.
Day 4: We would visit the Titlis peak and in the evening, head towards Zurich. Spend the night in Zurich.
Day 5: Visit Zurich city and then travel back to Geneva. Visit Geneva lake during the second half of the day.

Geneva Airport, Montreaux Surprise
We landed in Geneva Airport around 10:00AM. We bought the half fare card and the tickets to Interlaken from the Geneva Airport Train Counters. There are 3- 4 counters and you should expect a waiting time of around 30 -45 minutes. They accept payment in Euros and in Swiss Francs. We boarded the train to Montreaux from the Geneva Airport. We reached Montreaux within 1 hour 15 minutes, around 12:35PM. We had a Golden Pass train waiting but we wanted to have our lunch. We stepped out of the railway station and found that the place had no restaurants. We walked for 5 minutes and took a 200 step staircase to reach the main road of Montreaux. The place had a good view of the Lake Geneva and was a surprise. We had food in McDonalds and then spent around 30 minutes in the beach side. I felt that we should have spent the night or at least 3 hours in the beach side. We had to rush back to the to the Railway Station to board the train to Interlaken as we had reserved our seats in the Golden Pass Train at 13:45.

Golden Pass Train

I would recommend seat reservation so that you get good seats. Again, a painful surprise was that it was Golden Pass Classic - which meant the following - compartments were small, seats were small , had all antique look and worst, the windows were small and cant open it! Well then, it was Golden Pass Classic and I had paid for it. If we had boarded the train at 12:45 or at 2:45, we would have been in the Golden Class Panoramic, which had big windows and can open it so that you can take photographs. The scenic beauty was so awesome. The train took us to Zweisimmen around 3:30PM. At Zweisimmen, we had to change the train. God helped us- the next train was a Golden Pass Panoramic train, with large windows. The travel was via Speiz and then through the shores of Lake Thun to reach Interlaken at 5PM. We got good snaps of the Lake Thun with ice capped mountains in the background. PHOTO HERE

Interlaken
We went to Interlaken Ost station so that we could go to Wilderswill. We had booked our night accommodation in Wilderswill - a small village, 5 mins by train. The place was excellent - calm, scenic, a small stream, good view of the Jungfraujoch mountains and nice people. We went to our hotel, which had large and clean rooms. From our balcony we had a good view of the mountain peak. We kept our baggage in the room and then went back to Interlaken. Matter of fact, Interlaken West was much better than Interlaken Ost. West had a beautiful stream, lot of shops and lot many restaurants near by. We spent some time in the town and then had our lunch in a Chinese restaurant. Buffet (to-go) for 10 Francs was worth. We then returned back to the hotel and had a good sleep. We were supposed to leave the hotel around 7:30 AM, the next day, to take the early train (to beat the crowd) to Jungfraujoch.

Jungfraujoch Peak
The peak is indeed good and will depend on the cloud that day! .