Follow us

Design Scalable C# Code/Application

Hi,

Bleow are some ground principles, I belive we must take care for designing scalable C# code/application.

  1. Cache everything, always. Caches are essentially storages of precomputed results that we use to avoid computing the results over and over again. Like .net inmemory cache or distributed cash like Radish or Memcached.
  2. Provide as fresh as needed data. Depending on your application, users might not need the very freshest data right away. Eventual consistency leads to much better availability.
  3. API first (designing micro - services) and can host to multiple servers or may be docker/container.
  4. Asynchronous rather than synchronous.
  5. Strive for statelessness. Like AWS Lambda.
  6. Compress the data you send over the network. Compression and decompression of data between clients and servers. You can enable compression per request/response in code and even in IIS level also by enabling static and dynamic compression(GZIP)
  7. Use multi-threading and connection pool.
  8. Use bundling(less no. of files to load) and minification(minimum size of the file to load) for CSS, JS.
  9. Design for maintenance and automation.
  10. Avoid the single point of failure. We can never just have one of anything, we should always assume and design for having at least two of everything. This adds costs in terms of additional operational effort and complexity. Like having multiple web server over load balancer.
  11. Scale horizontally, not vertically. There is a limit to how large a single server can be, both for physical and virtual machines. There are limits to how well a system can scale horizontally, too. The cost of (vertically) upgrading a server increases exponentially whereas the cost of (horizontally) adding yet another (commodity) server increases linearly.
  12. At code level -
    • Use proper garbage collection to destroy the objects specially unmanaged like DB connection, file system IO etc,
    • Try avoid using loop
    • Use less static keywords
    • Do not keep unused variables

 

Categories/Tags: Scalable

Recent Articles

1

AWS Saving Plan - Cost optimization tips

2
3

AWS RDS Key Concepts & Why you should use it?

4
5

Open-Search/Kibana - Multi Tenancy Setup

See All Articles