Clever Engineer

Clever Engineer

Share

We teach computer Science

18/09/2025

๐๐จ๐ฅ๐ฒ๐ฆ๐จ๐ซ๐ฉ๐ก๐ข๐ฌ๐ฆ ๐„๐ฑ๐ฉ๐ฅ๐š๐ข๐ง๐ž๐

Polymorphism means โ€œmany forms.โ€ In programming, it allows the same method name or interface to produce different behaviors depending on the object that uses it.

It helps us write flexible, reusable, and extensible codeโ€”where the general structure stays the same, but the specific behavior is decided either at compile-time or runtime.

Real-World Analogy

Think of the word โ€œplay.โ€

A musician plays an instrument.

A child plays with toys.

An athlete plays football.

The word โ€œplayโ€ is the same, but its meaning changes depending on the context.
Thatโ€™s polymorphismโ€”the same action name triggers different results depending on whoโ€™s performing it.

Why Polymorphism Matters

Loose Coupling โ†’ You work with general types (interfaces or base classes) instead of specific classes.

Flexibility โ†’ You can add new behaviors without rewriting old code.

Scalability โ†’ Your system can grow to handle new cases smoothly.

Extensibility โ†’ You can โ€œplug inโ€ new implementations without touching the core logic.

There are three main Type of Polymorphism

REAM MORE ALSO DON't FORGET TO LIKE THIS PAGE
https://open.substack.com/pub/cleverengineer/p/polymorphism-explained?r=1nba3w&utm_campaign=post&utm_medium=web&showWelcomeOnShare=true

16/09/2025

๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐—ณ๐—ฎ๐—ฐ๐—ฒ๐˜€ ๐—˜๐˜…๐—ฝ๐—น๐—ฎ๐—ถ๐—ป

In object-oriented design, interfaces help us build flexible, testable, and loosely connected systems. They act like contracts: they define what must be done, but not how it should be done.

1. What is an Interface?

An interface lists method names that any class must provide.

It doesnโ€™t care about the internal logic, only the structure.

Analogy:

Think of a remote control:

play()

pause()

volumeUp()

powerOff()

No matter if it controls a TV, a speaker, or a projector โ€” the buttons stay the same, but the actions behind them differ.

Thatโ€™s exactly how interfaces work in code.

2. Why Use Interfaces?

Define behavior, not details โ†’ They say what should happen, but not how.

Enable polymorphism โ†’ Different classes can follow the same interface in their own way.

Promote decoupling โ†’ Code depends on the interface, not the concrete class, so changes in implementation donโ€™t break everything else.

ReadMore and don't forget to subscribe to the Clever Engineer News Letter the mission is to help 10,000 developers get better every day.

https://shorturl.at/CiHdZ

14/09/2025

๐—˜๐—ป๐—ฐ๐—ฎ๐—ฝ๐˜€๐˜‚๐—น๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—˜๐˜…๐—ฝ๐—น๐—ฎ๐—ถ๐—ป๐—ฒ๐—ฑ

Encapsulation is one of the core pillars of object-oriented programming (OOP). It refers to the concept of combining data (fields) and the functions that work on that data (methods) into a single unit

Real-World Analogy

Imagine a vending machine. You donโ€™t open it up to grab snacks or fiddle with the money system inside.

Instead, you use the buttons and coin slot interface.

The machine gives you limited, predefined options: insert money, select an item, get your snack.

You never see how the inventory is tracked or how the change is calculated.

Internally, the company may redesign how the machine handles inventory or payments, but your experience as the user stays consistent.

Also don't forget to follow this page

Serious about your Software Engineering growth ๐Ÿ‘‡๐Ÿพ

READ MORE

https://open.substack.com/pub/cleverengineer/p/encapsulation-explained?r=1nba3w&utm_campaign=post&utm_medium=web&showWelcomeOnShare=true

09/09/2025

๐—จ๐—ป๐—ฑ๐—ฒ๐—ฟ๐˜€๐˜๐—ฎ๐—ป๐—ฑ๐—ถ๐—ป๐—ด ๐—˜๐—ป๐˜‚๐—บ๐˜€

Enumerations, commonly called enums, are a practical yet often overlooked feature in object-oriented programming.

๐—ช๐—ต๐—ฎ๐˜ ๐—˜๐˜…๐—ฎ๐—ฐ๐˜๐—น๐˜† ๐—ถ๐˜€ ๐—ฎ๐—ป ๐—˜๐—ป๐˜‚๐—บ?

An enum is a specialized data type that groups together a predefined list of constant values under a single label. Unlike raw integers or plain strings, enums enforce type safety โ€” meaning you canโ€™t assign an arbitrary value to a variable that expects a specific enum type.

Enums are most useful when a variable should only accept one choice out of a restricted set.

๐—˜๐˜ƒ๐—ฒ๐—ฟ๐˜†๐—ฑ๐—ฎ๐˜† ๐—˜๐˜…๐—ฎ๐—บ๐—ฝ๐—น๐—ฒ๐˜€ ๐—ผ๐—ณ ๐—˜๐—ป๐˜‚๐—บ๐˜€

Payment Methods โ†’ CREDIT_CARD, PAYPAL, BANK_TRANSFER

Seasons โ†’ SPRING, SUMMER, AUTUMN, WINTER

Access Levels โ†’ GUEST, USER, MODERATOR, ADMIN

Traffic Light Signals โ†’ RED, YELLOW, GREEN

Using enums eliminates โ€œmagic valuesโ€ (hardcoded strings or numbers), makes your intent clearer, gives compiler checks and IDE autocomplete support, and reduces the likelihood of accidental mistakes.

Don't forget to follow Clever Engineer

๐—ฅ๐—˜๐—”๐—— ๐— ๐—ข๐—ฅ๐—˜

https://tinyurl.com/29uf8y6j

07/09/2025

Object-Oriented Programming (OOP) is a programming paradigm(pattern or style of doing thing) that organizes code around objects rather than functions. It models real-world entities as objects that contain both data (attributes) and code (methods) that operates on that data.

1. What is a Class?

A class is essentially a blueprint or template. It defines the attributes (data) and methods (behavior) that its objects will have.

Imagine you want to build several houses in an estate, and you want all of them to look alike. Instead of constructing a few houses randomly, you would first create a blueprint. This blueprint ensures that every house follows the same design.

In the same way, a Class in programming acts as a blueprint. It defines the structure and behavior that multiple Objects will share. If you want to create many objects, you first need a class to guide their creation

Key points about a class:

Groups related data and behavior together.

Attributes are represented as variables.

Methods (functions inside a class) act on that data.

2. What is an Object?

An object is an instance of a class. It takes the abstract design of a class and turns it into something concrete. Each object has its own state (its own copy of attributes) and can perform the actions defined in the class.

Want to learn coding don't forget to subscribe to The Clever Engineer Notebook

Read more
https://shorturl.at/70qQi

05/09/2025

๐–๐ก๐š๐ญ ๐ข๐ฌ ๐‹๐จ๐ฐ-๐‹๐ž๐ฏ๐ž๐ฅ ๐ƒ๐ž๐ฌ๐ข๐ ๐ง (๐‹๐‹๐ƒ)?

In software engineering, Low-Level Design (LLD) is where abstract concepts are turned into practical, working blueprints. Itโ€™s the step where a High-Level Design (HLD) is broken down into detailed class diagrams, interfaces, object relationships, and design patterns.

What LLD Really Means

LLD answers the question: โ€œHow exactly will we implement this?

HLD says: โ€œWe need a Ride-Sharing Service.โ€

LLD says: โ€œWeโ€™ll create an interface RideAllocator with implementations like NearestDriverAllocator and CheapestDriverAllocator, both coordinated by a RideManager.โ€

LLD zooms in on the building blocks of your system. It ensures the software is modular, extendable, testable, and understandable. Itโ€™s not just about making something workโ€”itโ€™s about designing systems that can adapt and grow.

Core Components of LLD

1. Classes and Objects

This is where design begins: defining the key entities.

Ask yourself:

What classes represent the main concepts?

What responsibilities do they have?

What data do they hold?

What actions do they perform?

Example: In a library management system, we might define:

Book โ€“ stores title, author, and availability

Member โ€“ borrows and returns books

Librarian โ€“ manages inventory

Loan โ€“ represents the borrowing transaction

2. Interfaces and Abstractions

Interfaces define contracts between components. They ensure loose coupling so implementations can change without breaking the system.

Ask yourself:

What should a class expose to the outside?

Which details should remain hidden?

What can be abstracted behind an interface?

Example: A SearchEngine interface could have multiple implementations:

ElasticSearchEngine

SolrSearchEngine

InMemorySearchEngine

The system depends only on the SearchEngine interface, not on the concrete choice.

3. Relationships Between Classes

Classes interact with each other in structured ways. LLD defines these relationships clearly:

Association โ€“ a general โ€œuses-aโ€ relationship

Composition โ€“ strong โ€œhas-aโ€ (lifespan tied)

Aggregation โ€“ weaker โ€œhas-aโ€ (independent lifespan)

Inheritance โ€“ โ€œis-aโ€ relationship for shared behavior

Example:

A Library has many Books (composition).

A Member can borrow multiple Books (one-to-many).

A Librarian manages several Members (aggregation).

4. Method Signatures

Once the structure is clear, you define operations.

Ask:

What methods should each class have?

What parameters and return types are needed?

Should they be synchronous or asynchronous?

What exceptions could they throw?

Bad: void doTask(String s)Better: void borrowBook(Book book, Member member)

The improved method is clearer, domain-specific, and more extensible.

Read More here

https://url-shortener.me/47AB

01/08/2025

๐‡๐ž๐ซ๐žโ€™๐ฌ ๐š ๐›๐ž๐š๐ฎ๐ญ๐ข๐Ÿ๐ฎ๐ฅ ๐ช๐ฎ๐ž๐ฌ๐ญ๐ข๐จ๐ง ๐Ÿ๐จ๐ซ ๐ฒ๐จ๐ฎ:

You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise).

You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.

Well, when I saw this question, I knew the optimal solution right out of the box because I have a bit of a mathematics background.
Transpose the matrix, then reverse it.

Transposing a matrix means making each row in the matrix its column and each column its row. It turns out thereโ€™s a constant when we transpose the matrix. Take, for example, the following matrix:

1 2 3
4 5 6
7 8 9
Thereโ€™s a constant diagonal of 1, 5, 9. Letโ€™s transpose this matrix, and I will discuss why this is, in fact, important to know:

1 4 7
2 5 8
3 6 9

If we move along this diagonal and swap opposite elements, then we have transposed the matrix: [0][1] = [1][0], [0][2] = [2][0], [1][2] = [2][1]

and the last part we can reverse every row
7 4 1
8 5 2
9 6 3

here is the question for you
https://shorturl.at/FKwBo

Photos from Clever Engineer's post 30/07/2025

๐“๐ก๐ข๐ฌ ๐ข๐ฌ ๐š ๐›๐ž๐š๐ฎ๐ญ๐ข๐Ÿ๐ฎ๐ฅ ๐๐ฎ๐ž๐ฌ๐ญ๐ข๐จ๐ง

Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.

๐„๐ฑ๐š๐ฆ๐ฉ๐ฅ๐ž ๐Ÿ:

Input: nums = [3,0,1]

Output: 2

๐„๐ฑ๐ฉ๐ฅ๐š๐ง๐š๐ญ๐ข๐จ๐ง:

n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums.

๐ˆ๐ง๐ญ๐ฎ๐ข๐ญ๐ข๐จ๐ง

There are actually two ways to solve this problem either you use logic cancellation or the sum of real numbers.

๐€๐ฉ๐ฉ๐ซ๐จ๐š๐œ๐ก

The Approach for the sum of real number is given as follow we know that for any real number you can find the sum by saying n(n+1)/2 this is a formular in arthmentic progression if you want the sum form 1 to 5 5(5+1)/2 = 15 it equal to 1+2+3+4+5 = 15

we can compute the summation of the array and substract the actual sum form the expected sum the result is the missing number.

Complexity

Time complexity:

O(n)

Space complexity:

O(1)

๐€๐ฉ๐ฉ๐ซ๐จ๐š๐œ๐ก ๐๐ฎ๐ฆ๐›๐ž๐ซ ๐Ÿ

The second is using the theory of logic

the following are true for xor

a ^ a = 0
a ^ 0 = a

equip with this knowledge we can Try to generate two group and cancel out where needed

Group 1 , 0, 1, 2, 3 or (0 ^ 1 ^ 2 ^ 3)

Group 2, 3, 0, 1 or (3 ^ 0 ^ 1)

we can combine them

(0 ^ 1 ^ 2 ^ 3) ^ (3 ^ 0 ^ 1)

let combine like term

0 ^ 0 ^ 1 ^ 1 ^ 3 ^ 3 ^ 2 = 2

The following two solution have the same time and space complexity

The actual solution is here

https://shorturl.at/XJU06

Remember it good to be smart but what even better is being consistent. Stay humble stay loyal to your grind

30/09/2024

Try out our new Mobile app that help smoothing payment of Events

Version with updated instructions

Join the Tick8 Plus Beta Testing Program!

Weโ€™re excited to announce the beta testing program for Tick8 Plus, the cashless event ticketing platform developed by BITS. We seek feedback from passionate users to help us improve the attendee and organizer mobile apps. Testing is currently limited to Android (APK), and your feedback will be invaluable in shaping the final version of our platform.

By joining, youโ€™ll be among the first to experience Tick8 Plus' seamless ticket purchasing, NFC-based in-event transactions(excluded from this initial test), and more! Your honest and logical feedback will help us deliver the best possible product.

How It Works:

Sign Up: We collect your name and email to have a record of all testers.
Anonymous Feedback: To ensure feedback remains unbiased, it will be stored separately from your details, keeping it anonymous.
If youโ€™re interested in being part of our journey and providing valuable insights, please visit our beta program page below:

๐Ÿ‘‰ Join the Tick8 Plus Beta Program (https://www.tick8plus.com/ -program)

We look forward to your participation and thank you for helping us make Tick8 Plus better!

Something to note:
In the attendee app, currently, all payments are in the demo stage, so there no actual deduction will be made.

For stripe payment, you can use the following test details
Card number:
424242424242424242 - expiry:
04/26 | cvv: 424

MTN Momo: any valid 10 digit (0880112233)

Wallet: To use the wallet method as payment, you need to firstly access the wallet screen and top up your wallet using mtn momo (0880112233). Then, you can test the wallet payment feature...

For organizer: The available amount to withdraw will only show after your event has ended. Once your available amount to withdraw is available, you can withdraw using MTN Momo(only for now)Try this new platform

04/02/2024

๐Ÿš€ ๐—จ๐—ป๐—น๐—ผ๐—ฐ๐—ธ๐—ถ๐—ป๐—ด ๐——๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ ๐—ฅ๐—ฒ๐—น๐—ถ๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†: ๐—จ๐—ป๐—ฑ๐—ฒ๐—ฟ๐˜€๐˜๐—ฎ๐—ป๐—ฑ๐—ถ๐—ป๐—ด ๐—”๐—–๐—œ๐—— ๐—ฃ๐—ฟ๐—ผ๐—ฝ๐—ฒ๐—ฟ๐˜๐—ถ๐—ฒ๐˜€ ๐Ÿš€

Ever wondered how databases ensure the reliability and integrity of your data, especially in critical applications like banking and healthcare? Let's delve into the world of ACID properties โ€“ the backbone of database transactions!

๐ŸญอŸ.อŸ อŸ๐—ชอŸ๐—ตอŸ๐—ฎอŸ๐˜อŸ อŸ๐—ถอŸ๐˜€อŸ อŸ๐—”อŸ๐—–อŸ๐—œอŸ๐——อŸ อŸ๐—ฃอŸ๐—ฟอŸ๐—ผอŸ๐—ฝอŸ๐—ฒอŸ๐—ฟอŸ๐˜อŸ๐˜†อŸ อŸ๐—ผอŸ๐—ณอŸ อŸ๐——อŸ๐—ฎอŸ๐˜อŸ๐—ฎอŸ๐—ฏอŸ๐—ฎอŸ๐˜€อŸ๐—ฒอŸ:อŸ

ACID is like a set of rules that databases follow to make sure they handle data reliably and safely. It stands for:

๐—”๐˜๐—ผ๐—บ๐—ถ๐—ฐ๐—ถ๐˜๐˜†: Treats a set of operations as one whole thing. Either all of them happen, or none of them.

Description:

Start Transaction:

The transaction begins.
Execute Operations: Multiple operations are executed as part of the transaction.

Checkpoint:
A checkpoint is reached. At this point, the system ensures that all operations have been completed successfully.

Commit:
If all operations succeed, the changes are committed to the database. If any operation fails, a rollback is performed, and the changes are discarded.

๐—–๐—ผ๐—ป๐˜€๐—ถ๐˜€๐˜๐—ฒ๐—ป๐—ฐ๐˜†: Makes sure that the database is in a valid state before and after transactions.

Description:
Start Transaction:
The transaction begins.

Execute Operations:
Multiple operations are executed as part of the transaction.

Consistency Check:
After each operation, a consistency check is performed to ensure that the database remains in a consistent state.

Commit:
If the consistency check passes for all operations, the changes are committed to the database. If any consistency check fails, a rollback is performed

๐—œ๐˜€๐—ผ๐—น๐—ฎ๐˜๐—ถ๐—ผ๐—ป: Keeps different transactions separate, so they don't interfere with each other.

Description:
Start Transaction (T1): Transaction T1 begins.
Start Transaction (T2): Concurrently, another transaction T2 begins.

Execute Operations (T1 and T2): Both transactions execute their respective operations concurrently.
Isolation: The operations of each transaction are isolated from each other, and neither is aware of the other's changes until they are committed.

Commit (T1 and T2): Each transaction independently commits its changes to the database.

๐——๐˜‚๐—ฟ๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†: Once a transaction is complete, its changes are permanent, even if something goes wrong.

Description:
Commit: The transaction commits its changes to the database.

Write to Log: The committed changes are written to a transaction log or journal.
Checkpoint: Periodically, the system creates a checkpoint, ensuring that all committed changes are permanently stored.

Recovery: In the event of a failure, the system can use the transaction log to recover the database to its last consistent state.

Imagine ACID like baking a cake. You want all the ingredients mixed (atomicity), the cake to taste good (consistency), each step to be done without messing with other recipes (isolation), and once it's baked, it stays baked (durability).

Please give us a follow if you love this
Clever Engineer

Photos from Clever Engineer's post 03/02/2024

๐—ฅ๐—˜๐—ฆ๐—ง ๐—”๐—ฃ๐—œ๐˜€: ๐—ง๐—ต๐—ฒ ๐—–๐—ผ๐—ป๐—ฒ๐—ฟ๐˜€๐˜๐—ผ๐—ป๐—ฒ ๐—ผ๐—ณ ๐— ๐—ผ๐—ฑ๐—ฒ๐—ฟ๐—ป ๐—ช๐—ฒ๐—ฏ ๐——๐—ฒ๐˜ƒ๐—ฒ๐—น๐—ผ๐—ฝ๐—บ๐—ฒ๐—ป๐˜

As a software engineer, I've always been passionate about sharing my knowledge and simplifying complex technical concepts. This presentation on REST APIs aims to provide a comprehensive understanding

Let's dive into the world of REST APIs with an analogy that might resonate.

Think of a REST API as a waiter at a restaurant. You, the client (or in API terms, the user), sit at the table (your device) and request a menu (data). The waiter (REST API) takes your order (request) to the kitchen (server), and soon enough, your dish (response) arrives.

Now, just like a restaurant has various actions โ€“ ordering, updating preferences, or even canceling an order โ€“ a REST API has different methods:

๐—š๐—˜๐—ง: Fetches specific data.
๐—ฃ๐—ข๐—ฆ๐—ง: Adds new data.
๐—ฃ๐—จ๐—ง: Updates existing data.
๐ƒ๐„๐‹๐„๐“๐„: Removes specific data.
๐—ฃ๐—”๐—ง๐—–๐—›: Makes partial updates.

Responses from the API are like the waiter's service โ€“ either successful (your order is delivered) or an error (oops, kitchen couldn't handle it).

Understanding this helps whether you're into software or just curious about how things online work together. I made this simple presentation to break down the basics of REST APIs. If you're diving into tech or just want to know more, I'm here to help. Expect more easy-to-understand stuff from me in the future! Got questions or thoughts? Let's chats

also if you like what we are doing you can follow us here on Facebook Clever Engineer

01/02/2024

๐ˆ๐ง ๐ฌ๐ฒ๐ฌ๐ญ๐ž๐ฆ ๐๐ž๐ฌ๐ข๐ ๐ง ๐ˆ๐ง๐ญ๐ž๐ซ๐ฏ๐ข๐ž๐ฐ๐ฌ ๐ฒ๐จ๐ฎ ๐ฐ๐ข๐ฅ๐ฅ ๐›๐ž ๐š๐ฌ๐ค ๐ญ๐ก๐ข๐ฌ ๐ช๐ฎ๐ž๐ฌ๐ญ๐ข๐จ๐ง ๐ญ๐จ ๐๐ž๐ฌ๐ข๐ ๐ง ๐š ๐ซ๐š๐ญ๐ž ๐ฅ๐ข๐ฆ๐ข๐ญ๐ž๐ซ

A rate limiter serves as a throttle for API endpoints, defining the allowable frequency of API calls within a specified time interval.

๐‘Šโ„Ž๐‘ฆ ๐‘–๐‘  ๐‘Ž ๐‘Ÿ๐‘Ž๐‘ก๐‘’ ๐‘™๐‘–๐‘š๐‘–๐‘ก๐‘’๐‘Ÿ ๐‘๐‘Ÿ๐‘ข๐‘๐‘–๐‘Ž๐‘™?

It safeguards against potential DOS attacks on APIs and, additionally,

It also curtails costs by processing only those requests that need to be executed within a designated time frame.

When crafting a rate limiter, it's crucial to weigh where to implement itโ€”whether on the client side, server side, or within middleware. The choice depends entirely on the specific problem you are addressing. But the recommend best place is the server

Here are various types of rate limiter algorithms to consider:

๐“๐จ๐ค๐ž๐ง ๐๐ฎ๐œ๐ค๐ž๐ญ ๐€๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ
๐‹๐ž๐š๐ค๐ฒ ๐๐ฎ๐œ๐ค๐ž๐ญ ๐€๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ
๐…๐ข๐ฑ๐ž๐ ๐–๐ข๐ง๐๐จ๐ฐ ๐‚๐จ๐ฎ๐ง๐ญ๐ž๐ซ
๐’๐ฅ๐ข๐๐ข๐ง๐  ๐–๐ข๐ง๐๐จ๐ฐ ๐‚๐จ๐ฎ๐ง๐ญ๐ž๐ซ
๐ƒ๐ข๐ฌ๐ญ๐ซ๐ข๐›๐ฎ๐ญ๐ž๐ ๐‘๐š๐ญ๐ž ๐‹๐ข๐ฆ๐ข๐ญ๐ข๐ง๐ 

๐—ง๐—ผ๐—ธ๐—ฒ๐—ป ๐—•๐˜‚๐—ฐ๐—ธ๐—ฒ๐˜ ๐—”๐—น๐—ด๐—ผ๐—ฟ๐—ถ๐˜๐—ต๐—บ

Maintain a bucket with tokens, each representing the right to make an API call.
Tokens are added to the bucket at a fixed rate.
When an API call is made, a token is consumed from the bucket.
If the bucket is empty, further API calls are delayed until tokens are replenished.

๐—Ÿ๐—ฒ๐—ฎ๐—ธ๐˜† ๐—•๐˜‚๐—ฐ๐—ธ๐—ฒ๐˜ ๐—”๐—น๐—ด๐—ผ๐—ฟ๐—ถ๐˜๐—ต๐—บ

Conceptually, requests "leak" into a bucket at a fixed rate.
When a request arrives, it is placed in the bucket.
If the bucket is full, excess requests are discarded or delayed.
Requests are processed at a constant rate, preventing bursts of traffic.

๐—™๐—ถ๐˜… ๐˜„๐—ถ๐—ป๐—ฑ๐—ผ๐˜„

Maintain a counter for each fixed time window.
Increment the counter for each API call within the window.
Reset the counter at the end of the window.
Limit the total count within the window to control the rate.

๐—ฆ๐—น๐—ถ๐—ฑ๐—ถ๐—ป๐—ด ๐—ช๐—ถ๐—ป๐—ฑ๐—ผ๐˜„ ๐—–๐—ผ๐˜‚๐—ป๐˜๐—ฒ๐—ฟ

Similar to the fixed window counter, but the time window "slides" continuously.
Track the count of API calls within the most recent time interval.
Enforce a limit on the total count within the sliding window.

๐——๐—ถ๐˜€๐˜๐—ฟ๐—ถ๐—ฏ๐˜‚๐˜๐—ฒ๐—ฑ ๐—ฅ๐—ฎ๐˜๐—ฒ ๐—Ÿ๐—ถ๐—บ๐—ถ๐˜๐—ถ๐—ป๐—ด

Use multiple rate limiters distributed across different components or servers.
Centralized coordination or distributed algorithms ensure a global rate limit is maintained.
Effective for large-scale systems to prevent overloads and ensure fair resource allocation.

Each algorithm provides a different approach to controlling the rate of API requests, allowing system designers to choose based on specific requirements and characteristics of their applications.

Follow Clever Engineer for more quality tech knowledge

Want your school to be the top-listed School/college in Monrovia?
Click here to claim your Sponsored Listing.

Telephone

Website

Address


9 Street Sinkor
Monrovia
1000