Home » Blog » Let’s give examples of unoptimized and optimized code

Let’s give examples of unoptimized and optimized code

Unoptimized code – undefined number of database queries

 

For an online store! this is a huge middle east mobile number list load when the code makes N requests to the database! where N is the number of products.

 

Optimized code – one query

 

Here one query to the database what are the differences between safe is made instead of hundreds. As a result! the server works more freely and the database will not “fall” from such a query.

 

How to ensure fault tolerance

First! let’s look at what fault tolerance is. Fault tolerance is the ability of a system to continue operating in the event of failure of individual components. In the context of an online store! this means that regardless of the load! server failure! database problems! or network connection failure! the platform remains operational and products are available to customers.

 

Fault tolerance is important for buy lead online stores because server downtime = lost money. If a store is down for 30 minutes during a sale! the losses are in the millions.

 

Now let’s look at when and what mechanisms create fault tolerance.

 

  1. Cloud technologies

Cloud solutions are suitable where flexible scaling of resources is required. They are useful in situations where:

 

Sudden surges in load occur! such as during sales! promotions and seasonal events.

Traffic is unpredictable. Advertising is more powerful than expected and servers can’t handle the load.

The business is growing rapidly and there is not enough capacity without a complete overhaul of the infrastructure.

Cloud providers (Yandex Cloud! VK Cloud! MTS Cloud) automatically scale server resources. If a site suddenly gets +50% of users! the system will add new servers without administrator intervention. When the load decreases! excess capacity is turned off to optimize costs.

Scroll to Top