try...catch...finally...bloggg....: June 2004

try...catch...finally...bloggg....

Wednesday, June 23, 2004

Caching Basics in .NET

Caching in .NET

Proactive Loading - Load at the time of application startup
Reactive Loading - Load when the data is accessed first

Caching addresses Performance, scalability and Availability.

When considering data to be cached think of these two parameters
1. Likelihood of changes.
2. Relevance of changes.

ASP.NET Caching
Cache is related with the Application object. Cache is recreated everytime the application restarts. The main difference between them is the dependencies and the expiration policy support in the Cache Object.

Dependencies provided are
1. File Based Dependency.
2. Key Based Dependency.
3. Time Based Expiration. - Absolute Expiration, Sliding Expiration.

Cache Callback can be used to reinsert the same item or get an update of the removed item or do nothing.

Page output caching, Page fragment caching.
VaryByParam
VaryByHeader
VaryByCustom
VaryByControl

Cache can be accessed outside the context of the request using
HttpRuntime.Cache.

Remoting Singleton Caching
This stores the cache information between different client invokations. you need to make sure that the remote cache object is not garbage collected. This method has poor performance and
scalability.

Memory Mapped File Caching
Memory-mapped file caches are not easy to implement because they require the use of complex Win32® application programming interface (API) calls. The .NET Framework does not support memory-mapped files, so any implementations of a memory-mapped file cache run as unmanaged code and do not benefit from any .NET Framework features, including memory management features, such as garbage collection, and security features, such as code access security

SQL server caching
SQL Server caching is easy to implement by using ADO.NET and the .NET Framework, and it provides a common development model to use with your existing data access components. It provides a robust security model that includes user authentication and authorization and can easily be configured to work across a Web farm using SQL Server replication.
Because the cache service needs to access SQL Server over a network and the data is retrieved using database queries, the data access is relatively slow. Carefully compare the cost of recreating the data versus retrieving it from the database.

Client side caching
1. HiddenFields
2. ViewState
3. Cookies.
4. QueryString
5. Hidden Frames.

Implement thread safety in when using cache using the ReaderWriterLock.

Normalizing cached data means storing the data in the format
in which the clients use it. This avoids repeated formatting and
serialization/deserialization calls.

Thursday, June 17, 2004

Replication in SQLServer

Replication

Database replication is different from file replication, which essentially copies files. Database-replication products log selected database transactions to a set of internal replication-management tables. The software then periodically checks these tables for updated data and moves the data from the source to the target systems while guaranteeing data coherency and consistency.

Replication improves scalability. The replicated server can be used to support the original server for reporting purposes sharing the load.
Database replication can also supplement your disaster-recovery plans by duplicating the data from a local database server to a remote database server.

Replication is the process whereby data is copied between databases on the same server or different servers connected by LANs, WANs, or the Internet.Microsoft SQL Server replication uses a publisher, distributor and subscriber metaphor.

Replication topologies
Microsoft SQL Server supports the following replication topologies:
Central publisher
Central subscriber
Central publisher with remote distributor
Central distributor
Publishing subscriber

Replication Types
Microsoft SQL Server 7.0/2000 supports the following replication types:
Snapshot
Transactional
Merge

Snapshot replication is the simplest type of replication. With this kind of replication, all replicated data (replica) will be copied from the Publisher database to the Subscriber's/Subscribers' database(s) on a periodic basis. Snapshot replication is best used as a method for replicating data that changes infrequently and when the size of replicated data is not very large.

Transactional replication, SQL Server captures all changes that were made in an article and stores INSERT, UPDATE, and DELETE statements in the distribution database. These changes are then sent to subscribers from the distribution database and applied in the same order. Transactional replication is best used when the replicated data changes frequently or when the size of replicated data is not small and is not necessary to support autonomous changes of the replicated data on the Publisher and on the Subscriber.

Merge replication is the most difficult replication type. It makes possible autonomous changes to replicated data on the Publisher and on the Subscriber. With Merge replication, SQL Server captures all incremental data changes in the source and in the target databases, and reconciles conflicts according to rules you configure or using a custom resolver you create. Merge replication is best used when you want to support autonomous changes of the replicated data on the Publisher and on the Subscriber.

Replication Agents
Microsoft SQL Server 7.0/2000 supports the following replication agents:
Snapshot Agent
Log Reader Agent
Distribution Agent
Merge Agent

SQL Server Replication The above link has information
related to the different SQL server replication topologies, Replication types and replication agents.

Basics about RAID

RAID

This is a quick premiere about the RAID(Redundant array of inexpensive disks). The knowledge is quite useful if you ever
have to choose some hardware for hosting critical applications.

General RAID Concepts.

Mirroring - Same data is written to two different disks using the same
controller.

Duplexing - Same data written to two different disks using differnt controllers.

Striping - Chopping up a single file among different disks to improve the read access time as different disks can be accessed parallely improving performance. Doesnt add any redundancy to the data so doesnt improve data protection.

Parity - Take N pieces of the data calculate N + 1 piece by XORing the data. If one of the N + 1 pieces are missing we can find that using the rest N. This is the general concept of parity because of XOR.
Advantages - doesnt waste 50% storage (N-1/N where N is the total number of disks in the array is the storage efficiency). Disadvantages - lots of computation use hardware controller.

RAID 0 - Striping without parity - No data redundancy - So no
way to restore if disk failed - Good Read / Write speeds.

RAID 1 - Mirroring - High Overhead cost because only 50% of the
storage is used and the other 50% is duplicate data - No performance improvement like striping - Write slower as has to write
the duplicate copy - read is improved

RAID 2 - Bit-level striping with Hamming code ECC
Read Fair / Write Poor.

RAID 3 - Byte-level striping with dedicated parity.
Read Good / Write Poor.

RAID 4 - Block-level striping with dedicated parity
Read Very Good / Write poor.

RAID 5 - Block-level striping with distributed parity.
Read Very Good / Write Fair

RAID 6 - Block-level striping with dual distributed parity.
Read Very Good/ Write Poor Can tolerate failure of two disks
in the array due to redundant second parity.

RAID 0+1/ 1+0 - Stripping with Mirroring/ Mirroring with Stripping

Thursday, June 10, 2004

DotNet Security Book

DotNet Security

Wednesday, June 09, 2004

CMM links

People Capability Maturity Model - Version 2

CMMI

Tuesday, June 08, 2004

Java language specification

Java language specification

Monday, June 07, 2004

foreword

This is my technical blog and I ramble about the technologies .NET, Java ...


·