Friday, June 27, 2008

Further into IIS issues

Recently we faced an issue with the webapplications hosted on IIS. Something interesting to solve.
The webapplications were working perfectly fine but only in the LAN environment. When logged in from VPN they didnt work. Access denied messages were displayed. All the settings on IIS were perfectly fine with Anonymous user login, security settings for folders, etc. After a brief analysis the reasons for the issue was found out.
This issue occurs where there is a non-sync between the IUSR password in IIS and the IUSR password at the system level.

To fix this we can either change the password to make it same at system level and in IIS setting or simply restart the IIS Admin service which will recreate the IUSR account.

To sychronise the system level password and password in the IIS setting follow the steps given below:

The password can be change in the IIS settings by changing the entries in the adsutil.vbs

To know if the password entries are available in the adsutil.vbs use the following command:
cscript adsutil.vbs find anonymoususerpass
This will return a listing of all the nodes where the anonymoususerpass appears in the metabase. Ideally you should see this in only the W3SVC node (it may also appear in the MSFTPSVC node if you are running FTP). If you see any locations “under” W3SVC (i.e. W3SVC/1/root) then we should delete these entries.

To delete an entry use the following syntax:
cscript adsutil.vbs delete W3SVC/1/root/anonymoususerpass

Once we have made sure that we only have the password set at a single location, we need to “sync” the password with the one in the SAM database. The easiest way to do this is to simply open Computer Management if you are on a member server or Active Directory Users and Computers on a domain server and do a change password on the IUSR account. Then back at our command prompt, we simply set the password to match the one we just set by using the following command:

cscript adsutil.vbs set W3SVC/anonymoususerpass "passwordgoeshere"

The passwords should now be in sync and the site should now be accessible.

Wednesday, April 23, 2008

SQL Query Optimisation - Other than common ones

In addition to the common optimization tips for SQL Server query, the following are some of the useful tips.

- To view the row count from a table use, "SELECT rows FROM sysindexes WHERE id = OBJECT_ID('table_name') AND indid < 2" query instead of count(*) or use sp_spaceused which will also provide the row count.
- Avoid having clause in group by and use where if necessary
- Avoid distinct clause and use it only when it is really mandatory
- Include SET NOCOUNT ON for stored procedures as it will reduce the transfer of rowcount data travelling from database to application
- In case you need to get only first n rows in a query use top or SET ROWCOUNT statement.
- Avoid using optimizer hints in any database. This may make the query faster initially but will really affect the performance as the data grows in the table.
- Try to use inner tables instead of creating temporary table whereever possible.
- Use a EXIST, NOT EXISTS or LEFT OUTER JOIN instead of a IN or NOT IN in where clause.

Tuesday, April 22, 2008

Removing Code Smells - An Example

Common code smells

Type codes and switch statements are common code smells. In addition, there are quite some other code smells that are also very common. Below is a summary list:

- Duplicate code.
- Too many comments.
- Type code.
- Switch or a long if-then-else-if.
- Cannot give a good name to a variable, method or class.
- Use names like XXXUtil, XXXManager, XXXController and etc.
- Use the words "And", "Or" and etc. in the name of a variable, method or class.
- Some instance variables are not always used.
- A method contains too much code.
- A class contains too much code.
- A method takes too many parameters.
- Two classes are using each other.

Monday, March 31, 2008

IIS Performance issue

The normal issue that comes up with the web applications hosted on IIS is related to performance. Coincidentally I came across these issues recently in my area of work. I hope this information will help to those who face similar issues.

Here are the basic steps to do when faced with performance issues in web applications:

- Check if the process Aspnet_wp.exe (IIS 5.0) or W3wp process (IIS 6.0) is consuming high memory in the server.
- If the memory level is higher, then it may affect any other services or applications running on that server.
- In case, the requirement of the application requires more memory then upgrade your system to have higher memory to support the application
- Check the Web.Config file if the Debug, Trace or both are enabled. To accomplish this, ensure that the web application is deployed to production always in release mode.

compilation debug="false"

trace enabled="false"

- Check if the executionTimeOut attribute is set to higher level. This should not be set to higher level in production environment. This will hold on to the thread till it timeout and increase the level of memory usage.
- The performance can also be improved at the coding level by avoiding any string concatenation process and instead use the StringBuilder for the purpose.
- On the software installation, ensure that .NET framework 1.1 SP1 is installed.

Here are some additional tips for writing High – Performance Web applications
http://msdn2.microsoft.com/en-us/magazine/cc163854.aspx

Saturday, March 29, 2008

Making the beginning is one third of the work done.

This is my first blog. I have started this for a purpose. As the thought goes in the quote:

"No story is the same to us after a lapse of time; or rather we who read it are no longer the same interpreters." - -- George Eliot

So does my thoughts behind this blog. We learn many things in the course of our daily work, especially in working with technology we learn a particular concept only when it is faced as an issue by us. There is no common solution provided for a particular issue. The approach differs by person, time and environment. In such an environment, knowledge sharing is now the popular concept across the IT sector.

I hope my blog will add value to the knowledge sharing chain