Building A Large Scalable System


Most applications are developed using three tier architecture which consists of presentation layer, business logic layer, and data access layer. The presentation layer contains aspx, html or jsp page and business layer contains services like WCF, Web API or web services and data layer contains code to communicate to databases where the actual data resides.

This is how the application architecture looks.

How scalability comes into picture

The web application is up and running, users are happy and business getting revenue —  everything goes fine when the business is very small, now gradually the users’ level increases to the applications and the traffic to the applications became huge and web applications became very slow. When the application is very slow no user is interested in using the applications and the business loses revenue and reputation, and losing the business is losing everything.

This is where the scalability comes into the  picturel how to extend the system to serve significantly high volumes of users. Scalability is not the same as performance scalability is not code issue, it is how we need  to extend the application in multiple servers, multiple database, multiple location to server millions users.

When designing any system there are some key considerations which developers and architects should keep in mind. These are:

  • Scalability – The number of users system/ session/transaction/ operations it can support.
  • Performance – The system should use optimal utilization of resources like CPU, Thread, memory.
  • Responsiveness – The time taken per operation should be less. Example: User should not wait a long time to get the information from server.  Example -If we are booking tickets and it is very slow in doing a transactions we think  what a bad application.
  • Availability – The system should be the available at any given point in time. If not fully, it should be partially available ensuring that end users think the system is available.
  • Downtime Impact – The impact of the downtime of a server/service/resource – number of users, type of impact should be very minimal.
  • Cost – Cost for the system should be within the budget. More cost of the system does not give profit to the organization.
  • Maintenance Effort- System must have the very litlle maintenance effort. For example if the system is developed now it must have the features to extend or enhance the feature very easily.

There are some key considerations when designing scalable systems, these considerations are:

  • Vertical scaling
  • Horizontal Scaling
  • Horizontal Partitioning
  • Vertical Partitioning
  • Load balancing
  • Master-Slave setup
  • Distributed Caching
  • Use NOSQL
  • Incremental model development

Vertical scaling

Vertical scaling means adding hardware to the system i.e., RAM, CPU, processors into the existing machine to increase the processing time in the server. In a virtual machine set up it can be configured virtually instead of adding real physical machines. When increasing the hardware resources we should not change the number of nodes. This is referred to as “Scaling up” the Server.

As an advantage it is simple to implement but as a disadvantage how much hardware we can add to it has a finite limit. Hardware does not scale linearly (diminishing returns for each incremental unit). Adding hardware requires downtime.

Horizontal Scaling

The horizontal scaling means adding more web servers through Load Balancing to the system similar to earlier one. Now multiple machines work together to give quick response and availability of any system including database. After adding multiple machines now we have multiple machines to distribute the work load from time to time.

Each machine works as a different node which is identical in nature here and sometimes multiple nodes are treated as a cluster of servers. This is referred to as “Scaling Out” of the web server.

As an advantage we have multiple servers which can distribute the user traffic, now the synchronization of codes, session management, caching data should be in a proper way to the user.

Horizontal Partitioning

Horizontal partitioning partitions or segments rows into multiple tables with the same columns.

E.g. of horizontal partitioning :- customers with city ABC codes are stored in Customers ABC, while customers with customer city XYZ are stored in Customers XYZ. Here the two partitioning tables can be ABC and XYZ .

This way Database partitioning by value from the beginning into your design is a good approach.

Vertical Partitioning

The term Vertical Partitioning denotes increasing the number of nodes by distributing the tasks/functions. Each node (or cluster) performs separate tasks  different from the other. Vertical Partitioning can be performed at various layers,this may be at application /server / Data / Hardware levels. These are Task-based specialization, reduces context switching and we can do the optimization and tuning as much possible. Instead of putting everything into one box put  it into different boxes. In Database tables consider we have customer, orders, customer order, and order status in one DB, we can move some of these into another DB.

Load balancing

Load balancing is the process of serving a user his request towards one server that is part of a server farm. In this way the user load is distributed amongst several servers.

There are two kinds of load balancers.  (Hardware Load balancers and Software Load balancers). Hardware Load balancers are faster whereas Software Load balancers are more customizable.

We should keep in mind when coding for a system that has load balancing.

Do not program depending on a cache or session data that is written to the server or local file system of the server, do not rely on the file system at all.

Let us assume we have different servers and user1 is hitting the request and this request is served by server1 and  server1 goes down, now the load balancer will redirect the request to server2 but how the session data in server1 will be passed to server2. This issue is called a sticky session.

For proper session management we should use a centralized session management where multiple servers can read session data .SQL server as session state mode is used  for most of .NET based web applications in a large systems.

Scaling from a single DB server to a Master-Slave setup

Isolating the Database based on the purpose gives better performance in scalable systems.

As an example earlier we had one database which was used for getting different SSRS reports and crystal reports, same was used for different SQL Jobs, Windows Services, Email Message communication, all transaction data etc. We moved to different Master-slave databases for better results. All transaction data as written are sent to a single master who replicates the data to multiple slave nodes. Almost all the RDBMS MySQL, MSSQL and Oracle support native replication.


Effective caching is a key to performance in any distributed systems. To make a highly scalable system the caching should be a distributed caching which may span multiple servers. The cache data may grow from time to time but there should be an effective way to handle it.

NCache/ Velocity/AppFabric are some of the good distributed caching tools options in a .NET large scale application. The cache information is stored as a cluster of nodes and all have the feature of replicating and locating information for faster access.


NoSQL databases give advantages with scalability, availability, and zero downtime. They store the data in multiple file nodes which can be easily accessed and replicated as needed.

Some of the NoSQL tools are Cassandra, MongoDB, and CouchDB etc.

Incremental model development

Inspect the issues, Change as needed and adopt this is the key for building of a scalable system.

Write automated builds using Jenkin, Team city or TFS to make a build automated with 100% test coverages. Proper testing to  changes in Database, codes, configurations in the test or UAT environment is needed before pushing the code into production. From day one of development designer/architects/developers should think of developing loosely coupled modules. Choosing a proper platform and language considerations are also a big factor for building large systems.

As Applications need be able to scale in distributed environments with a number of servers these incremental model development steps help to a large extent.

We cannot bring scalable systems in a single day as “Rome was not build in a day,” it is a collaboration and  great team work among developers, architects, QA, infrastructure, and dev ops to build a highly scalable systems.

Posted in Uncategorized | Leave a comment

History of Kanamoji (Katakana and Hiragana)

Japanese language has three different alphabets; Kanji, Katakana and Hiragana. Kanamoji is a generic name for the character of Hiragana and Katakana. It is equivalent to the English alphabet and the kana character has the 46 standard phonetic characters.

     Around 500 AD, the basis of modern Japanese Kanji developed after Japan had a culture contact with Chinese. The Chinese character in that time was called “Manyogana(万葉仮名)“.However, because Manyogana is too difficult, during the Heian Period (794 – 1192), manyogana was adapted to create a Japanese script that was partly syllabic (characters based on sounds; hiragana and katakana) and partly logographic (characters based on concepts; kanji).

      Unlike Katakana which took one part from the Kanji, Hiragana is the simplified version of Kanji.  You can see how to create both characters from Kanji in the table below (Read from right to left).

Posted in Uncategorized | Leave a comment

What are the differences between “git commit” and “git push”?


Posted in ASP.NET MVC, C#, Knowledge, Problem solving, Programming, Uncategorized | Leave a comment

CSS center display inline block?

I have a working code here: (you might need to make the result window bigger to see the align center effect)


The code works fine but I don’t like to have display: table;. It’s the only way I could make the wrap-class align center. I think it would be better if there was a way to use display: block; or display: inline-block;. Is it possible to solve the align center another way?

Adding a fixed with to the container is not an option for me.

The accepted solution wouldn’t work for me as I need a child element with display: inline-blockto be both horizontally and vertically centered within a full width parent.

I used Flexbox’s justify-content and align-items properties, which respectively allow you to center elements horizontally and vertically. By setting both to center on the parent, the child element (or even multiple elements elements!) will be perfectly in the middle.

This solution does not require fixed width, which would have been unsuitable for me as my button’s text will change.

Here is a CodePen demo and a snippet of the relevant code below

.parent {
  display: flex;
  justify-content: center;
  align-items: center;

.child {
  display: inline-block;

Posted in Uncategorized | Leave a comment

What is the best way to paginate results in SQL Server

What is the best way (performance wise) to paginate results in SQL Server 2000, 2005, 2008, 2012 if you also want to get the total number of results (before paginating)?

Getting the total number of results and paginating are two different operations. For the sake of this example, let’s assume that the query you’re dealing with is

SELECT * FROM Orders WHERE OrderDate >= ‘1980-01-01’ ORDER BY OrderDate
In this case, you would determine the total number of results using:

SELECT COUNT(*) FROM Orders WHERE OrderDate >= ‘1980-01-01’
…which may seem inefficient, but is actually pretty performant, assuming all indexes etc. are properly set up.

Next, to get actual results back in a paged fashion, the following query would be most efficient:

FROM Orders
WHERE OrderDate >= ‘1980-01-01’
) AS RowConstrainedResult
WHERE RowNum >= 1
AND RowNum 50 AND RowNumber = ‘1980-01-01’ ORDER BY OrderDate


FROM Orders t
INNER JOIN @orderedKeys o ON o.TableKey = t.ID
WHERE o.rownum >= @firstRecord
ORDER BY o.rownum


Posted in C#, Database, Knowledge, Problem solving, Programming, Uncategorized | Leave a comment

Coaching Skills

Target Audience
This workshop is developed for those who wish to help trainees effectively apply skills learned in training courses at their workplace, using a structured approach to learning transfer.
Managers with direct responsibility for training programs and administrators with indirect responsibility for training may also find this workshop useful.
None. However, Business Edge® Training of Trainers (ToT): Facilitation Skills  and Training Needs Analysis (TNA) courses, or equivalents are excellent complements to this workshop.
Course Objectives
Upon completion of this course, you should be able to:

  • Explain purpose and benefits of coaching
  • Review the action planning context for coaching
  • Describe 5 coaching skills
  • Use effective listening techniques with a coachee
  • Explain the four dimensions of how to build rapport with a coachee
  • Apply the 4P model to resolve problems and issues arising with a coachee
  • Give feedback to a coachee in a constructive manner
  • Explain how to facilitate and support a coachee’s learning
  • Demonstrate techniques of each coaching skill
  • Apply coaching skills to transfer of learning from the classroom to the workplace: Initiating, monitoring and concluding action plans
Classroom-based course
The workshop uses an interactive methodology in order to engage participants actively in the learning process. During the course, your trainer will act as both instructor and facilitator, using a variety of learning methods to help you and your fellow participants share experiences and learn through participation in activities such as group discussions, case studies, role-playing, and games. At the same time, you will be guided to apply skills learned to client examples of your own choosing.
Not available at this time
  • Introduction to the workshop
    • Overview of coaching: What and why
  • Coaching and action planning
    • The business case for training transfer
    • Requirements for successful training transfer
    • Transfer methods
    • The Business Edge® action planner
  • Five coaching competencies
    • 1: Questioning and listening (LACE)
    • 2: Building rapport (RITE)
    • 3: Observing and analyzing (4P’s)
    • 4: Providing feedback (FEED)
    • 5: Facilitating learning (STAIR)
    • Putting it all together
  • Concluding remarks
Course Duration
2 days (depending on number of participants attending)
Posted in Education and Training, Knowledge, Problem solving, Uncategorized | Leave a comment

GLOSS, EASE, FEED and OFF stand for?

The FARMERS School is a ToT platform which offers 16 modular courses on rice-based integrated farming and marketing to boost the training capacities of agricultural extension workers, local farmer technicians, and farmer leaders. Each module was developed by assigned partner agencies as expert contribution to the project. The development of the ToT modules was based on the adult learning framework of the International Finance Corporation (IFC) as part of the private sector’s contribution to the project.
IFC’s adult learning approach builds on the learning cycle of adult learners as crucial aspects in the training to optimize learning. It offers a facilitation guide in conducting training or a meeting based on the four-quadrant learning cycle – GLOSS, EASE, FEED, and OFF. GLOSS stands for Get attention, Link topics to experience or knowledge, learning Outcomes, Structure or outline of the topic, and Stimulate interest; EASE, Explain, Activity, Summary, and Examples; FEED, Frame positive intent, Evidence, Effect, and Diagnosis; and OFF, review Outcomes, Feedback, and Future link.

Posted in Education and Training, Knowledge, Uncategorized | 1 Comment