Thursday, October 08, 2009
Friday, October 02, 2009
Where does ASPState Database store data?
The default when creating the ASPState database with the command line tool, aspnet_regsql, is for data to be stored in the tempdb rather than in the ASPState db.
For others similarly unenlightened as I was:
C:\>aspnet_regsql -S servername -E -ssadd -sstype t
is for the temdb option, and:
C:\>aspnet_regsql -S servername -E -ssadd -sstype p
is for the persistent option.
For others similarly unenlightened as I was:
C:\>aspnet_regsql -S servername -E -ssadd -sstype t
is for the temdb option, and:
C:\>aspnet_regsql -S servername -E -ssadd -sstype p
is for the persistent option.
Thursday, September 10, 2009
LARGEADDRESSAWARE and Visual Studio
To make the application use more than 2G memory, you need use LARGEADDRESSAWARE indicator when compiling.
To make Visual Studio large address aware:
1.Be sure to backup devenv.exe
2.Using the Visual Studio command prompt, navigate to C:\Program Files\Microsoft Visual Studio 9\Common7\IDE\
3.execute the following command:
1: editbin /LARGEADDRESSAWARE devenv.exe
By doing above, your studio will be able to use more than 2G memory.
In addition, "editbin /LARGEADDRESSAWARE " can be used against any managed assemblies. It will enable the assemblies use more than 2G memory.
To make Visual Studio large address aware:
1.Be sure to backup devenv.exe
2.Using the Visual Studio command prompt, navigate to C:\Program Files\Microsoft Visual Studio 9\Common7\IDE\
3.execute the following command:
1: editbin /LARGEADDRESSAWARE devenv.exe
By doing above, your studio will be able to use more than 2G memory.
In addition, "editbin /LARGEADDRESSAWARE " can be used against any managed assemblies. It will enable the assemblies use more than 2G memory.
3GB Switch in Windows boot.ini
http://www.maxi-pedia.com/3GB+switch+Windows+boot.ini+3+GB
The /3GB or 3GB switch in the boot.ini file lets you tune the use of memory and memory address space in your computer. The /3GB switch specifies the amount of memory for user-mode virtual address space. It is used to allocate more memory to applications and less memory to the operating system.
The /3GB switch increases the size of the user process address space from 2 GB to 3 GB.
This can improve performance of servers that run virtual-memory-intensive applications. That is for example database servers. A larger address space can improve a database server performance.
How does the /3GB switch work?
By default Windows provides applications with a flat 32-bit virtual address space that describes 4 gigabytes of virtual memory. In other words, regardless of the amount of physical memory in your system (RAM), 32-bit versions of Windows only use a virtual address space of 4 GB.
The address space is split so that 2 GB of address space is directly accessible to user-mode processes (applications, for example your Opera Browser and the other 2 GB is only accessible to kernel-mode processes (Windows operating system, drivers, etc.).
The 32-bit versions of Windows were later in their production cycles improved to provide applications with a 3 GB flat virtual address space, with the kernel and executive components using only 1 GB.
This is accomplished by adding the /3GB switch to the boot.ini file. Adding the /3GB switch to the boot.ini file will not increase the amount of physical RAM memory, the 3GB switch just tells the computer to allocate the existing memory space differently.
The 3GB boot.ini switch is often used on Windows Server 2003 which includes support for the 3GB startup switch.
What is the benefit of using the 3GB switch?
Depending on what software you run on your server, it might make sense to optimize the server memory usage. If for example you are running only a few memory extensive large applications that do not interact with the operating system but rather work on their own, you might want to consider implementing this switch.
The additional virtual address space that you give applications with the 3GB switch helps reduce the amount of memory fragmentation in the virtual address space.
What values can the /3GB switch take?
The switch can have any value between 2048 (2 GB) and 3072 (3 GB) megabytes. It needs to be expressed in decimal notation.
With the switch, Windows will use the remaining address space (4 GB minus the specified amount) as its kernel-mode address space.
How do I find out what boot.ini options my server uses?
You can see this in the boot.ini file, of course. Another more detailed way is to research registry settings. In this case, you would go to the Start menu, click Run, type REGEDIT, and hit ENTER.
Locate the following registry keys section:
HKLM\System\CurrentControlSet\Control\SystemStartOptions
How do I set the /3GB switch in Windows Server 2003?
Setting the /3GB switch for your server is very easy. Execute the following steps:
-> right-click My Computer
-> Properties
-> click the Advanced tab
-> click Settings in the Startup and Recovery area
-> click Edit in the System startup area
This will open the Windows boot.ini file in Notepad. See the following print screen:
Locate the [Operating Systems] section and add the /3GB switch to the end of the startup line that includes the /fastdetect. Now you can save the changes, close Notepad, and click OK to close all the open dialog boxes.
You need to restart the computer for the change to take effect.
Boot.ini file /3GB switch example
This is what your default boot.ini file before you make the change might look like. The timeout and partition and other parameters depend on your setup. Pay attention to the line with the /fastdetect.
[boot loader]timeout=10default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS[operating systems]multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise" /fastdetectAnd, below you can find what the boot.ini file should look like after making the change.
[boot loader]timeout=10default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS[operating systems]multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise" /fastdetectmulti(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise with /3GB" /3GB /fastdetectMake sure you do not enter a typo in this file as it might result in being unable to start your computer.
Do I need to reboot the server after adding the /3GB switch?
Yes, the /3GB switch entered in the system’s boot.ini file and takes effect after a restart.
Which operating systems support the 3GB switch?
The /3GB switch applies to 32-bit systems only. The following is a list of operating systems that support the 3GB switch:
Windows Server 2003 Standard Edition
Windows Server 2003 Enterprise Edition
Windows Server 2003 Datacenter Edition
Windows 2000 Advanced Server
Windows 2000 Datacenter Server
This is a list of officially supported operating systems that can handle the 3GB switch. Other systems may or may not handle it well depending on the hardware and software configuration.
Can I use the /3GB switch on Windows XP?
Adding the 3GB switch to the boot.ini file in Windows XP SP1 can cause Windows not to start.
A supported fix is available from Microsoft, but it is only intended to correct the problem resulting from this specific setup. The solution to this problem is upgrade to the latest service pack. You can read more about this problem on the following Microsoft page:
Windows XP SP1 May Not Start with the /3GB or /USERVA Switch
http://support.microsoft.com/default.aspx?scid=kb;en-us;328269
Can I use the /3GB switch on Windows Server 2000?
The 3GB switch is officially supported on the 2000 Advanced Server. The official word is that it should not be used on Windows 2000 Server because it is unsupported and can cause application or operating system to crash.
Important warning
Any time you make a change to the boot.ini file, make sure that you have all your data backed up!
Are there any other boot.ini parameters that I should know about?
Yes, you might be interested in knowing about the /fastdetect switch: Fastdetect boot.ini switch.
The Data Execution Prevention DEP setting can be also implemented in your BOOT.INI file through the NOEXECUTE switch. See the noexecute DEP parameter in boot.ini page for more details.
The /3GB or 3GB switch in the boot.ini file lets you tune the use of memory and memory address space in your computer. The /3GB switch specifies the amount of memory for user-mode virtual address space. It is used to allocate more memory to applications and less memory to the operating system.
The /3GB switch increases the size of the user process address space from 2 GB to 3 GB.
This can improve performance of servers that run virtual-memory-intensive applications. That is for example database servers. A larger address space can improve a database server performance.
How does the /3GB switch work?
By default Windows provides applications with a flat 32-bit virtual address space that describes 4 gigabytes of virtual memory. In other words, regardless of the amount of physical memory in your system (RAM), 32-bit versions of Windows only use a virtual address space of 4 GB.
The address space is split so that 2 GB of address space is directly accessible to user-mode processes (applications, for example your Opera Browser and the other 2 GB is only accessible to kernel-mode processes (Windows operating system, drivers, etc.).
The 32-bit versions of Windows were later in their production cycles improved to provide applications with a 3 GB flat virtual address space, with the kernel and executive components using only 1 GB.
This is accomplished by adding the /3GB switch to the boot.ini file. Adding the /3GB switch to the boot.ini file will not increase the amount of physical RAM memory, the 3GB switch just tells the computer to allocate the existing memory space differently.
The 3GB boot.ini switch is often used on Windows Server 2003 which includes support for the 3GB startup switch.
What is the benefit of using the 3GB switch?
Depending on what software you run on your server, it might make sense to optimize the server memory usage. If for example you are running only a few memory extensive large applications that do not interact with the operating system but rather work on their own, you might want to consider implementing this switch.
The additional virtual address space that you give applications with the 3GB switch helps reduce the amount of memory fragmentation in the virtual address space.
What values can the /3GB switch take?
The switch can have any value between 2048 (2 GB) and 3072 (3 GB) megabytes. It needs to be expressed in decimal notation.
With the switch, Windows will use the remaining address space (4 GB minus the specified amount) as its kernel-mode address space.
How do I find out what boot.ini options my server uses?
You can see this in the boot.ini file, of course. Another more detailed way is to research registry settings. In this case, you would go to the Start menu, click Run, type REGEDIT, and hit ENTER.
Locate the following registry keys section:
HKLM\System\CurrentControlSet\Control\SystemStartOptions
How do I set the /3GB switch in Windows Server 2003?
Setting the /3GB switch for your server is very easy. Execute the following steps:
-> right-click My Computer
-> Properties
-> click the Advanced tab
-> click Settings in the Startup and Recovery area
-> click Edit in the System startup area
This will open the Windows boot.ini file in Notepad. See the following print screen:
Locate the [Operating Systems] section and add the /3GB switch to the end of the startup line that includes the /fastdetect. Now you can save the changes, close Notepad, and click OK to close all the open dialog boxes.
You need to restart the computer for the change to take effect.
Boot.ini file /3GB switch example
This is what your default boot.ini file before you make the change might look like. The timeout and partition and other parameters depend on your setup. Pay attention to the line with the /fastdetect.
[boot loader]timeout=10default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS[operating systems]multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise" /fastdetectAnd, below you can find what the boot.ini file should look like after making the change.
[boot loader]timeout=10default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS[operating systems]multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise" /fastdetectmulti(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise with /3GB" /3GB /fastdetectMake sure you do not enter a typo in this file as it might result in being unable to start your computer.
Do I need to reboot the server after adding the /3GB switch?
Yes, the /3GB switch entered in the system’s boot.ini file and takes effect after a restart.
Which operating systems support the 3GB switch?
The /3GB switch applies to 32-bit systems only. The following is a list of operating systems that support the 3GB switch:
Windows Server 2003 Standard Edition
Windows Server 2003 Enterprise Edition
Windows Server 2003 Datacenter Edition
Windows 2000 Advanced Server
Windows 2000 Datacenter Server
This is a list of officially supported operating systems that can handle the 3GB switch. Other systems may or may not handle it well depending on the hardware and software configuration.
Can I use the /3GB switch on Windows XP?
Adding the 3GB switch to the boot.ini file in Windows XP SP1 can cause Windows not to start.
A supported fix is available from Microsoft, but it is only intended to correct the problem resulting from this specific setup. The solution to this problem is upgrade to the latest service pack. You can read more about this problem on the following Microsoft page:
Windows XP SP1 May Not Start with the /3GB or /USERVA Switch
http://support.microsoft.com/default.aspx?scid=kb;en-us;328269
Can I use the /3GB switch on Windows Server 2000?
The 3GB switch is officially supported on the 2000 Advanced Server. The official word is that it should not be used on Windows 2000 Server because it is unsupported and can cause application or operating system to crash.
Important warning
Any time you make a change to the boot.ini file, make sure that you have all your data backed up!
Are there any other boot.ini parameters that I should know about?
Yes, you might be interested in knowing about the /fastdetect switch: Fastdetect boot.ini switch.
The Data Execution Prevention DEP setting can be also implemented in your BOOT.INI file through the NOEXECUTE switch. See the noexecute DEP parameter in boot.ini page for more details.
Is my xp 32bit or 64 bit?
Method 1
1. Click Start, click Run, type sysdm.cpl, and then click OK.
2. Click the General tab. The operating system appears as follows:
(For a 64-bit version operating system: Microsoft Windows XP Professional x64 Edition Version < Year> appears under System. For a 32-bit version operating system: Microsoft Windows XP Professional Version< Year> appears under System.) Note is a placeholder for a year.
Method 2
1. Click Start, click Run, type winmsd.exe, and then click OK.
2. In the details pane, locate Processor under Item. Note the value. (If the value that corresponds to Processor starts with x86, the computer is running a 32-bit version of the Windows operating system. If the value that corresponds to Processor starts with ia64 or AMD64, the computer is running a 64-bit version of the Windows operating system.)
1. Click Start, click Run, type sysdm.cpl, and then click OK.
2. Click the General tab. The operating system appears as follows:
(For a 64-bit version operating system: Microsoft Windows XP Professional x64 Edition Version < Year> appears under System. For a 32-bit version operating system: Microsoft Windows XP Professional Version< Year> appears under System.) Note
Method 2
1. Click Start, click Run, type winmsd.exe, and then click OK.
2. In the details pane, locate Processor under Item. Note the value. (If the value that corresponds to Processor starts with x86, the computer is running a 32-bit version of the Windows operating system. If the value that corresponds to Processor starts with ia64 or AMD64, the computer is running a 64-bit version of the Windows operating system.)
.Net, 64bit and 32 bit
Since .Net 2.0 was released, .Net started supporting 64bit programming.
'CorFlags.exe' is a tool for you to peek the information inside a PE. It can be used to check whether an assembly is targetting 32bit or 64bit.
Here's one sample query.
D:\Project\BookingSheet\BookingSheetUI\bin\Release>corflags bookingsheetui.exe
Version : v2.0.50727
CLR Header: 2.5
PE : PE32
CorFlags : 3
ILONLY : 1
32BIT : 1
Signed : 0
You can see that 32bit is set to 1 that means the exe is targetting 32bit.
You can use "corflags bookingsheetui.exe \32bit+" to enforce the assembly to target 32bit. You can also use "corflags bookingsheetui.exe \32bit-" to enforce the assembly not use 32bit.
An assembly that is targetting 32bit can also run at a 64bit WIN OS. It is called "WOW64".
Migrating a managed program involved unmanaged codes is more complicated.
'CorFlags.exe' is a tool for you to peek the information inside a PE. It can be used to check whether an assembly is targetting 32bit or 64bit.
Here's one sample query.
D:\Project\BookingSheet\BookingSheetUI\bin\Release>corflags bookingsheetui.exe
Version : v2.0.50727
CLR Header: 2.5
PE : PE32
CorFlags : 3
ILONLY : 1
32BIT : 1
Signed : 0
You can see that 32bit is set to 1 that means the exe is targetting 32bit.
You can use "corflags bookingsheetui.exe \32bit+" to enforce the assembly to target 32bit. You can also use "corflags bookingsheetui.exe \32bit-" to enforce the assembly not use 32bit.
An assembly that is targetting 32bit can also run at a 64bit WIN OS. It is called "WOW64".
Migrating a managed program involved unmanaged codes is more complicated.
Tuesday, August 25, 2009
Reactive Process Recycling
Reactive process recycling occurs when a process is misbehaving or unable to serve requests.
Configuration settings that are related to this:
requestQueueLimit: Handles deadlock conditions. The DWORD value is set to the maximum allowed number of requests in the queue, after which the worker process is considered to be misbehaving. When the number is exceeded, a new process is launched and the requests are reassigned. The default is 5000 requests.
memoryLimit: Handles memory leak conditions. The DWORD value is set to the percentage of physical memory that the worker process can consume before it is considered to be misbehaving. When that percentage is exceeded, a new process is launched and the requests are reassigned. The default is 60%.
shutdownTimeout: Specifies the amount of time the worker process has to shut itself down gracefully (string value in hr:min:sec format). When the time out expires, the ASP.NET ISAPI shuts down the worker process. The default is "00:00:05".
Configuration settings that are related to this:
requestQueueLimit: Handles deadlock conditions. The DWORD value is set to the maximum allowed number of requests in the queue, after which the worker process is considered to be misbehaving. When the number is exceeded, a new process is launched and the requests are reassigned. The default is 5000 requests.
memoryLimit: Handles memory leak conditions. The DWORD value is set to the percentage of physical memory that the worker process can consume before it is considered to be misbehaving. When that percentage is exceeded, a new process is launched and the requests are reassigned. The default is 60%.
shutdownTimeout: Specifies the amount of time the worker process has to shut itself down gracefully (string value in hr:min:sec format). When the time out expires, the ASP.NET ISAPI shuts down the worker process. The default is "00:00:05".
Increase the memory limit
1) Booting the OS into /3GB mode
2) Marking your assemblies as /LARGEADDRESSAWARE
3) There may not be a contiguous block of memory large enough to satisfy your allocation.
4) .NET imposes a 2GB object size limit, so trying to allocate an array larger than 2GB will fail.
5) The exe that will be published is first created in the obj\release or obj\debug directory, depending on if this is a release or debug build.
6) The postbuild is run before the .exe is copied to the bin\release\*.publish\publish version directory.
7) Postbuild commands: $(ProjectDir)postbuild.bat $(ProjectDir)obj\$(ConfigurationName)\$(TargetFileName) $(TargetPath)
8) Postbuild.bat file
echo off
call "%VS80COMNTOOLS%vsvars32.bat"
editbin /largeaddressaware %1
editbin /largeaddressaware %2
2) Marking your assemblies as /LARGEADDRESSAWARE
3) There may not be a contiguous block of memory large enough to satisfy your allocation.
4) .NET imposes a 2GB object size limit, so trying to allocate an array larger than 2GB will fail.
5) The exe that will be published is first created in the obj\release or obj\debug directory, depending on if this is a release or debug build.
6) The postbuild is run before the .exe is copied to the bin\release\*.publish\publish version directory.
7) Postbuild commands: $(ProjectDir)postbuild.bat $(ProjectDir)obj\$(ConfigurationName)\$(TargetFileName) $(TargetPath)
8) Postbuild.bat file
echo off
call "%VS80COMNTOOLS%vsvars32.bat"
editbin /largeaddressaware %1
editbin /largeaddressaware %2
Wednesday, August 19, 2009
An Introduction to OLAP in SQL Server 2005
http://www.devx.com/dbzone/Article/21410/0/page/3
•Determine the required dimensions (bys) and measures (target data) .
•Use Data Transformation Services to extract data from your source databases, transforming the data as needed, and loading the finished data into the cube.
•Use the BI Workbench's Analysis Services wizards to build the measures, dimensions, and schema.
•Provide cube browsers for your users so they can select and view reports. If necessary, write MDX queries or use automated tools, such as Excel Pivot Tables to query the cube.
•Determine the required dimensions (bys) and measures (target data) .
•Use Data Transformation Services to extract data from your source databases, transforming the data as needed, and loading the finished data into the cube.
•Use the BI Workbench's Analysis Services wizards to build the measures, dimensions, and schema.
•Provide cube browsers for your users so they can select and view reports. If necessary, write MDX queries or use automated tools, such as Excel Pivot Tables to query the cube.
Wednesday, July 15, 2009
try/catch/finally
"try/catch/finally" is to handle unexpected exception so that the program will deterministic. But you have to be aware of that it only handle the codes that are in the block of "try".
Monday, July 06, 2009
How ASP.NET Works with IIS
Svchost.exe is process that delivers Web publishing services (or in other words - iis). When an asp.net request comes, it will forward the request to asp.net working process - aspnet_wp.exe that is running under the account ASPNET.
DB schema design - char, varchar, nchar, nvarchar and text
Database supplies mutilple field types to manage text data.
If the length of the data in a field is relatively fixed, you should use char.
If the length of the data varies, you should use varchar.
If the data is unicode (16 bits characters), you should nchar or nvarchar.
In old version, varchar and nvarchar can only hold chars no more than 8000 (?). In sql 2005 and future version, text, and ntext going to be replaced by varchar. (Image is replaced by varbinary(max)). Varchar(max) can hold 2(31) - 1 bytes or 2GB - 1 chars.
If the length of the data in a field is relatively fixed, you should use char.
If the length of the data varies, you should use varchar.
If the data is unicode (16 bits characters), you should nchar or nvarchar.
In old version, varchar and nvarchar can only hold chars no more than 8000 (?). In sql 2005 and future version, text, and ntext going to be replaced by varchar. (Image is replaced by varbinary(max)). Varchar(max) can hold 2(31) - 1 bytes or 2GB - 1 chars.
ODBC and OLE
ODBC and OLE are both the utility for applications to connect to database. OLE is a native MS SQL server connector while ODBC is a general connector and can be used to connect to any Database that supports ODBC.
For performance reason, if you know you are connecting to MS SQL database, you can choose to use OLE as your connector.
For performance reason, if you know you are connecting to MS SQL database, you can choose to use OLE as your connector.
