Thursday, June 23, 2016

How to Manage Session in Web Garden Mode?

When we are using Web garden where request is being taken care of by different worker process, we have to make the session mode as out process session mode as described earlier. For Web Garden, we have to configure the out process within the same server but for different worker process.
webgardenSession2
While using Web garden with your application, you need make a couple of configuration settings in web.config in<process Model> section where you need to set certain properties like cpuMask, RequestLimit, webGarden,ClientConnectCheck, etc.

How to Manage Session in Web Farm Mode?

While using session, requests are distributed among different servers. By default, session mode is set to In Proc where session data is stored inside worker process memory. But, in Web farm mode, we can share the session among all the servers using a single session store location by making it Out proc (State Server or SQL Server Mode). So, if some of the servers go down and request is transferred to the other server by the Load balancer, session data should be available for that request.
sessionWebfarm
In the above diagram, you can see that we can both the IIS server sharing the same session data which is stored in out of worker process. 

What is the difference between Web Farm and Web Garden?

Overview

Visual Studio has its own integrated ASP.NET engine which is used to run the ASP.NET Web application from Visual Studio. ASP.NET Development Server is responsible for executing all the requests and responses from the client. Now after the end of development, when you want to host the site on some server to allow other people to access, concept of web servers comes in between. A web server is responsible for providing the response for all the requests that are coming from clients. The below diagram shows the typical deployment structure of an ASP.NET Web application with a single IIS.


  2 

Clients request for resources and IIS process the request and send back to clients. If you want to know more details on How IIS Processes the request, please read one of my articles about “How IIS Process ASP.NET Request?”.

Web Farm

This is the case where you have only one web server and multiple clients requesting for resources from the same server. But when are is huge amount of incoming traffic for your web sites, one standalone server is not sufficient to process the request. You may need to use multiple servers to host the application and divide the traffic among them. This is called “Web Farm”. So when you are hosting your single web site on multiple web servers over load balancer is called “Web Farm”. The below diagram shows the overall representation of Web Farms.







Web Farms

In general web farm architecture, a single application is hosted on multiple IIS Server and those are connected with the VIP (Virtual IP) with Load Balancer. Load Balancer IPs are exposed to external world to access. So whenever some request will come to server from clients, it will first hit the Load Balancer, then based on the traffic on each server, LB distributes the request to the corresponding web server. These web servers may share the same DB server or may be they can use a replicated server in the back end.
So, in a single statement, when we host a web application over multiple web servers to distribute the load among them, it is called Web Farm.

Web Garden

Now, let’s have a look at what is Web Garden? Both the terms sound the same, but they are totally different from each other. Before starting with Web Garden, I hope you have a fundamental idea of what an Application Pool is and what a Worker Process is. If you have already read the article, “How IIS Processes ASP.NET Request ?”, then I can expect that you now have a good idea about both of them.
Just to recall, when we are talking about requesting processing within IIS, Worker Process (w3wp.exe) takes care of all of these. Worker Process runs the ASP.NET application in IIS. All the ASP.NET functionality inside IIS runs under the scope of worker process. Worker Process is responsible for handling all kinds of request, response, session data, cache data. Application Pool is the container of worker process. Application pool is used to separate sets of IIS worker processes and enables a better security, reliability, and availability for any web application.
apppools
Now, by default, each and every Application pool contains a single worker process. Application which contains the multiple worker process is called “Web Garden”. Below is the typical diagram for a web garden application.
WebGarden Basic 

In the above diagram, you can see one of the applications containing the multiple worker processes, which is now a web garden.
So, a Web application hosted on multiple servers and access based on the load on servers is called Web Farms and when a single application pool contains multiple Worker processes, it is called a web garden.

Create Web Garden in IIS 6 and IIS 7

Now, I am going to show how you can change the Number of Worker processes in both IIS 6 and IIS 7. For IIS 6, Right Click on Application Pool > Properties > Goto Performance Tab.
WebGardenIIS6
In the “Performance Tab” section, you would have one option called “Web Garden” where worker process sets to “1”, you can set the number of worker processes that you required.
For IIS 7, Right Click on Application Pool > Go To Advance Settings > In Process Model section, you will have “Maximum Worker Processes”. You can change it more than 1 to make it as a web garden.
WebGardenIIS7
In the above image, you can also check the definition of Web Garden.
You can find one of my previous articles on the basics of the same over here.

Advantages of Web Farm and Web Garden

Now, let’s have a look into the advantages of both the Web Farms and Web Gardens.

Advantages of Web Farm

  • It provides high availability. If any of the servers in the farm goes down, Load balancer can redirect the requests to other servers.
  • Provides high performance response for client requests.
  • Provides better scalability of the web application and reduces the failure of the application.
  • Session and other resources can be stored in a centralized location to access by all the servers.

Advantages of Web Garden

  • Provides better application availability by sharing requests between multiple worker process.
  • Web garden uses processor affinity where application can be swapped out based on preference and tag setting.
  • Less consumption of physical space for web garden configuration.


Thursday, February 11, 2016

New Features in Visual Studio 2015 | 2013 | 2012 | 2010


Visual Studio 2015

Visual Studio 2015 has been finally released including several incredible features that enhanced the way we look at development from desktop and web to mobile applications.
  • Improved Code Editor: The Code Editor has been already replaced with the so called “Roslyn” compiler to provide you an improved and exciting code editing experience. A light bulb is shown when you have to include some code fixes , so anytime you see a light bulb, click it and you will get suggestions that is based upon the analyzed code.
  • Custom Layout: The full potential of this feature can be used on multiple devices. Let’s say you are about to use a Surface Pro to develop on your bus ride home and a 24″ monitor from the comfort of your home. In order to quickly switch devices go to Window – Apply Window Layout. Keyboard shortcuts is also supported so that the user can quickly navigate to any familiar layout.
  • Shared Project: Probably you have been a witness of an event when you wanted to use a Shared Project option right outside of Windows Universal Application, now IT IS A REALITY. After a quick search you will find the Shared Project in the list of the new project window.
  • Single Sign-In: This one is undoubtedly much awaited feature. As these days, we developers, are using cloud services for multiple purposes. So, managing these services with different sign-in details in Visual Studio was annoying as authentication alerts were required for accessing these integrated cloud services. With Visual Studio 2015 single Sign-In support is provided, so once we are authenticated with first cloud service, no more authentication needed.
  • Smart Unit Tests: IntelliTest in Visual Studio 2015 has the capability to explore our code to generate test data and a suite of unit tests with much improved code coverage.
  • Emulator for Android: No doubt the Android Emulator is a true relief as you can use it in Visual Studio 2015 as a cross-platform project or VS Tools for Cordova. It supports a variety of sensors and simulations, also GPS Location, Screen Rotation,  Accelerometer, SD Card, Zoom, Multi-touch, Camera and access to network also.
  • Renaming Enhancement: Before the user renames a variable or an object, Visual Studio will highlight all affected instances making it easy to identify all the changes to be made. Also there is a new dialog window that shows the number of changes or even conflicts for a renaming operation.
  • Editor Touch Support: There is an enormous boom of touch sensitive devices and monitors nowadays, soVisual Studio 2015 had to come up with touch based support. You can use the touch screen for scrolling, gesture zooming, line selecting and also a new functionality was added to bring up the Editor context menu.
  • Support for JavaScript Editor: Working as a web developer on Microsoft Platform, it’s always been difficult to work with JavaScript within Visual Studio. Although Visual Studio 2013 has improved it’s editor for JavaScript but in Visual Studio 2015, JavaScript editor has been updated with number of amazing features as:
    • Intellisense support for object literal
    • Expand/Collapse JavaScript code sections
    • New Navigation Bar for navigating between elements in JavaScript
    • Support for New JavaScript Features (ES6 version)
    • and many more…
  • Custom Window Layouts: Most developers are familiar with their own window configuration. Let’s say you work on a JavaScript based project, then you will need a much larger code editor window whilst with a web project you may want to open the solution explorer window.

Visual Studio 2013

  • Throw-away applications: In Visual Studio 2013, the new project window looks a little different. If you want to create a new project, the name and the location no longer have to be set immediately. It is a good option when you are about to test something and delete the project right away, so you don’t waste time.
  • Code-lens: A feature that is available only in the Ultimate Edition. A real time saver, as by default, it shows the number of times a method or property is referenced in your code. Especially useful feature in larger project where you are not familiar with the entire source code.
  • Customizing Scroll Bar: The possibility to customize the scroll bar just gives the user a much better overview of larger files. A user can set the scroll bar to show breakpoints, errors and much more.
  • ALM (Application Life Cycle Management) features including agile portfolio management, web-based code comments, web-based test case management, change-sets and commits etc.
  • Creating Azure Website from within Visual Studio 2013 by installing Azure SDK and connecting to Azure.
  • Live debugging in Azure
  • Live Tracing from Azure
  • With .NET framework 4.5.1, just like 32-bit Edit and Continue, now we have with 64-bit also.
  • Better Navigation & Search
  • Open a method definition by using Peek a Definition feature.
  • Handy feature of resolving type by resolve menu.

Visual Studio 2012

  • While the Visual Studio 2010 already included an emulator for Windows Phone devices, the Visual Studio 2012 Simulator is much more powerful. It enables debugging apps for various scenarios that you just don’t have natively on your own machine.
  • You can also develop Windows 8 apps that strictly require some hardware support such as touch, rotation and different target resolution.
  • It is unimaginable to build quality applications without good IntelliSense. Therefore, the developers put enough effort in Visual Studio 2012 to make it more efficient and productive.
  • An even more important feature is the JavaScript Console. The good news is, that you can play with the source code modifications while the application is running.
  • Runtime Debugging Tool i.e. DOM Explorer for debugging HTML/CSS.
  • Asynchronous Support in C#/VB
  • Team Foundation Explorer Window
  • Code Clone Detection
  • Project File Compatibility with Visual Studio 2010

Visual Studio 2010

  • IntelliSense improvement: One of the most important and time saving feature. It is so comforting to wonder how many hours a programmer can save thanks to IntelliSense. For those who don’t know, it is that wonderful drop down list that automatically completes existing member names or type names. This feature can amazingly speed up your work as you don’t have to type so much on your keyboard.
  • Toolbar Items can be easily found: Each new version of Visual Studio has an exponential increase of items in the Toolbox. Until the release of VS 2010, the items where categorized into collapsible sections and searching was managed manually by the user. Fortunately, the new version of Visual Studio offers a search via keyboard.Simply click on the Toolbox so that it is focused and just start typing.
  • Improvement in Searching: Visual Studio always supported different search features , but the fact is that it was a little clunky. In other words, the search feature was limited to searching for specific string in files. This feature was still available but a new one was added. A search window called Navigate To. You can navigate anywhere in your project by typing in the name of a method, class, an event or even a file name.
  • Multiple monitors: It is statically proven that using multiple monitors can improve a programmers efficiency by 50%. So, visual Studio 2010 has feature for detaching window outside the IDE.
  • Highlighting References feature in Visual Studio 2010 can highlight all calls to a specific method or member variables.
  • Improved Loading Time for Assemblies in “Add Reference”.
  • Support for Targeting multiple .NET Framework during Application Development.

Tuesday, February 2, 2016

SQL Server Invalid Object Name,but tables are listed in SSMS tables list

Try:
Edit -> IntelliSense -> Refresh Local Cache
This should refresh the data cached by Intellisense to provide typeahead support and pre-execution error detection.

Monday, February 1, 2016

Exit single-user mode in MSSQL

SSMS in general uses several connections to the database behind the scenes.
You will need to kill these connections before changing the access mode.
First, make sure the object explorer is pointed to a system database like master.
Second, execute a sp_who2 and find all the connections to database 'my_db'. Kill all the connections by doing KILL { session id } where session id is the SPID listed by sp_who2.
Third, open a new query window.
Execute the following code:

-- Start in master
USE MASTER;

-- Add users
ALTER DATABASE [my_db] SET MULTI_USER
GO

Thursday, December 10, 2015

Restore a Encrypted MSSQL Backup to Another Server

1.If you want to restore a encrypted backup to another server as usual you encounter the following error
 Cannot find server certificate with thumbprint …...
2.Find the cert name : in this example vestacert
   SELECT  * FROM   sys.certificates
3.backup the cert from source server (Source encryptedserver) :
BACKUP CERTIFICATE vestacert
TO FILE = 'c:\Backup\certificate_TDE_Test_Certificate.cer'
WITH PRIVATE KEY
(FILE = 'c:\Backup\certificate_TDE_Test_Key.pvk',
ENCRYPTION BY PASSWORD = 'Password12#')
4.Create new Master Cert on UAT server if not already exist
USE master GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'D1ffPa$$w0rd'
5.Restore backup certs in UAT server (UATserver)
CREATE CERTIFICATE vestacert2
FROM FILE = 'C:\tmp\certificate_TDE_Test_Certificate.cer'     
WITH PRIVATE KEY (FILE = 'C:\tmp\LCMS\certificate_TDE_Test_Key.pvk', 
DECRYPTION BY PASSWORD = 'Passsword12#')
6.After this step restoring backup does not have any error and all data was readable.
7.But the funny thing is that removing encryption simply and taking new backup and restoring it on final server (Final Server) does not work and gives the following error The file "mydb_log" failed to initialize correctly. Examine the error logs for more details.
8.The correct way of removing encryption from UAT is to remove all signs like below step by step and from bottom to top
    USE master
    ALTER DATABASE mydb SET ENCRYPTION OFF
    USE mydb
    DROP DATABASE ENCRYPTION KEY 
    USE master
    DROP CERTIFICATE vestacert2 
    DROP MASTER KEY
9.Now create a new backup from UAT server and restore it to final server.