Improving the Performance of Web API

Taking notes from this blog: https://www.c-sharpcorner.com/article/important-steps-to-increasing-web-api-performance/

Thread Usage

Parallel Programming - Executing a collection of tasks at the same time in order to maximum thread usage.

Asynchronous Programming - Asynchronous programming indicates to the program when it needs a thread to execute, and gives it back when finished or waiting. You may do this so that long operations do not block the thread.

Data Transfer and Serialization

Compress the results of Web API - You may enable some settings on IIS or use a different protocol to decrease the transfer size.

Using a high speed serializer - In order to transform your .NET classes to readable data, it must perform serialization on your data to convert it to a form readable over the web. There are special performance libraries such as JSON.net or others like ProtoBuf that are faster than then builtin serializer.

Data

Caching - If there is a chance that you don't have to recompute data, it is best to store it in a high accessible place.

Creating the Proper Database Schema - It's best to cure the root problem if possible if your schema becomes too complex and accessing your data becomes slow. This may be hard if your system is already in production, so take extra caution to do the work up front of designing a good schema.

Utilize Client-Side Processing

Client-Side Validation - When possible, it is best to do as much processing on the client side where your relying on the computation power of external machines which helps with scale - to a point that it doesn't affect the performance of the UI/UX. Making sure to do proper validation will save precious requests to your backend.

Environment

Load Balancing - Design your system to be stateless so that it can be load balanced so new machines can be added when demand is high.

Network Evaluation - Evaluate your network for potential bottlenecks where calls might be piling up and see if you can optimize that path. A call not made is the fastest one.

Comments

Popular posts from this blog

Uncle Bob's Clean Architecture

C4 Model: Describing Software Architecture

Running RabbitMQ with Docker