Posts

Generating unique string in C#

One of the solution in C# that generates unique string.  class UniqueString { private static readonly Random random = new Random(); private static readonly object syncLock = new object(); // Map to store 62 possible characters   private static readonly char[] charMap = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".ToCharArray(); /// <summary> /// Generates unique string /// </summary> /// <param name="strLen">Length of the string.</param> /// <returns>Unique string of specified length.</returns> public static string GenerateUniqueString(int strLen) { if (strLen <= 0) { return null; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < strLen; i++) { lock (syncLock) // synchronize { _ = sb.Append(charMap[random.Next(62)]); } } return sb.ToString(); } public static void Main() { // generate 10 character string Console...

SQL Query Optimization

SQL query optimization is bare minimum  requirement when working with queries. Need to look for Indexes, Execution plan etc. Few links that help to understand query optimization. SQL Query Optimization    query-processing-architecture-guide optimize-query-performance-sql-server

Internet Information Services (IIS) on Load Balancer and shared folder for files

Image
In the load balancer setup for windows Internet Information Services (IIS) if shared folder is used for files to upload and download create virtual directory under application folder with alias as Upload(whatever you prefer) and physical path as \\sharedfilefolder\files$\AppFiles\ where files is the shared folder on sharedfilefolder and AppFiles is subfolder in the files folder Have the same setup on each server and the application works fine with upload and download of files from load balancer URL.

Scalable architecture

Image
What is scalable architecture? Systems are often designed based on initial number of users in consideration. Few users to millions of users may be using the system. But there is possibility over the period of time the number may go up or usage may be high some times during the day or some days in a week or few months in  a year.  To support such usage the system should be designed to sustain any kind of usage or load. Both hardware and software should able to handle any increase in work loads. That is the core of scalable architecture. Vertical scaling(scale-up_ is increasing the hardware like CPU power, memory etc to handle the workload. Horizontal scaling(scale-out) is adding more servers with similar hardware configuration or distributing different tasks to different servers minimizing the impact on one or few servers. The choice is always depending on the application requirements and no system is designed the same way. Start everything in one  Single Server for exampl...