Saturday, September 29, 2012

Preserving State Between Web Server Instances

One of my web site applications has been giving me headaches.  Every few days, I would encounter an incident when one of the user session seem to lockout the application causing other users to time out.  I used Microsoft IIS' application pool function to separate it from the other apps running on the same server so I can easily restart its pool without affecting the others.  But still, having to restart the pool every so often is a chore.

I decided to spread out the load to several threads by initially setting up a Web Garden.  A Web Garden uses multiple worker processes and uses a queue manager to process incoming requests to the application pool.  Unlike a Web Farm, which comprises of multiple web servers, a Web Garden just uses multiple worker threads in the same multi-CPU server.

The problem I encountered with running apps in a web garden is that values stored in Session variables are local to the worker thread that was assigned to it.  So if IIS decide to send you to a different worker thread in subsequent requests, the Session variables used in the other worker thread will completely disappear.  I thought of using ViewState at first so that the values are stored on the client side and just passed back on every request.  Unfortunately, ViewStates only seem to work for postbacks to the same URL.  Once the URL changes, the previous ViewState value is also gone.

I found this interesting article on how to use OutOfProc Session State servers.  By using the StateServer instance, one can save session variables between apps or even between servers.  Its not as robust as the SQLServer solution, but its relatively lower overhead.  One only need to add the following lines in the web.config's system.web section:


< sessionState mode="stateserver" stateConnectionString="tcpip=127.0.0.1:42424" />

Will be observing if performance improves with this modest adjustment on the design.

Wednesday, September 26, 2012

Taking the Camry for a spin

I had a meeting at Clark, Pampanga today with a client so I took our new Toyota Camry for its first long distance drive.  I've been wanting to figure out what its mileage is like under a long, smooth driving condition with no traffic.  One of the nifty features of the car's dashboard is a real-time calculator of its gasoline mileage.  Under Manila's normal city traffic conditions, the best I can do is between 6 to 8 km/liter under "Eco Drive" mode.  A long distance drive with no traffic should show a much better performance.

At its peak, I was able to clock a sweet 16.1 km/liter!  I cruised between 80 to 110 kmph during the whole stretch.  It seems that the optimal mileage can be reached by the car if you set it at cruise control and just let the computer take over; or maybe it was just my imagination.  Sigh... if only inner city driving was as fuel efficient.


Saturday, September 15, 2012

Hello World Conner Drake

Cols and I woke up early today because we were supposed to drive Ethan to Xavier for his Saturday make-up class.  But because its been raining heavily the whole night, the school decided to postpone the make-up class.  Cols and I proceeded to Cardinal Santos to have a check-up since she is scheduled to give birth already anytime this week.  The maternity unit said she is already open 2cm and when they contacted Dr. Madamba, she told the staff to inform us to come back later in the day to induce labor already.

We went home first to have lunch and relax a bit.  We drove back to Cardinal Santos around 4:30pm.  When we got to the maternity unit, we were surprised when they told us Cols is now at 5cm and can give birth in 2 hours time!

I proceeded to the admission counter while they prepared Cols to go into labor.  By around 8:30pm, Dr. Madamba predicted baby will be out by around 9pm.  So at quarter to 9, we were moved already from the labor room to the delivery room.  With just a couple of push, and almost right on the dot, Conner Drake popped out of his mom's tummy!


Conner weighed in at 6.7 lbs.