How a URL Shortener Works
A URL shortener turns a long web address into a short one, and sends everyone who clicks it to the real page. A public service must create millions of short links, never give the same one to two pages, and answer every click fast. This page follows one article that designs such a service step by step. It is not the exact system that TinyURL or Bitly runs.
9 min read9 মিনিটে পড়া যায় · 9 sections9টি সেকশন · 1 source1টি সোর্স · updated Oct 2026আপডেট: Oct 2026
Why a click is cheapকেন একটা ক্লিক সস্তা
A click passes layers of copies, so the database sees few reads. Move the hit rate and watch it drop.একটা ক্লিক কপির কয়েকটা লেয়ার পার হয়, তাই ডেটাবেসে কম রিড পৌঁছায়। হিট রেট সরান আর কমতে দেখুন।
You’ll learnআপনি শিখবেন
- A short code of 7 characters gives about 3.5 trillion codes7 অক্ষরের শর্ট কোডে প্রায় 3.5 trillion কোড হয়✓
- Reads are 100 times more than writesপড়া লেখার চেয়ে 100 গুণ বেশি
- Each layer of copies answers some clicksকপির প্রতিটা লেয়ার কিছু ক্লিকের উত্তর দেয়
- The database sees only the missesডেটাবেস শুধু মিস দেখে
- A TTL makes a cached entry expireTTL ক্যাশের এন্ট্রির মেয়াদ শেষ করে
The problem in plain words
The service does two jobs. First, a person gives it a long link and gets back a short link. Second, anyone who opens the short link must land on the long page Source 1সোর্স 1. The article names tinyurl.com and bitly.com as well-known public services of this kind Source 1সোর্স 1.
People use short links for several reasons. Short links look cleaner, they let the owner count clicks, and some chat tools limit how many characters a link can have Source 1সোর্স 1.
The article sets these numbers for its design Source 1সোর্স 1:
| Item | Value in the article |
|---|---|
| Daily active users who create links | 100 million |
| Reads for each write | 100 to 1 |
| How long a short link lives by default | 5 years |
| Longest allowed short code | 9 characters |
| Read requests per second | about 100 thousand |
| Size of one stored link record | about 2.5 KB |
The read-to-write ratio is the key number. For each link that somebody creates, the service handles about 100 clicks Source 1সোর্স 1. So the design must make clicks very fast and very cheap. The article also expects that most short links get opened only one time after they are made Source 1সোর্স 1.
সহজ English
The service does two jobs. First, a person gives it a long link and gets back a short link. Second, a person who opens the short link must land on the long page Source 1সোর্স 1. The article names tinyurl.com and bitly.com as well-known public services of this kind Source 1সোর্স 1.
People use short links because they look cleaner, they let the owner count clicks, and some chat tools limit the number of characters in a link Source 1সোর্স 1.
The article sets these numbers for its design Source 1সোর্স 1: 100 million daily active users who create links, 100 reads for each write, a default life of 5 years for a short link, a maximum of 9 characters in a short code, about 100 thousand read requests per second, and about 2.5 KB for one stored link record.
The most important number is the read-to-write ratio. For each new link, the service handles about 100 clicks Source 1সোর্স 1. So clicks must be very fast and very cheap. The article also expects that people open most short links only one time after they are made Source 1সোর্স 1.
বাংলা ব্যাখ্যা
এই service দুটি কাজ করে। প্রথমত, একজন ব্যক্তি একটি long link দেন এবং বিনিময়ে একটি short link পান। দ্বিতীয়ত, যে কেউ short link-টি খুললে তাঁকে long page-এ পৌঁছাতে হবে Source 1সোর্স 1। Article-টি tinyurl.com আর bitly.com-কে এই ধরনের পরিচিত public service হিসেবে উল্লেখ করে Source 1সোর্স 1।
মানুষ কয়েকটি কারণে short link ব্যবহার করেন। Short link দেখতে পরিষ্কার, এতে owner click গুনতে পারেন, আর কিছু chat tool একটি link-এ কতগুলো character থাকতে পারে, তা সীমিত করে Source 1সোর্স 1।
Article-টি তার design-এর জন্য এই সংখ্যাগুলো ধরে নেয় Source 1সোর্স 1: link তৈরি করেন এমন 100 million daily active user; প্রতিটি write-এর বিপরীতে 100টি read; একটি short link-এর default মেয়াদ 5 বছর; short code-এ সর্বোচ্চ 9টি character; প্রতি সেকেন্ডে প্রায় 100 হাজার read request; আর একটি stored link record-এর আকার প্রায় 2.5 KB।
সবচেয়ে গুরুত্বপূর্ণ সংখ্যা হলো read-to-write ratio। কেউ একটি link তৈরি করলে service সেটির জন্য প্রায় 100টি click সামলায় Source 1সোর্স 1। তাই design-কে click খুব দ্রুত আর খুব সস্তা করতে হবে। Article আরও ধরে নেয় যে বেশিরভাগ short link তৈরি হওয়ার পর মাত্র একবার খোলা হয় Source 1সোর্স 1।
The big picture
WRITE PATH (create a link)
[User] --> [Load balancer] --> [Server] --> [Key Generation Service]
| |
v v
[Database] <-- short code + long URL
READ PATH (open a link)
[Browser] --> [DNS] --> [CDN] --> [Reverse proxy] --> [Cache] --> [Database]
^ |
+------------------ 301 redirect to long URL --------+On the write path, the server asks a separate service for a fresh short code, then saves the pair "short code to long link" in the database Source 1সোর্স 1. On the read path, the click passes through layers of copies (CDN, proxy, cache) before it touches the database Source 1সোর্স 1. Each layer tries to answer from memory so the database stays calm. The service then tells the browser where to go next.
সহজ English
The design has two paths.
On the write path, a person creates a link. The request goes through a load balancer to a server. The server asks a separate service, the Key Generation Service, for a new short code. Then the server saves the pair "short code to long link" in the database Source 1সোর্স 1.
On the read path, a person opens a link. The click goes from the browser through DNS, a CDN, a reverse proxy, and a cache, before it gets to the database Source 1সোর্স 1. The CDN, the proxy, and the cache are layers of copies. Each layer tries to answer from memory, so the database has less work. Then the service tells the browser where to go next, with a 301 redirect to the long URL.
বাংলা ব্যাখ্যা
এই design-এ দুটি path আছে।
Write path-এ একজন ব্যক্তি একটি link তৈরি করেন। Request-টি load balancer হয়ে একটি server-এ যায়। Server একটি আলাদা service, অর্থাৎ Key Generation Service-এর কাছে একটি নতুন short code চায়। তারপর server "short code থেকে long link" জোড়াটি database-এ save করে Source 1সোর্স 1।
Read path-এ একজন ব্যক্তি একটি link খোলেন। Click-টি browser থেকে DNS, CDN, reverse proxy আর cache পার হয়ে তবেই database-এ পৌঁছায় Source 1সোর্স 1। CDN, proxy আর cache হলো copy রাখার কয়েকটি layer। প্রতিটি layer memory থেকে উত্তর দেওয়ার চেষ্টা করে, যাতে database-এর ওপর চাপ কম থাকে। এরপর service browser-কে একটি 301 redirect দিয়ে long URL-এ যেতে বলে।
Making a short code
Think of a coat check at a theatre. You hand over your coat and get a small numbered ticket. The ticket must be unique, or two people walk home with the same coat.
The short code is that ticket. The article encodes it in base62, which uses only letters and digits Source 1সোর্স 1. A related format, base58, drops look-alike characters such as zero and capital O Source 1সোর্স 1. With 7 base62 characters there are about 3.5 trillion possible codes Source 1সোর্স 1. The article says that supply lasts about 100 years if the service uses 1,000 codes every second Source 1সোর্স 1. So 7 characters is the length it picks Source 1সোর্স 1.
The article compares three ways to make the code Source 1সোর্স 1:
| Way | How it works | Main problem |
|---|---|---|
| Random ID | Pick a random value for each link | Two links can get the same code, so every new code needs a database check |
| Hash of the long URL | Run a hash function such as MD5 and keep the first 7 characters | Different links can share the first 7 characters, and the code is easy to guess |
| Token range | Each server counts up through its own block of numbers | Codes come in order, so they are easy to guess unless you add random bits |
A hash function turns any input into a fixed-size fingerprint. The same input always gives the same fingerprint.
The article picks the token range method Source 1সোর্স 1. A coordinator hands each code-making server its own block of numbers, so two servers never hand out the same code. The article names Apache ZooKeeper or Amazon DynamoDB as possible coordinators Source 1সোর্স 1. When a server uses up its block, it asks for a new one Source 1সোর্স 1.
What a Bloom filter is
A Bloom filter is a small, fast memory check that answers "have I seen this before?" It can say "maybe yes" by mistake, but it never says "no" by mistake. The article uses one to skip slow database lookups Source 1সোর্স 1.
সহজ English
The article writes the code in base62, which uses only letters and digits Source 1সোর্স 1. A related format, base58, removes characters that look alike, such as zero and capital O Source 1সোর্স 1. 7 base62 characters give about 3.5 trillion codes, enough for about 100 years at 1,000 codes every second. So the article picks 7 characters Source 1সোর্স 1.
The article compares three ways to make the code Source 1সোর্স 1:
- Random ID. Two links can get the same code, so each new code needs a database check.
- Hash of the long URL. A hash function, such as MD5, makes a fingerprint of the link. The service keeps its first 7 characters. Different links can share them, and the code is easy to guess.
- Token range. Each server counts up through its own block of numbers. The codes come in order, so they are easy to guess without random bits.
The article picks the token range Source 1সোর্স 1. A coordinator, such as Apache ZooKeeper or Amazon DynamoDB, gives each server its own block. So no two servers give the same code Source 1সোর্স 1.
বাংলা ব্যাখ্যা
Theatre-এর coat check-এর কথা ভাবুন। আপনি coat জমা দিয়ে একটি ছোট নম্বরওয়ালা ticket পান। Ticket-টি unique হতে হবে, নইলে দুজন মানুষ একই coat নিয়ে বাড়ি যাবেন। Short code হলো সেই ticket।
Article-টি code-টি base62-এ লেখে, যেখানে শুধু অক্ষর আর অঙ্ক থাকে Source 1সোর্স 1। এর কাছাকাছি একটি format, base58, দেখতে একই রকম character বাদ দেয়, যেমন শূন্য আর capital O Source 1সোর্স 1। 7টি base62 character দিয়ে প্রায় 3.5 trillion code সম্ভব। প্রতি সেকেন্ডে 1,000টি code ব্যবহার করলে এই মজুত প্রায় 100 বছর চলে। তাই article 7টি character বেছে নেয় Source 1সোর্স 1।
Article-টি code তৈরির তিনটি উপায় তুলনা করে Source 1সোর্স 1:
- Random ID। প্রতিটি link-এর জন্য একটি random value নেওয়া হয়। দুটি link একই code পেতে পারে, তাই প্রতিটি নতুন code-এর জন্য database check লাগে।
- Long URL-এর hash। MD5-এর মতো একটি hash function চালিয়ে প্রথম 7টি character রাখা হয়। Hash function যেকোনো input থেকে একটি নির্দিষ্ট আকারের fingerprint বানায়। আলাদা link-এর প্রথম 7টি character একই হতে পারে, আর code সহজে অনুমান করা যায়।
- Token range। প্রতিটি server নিজের একটি নম্বরের block ধরে গুনে এগোয়। Code-গুলো ক্রমানুসারে আসে, তাই random bit যোগ না করলে সেগুলো সহজে অনুমান করা যায়।
Article token range পদ্ধতি বেছে নেয় Source 1সোর্স 1। একটি coordinator প্রতিটি server-কে আলাদা block দেয়, তাই দুটি server কখনো একই code দেয় না। Article Apache ZooKeeper বা Amazon DynamoDB-কে সম্ভাব্য coordinator হিসেবে উল্লেখ করে। কোনো server-এর block শেষ হলে সেটি নতুন block চায় Source 1সোর্স 1।
Sending the click to the right page
Picture a mail forwarding service. Your old address gets a letter, and the post office puts a new label on it and sends it to your new home.
When a browser opens a short link, the server answers with an HTTP redirect. The redirect is a short reply that says "the page you want is over there." It carries the long address in the location header Source 1সোর্স 1. The browser then makes a second request to the long address by itself Source 1সোর্স 1.
The article compares redirect codes Source 1সোর্স 1:
| Code | Meaning | Effect |
|---|---|---|
| 301 Moved Permanently | The short link always points here | Search engines update their records; browsers keep a copy |
| 302 Found | A temporary move | No search ranking benefit for the long page |
| 307 Temporary Redirect | A temporary move that keeps the method | The browser may repeat a PUT or POST to the new address |
| 404 Not Found | No such short code | The user sees an error |
The article chooses 301 Source 1সোর্স 1. But a 301 lets the browser keep its own copy. If the browser never asks the server again, the service cannot count the click. So the article sets the cache header to public. This moves the copy to the CDN and proxy layer, where the service still sees the traffic Source 1সোর্স 1.
সহজ English
When a browser opens a short link, the server answers with an HTTP redirect. It tells the browser where the page is. It carries the long address in the location header Source 1সোর্স 1. Then the browser itself sends a second request to the long address Source 1সোর্স 1.
The article compares redirect codes Source 1সোর্স 1:
- 301 Moved Permanently. The short link always points here. Search engines update their records, and browsers keep a copy.
- 302 Found. A temporary move. The long page gets no search ranking benefit.
- 307 Temporary Redirect. A temporary move that keeps the method. The browser can send a PUT or POST again to the new address.
- 404 Not Found. No such short code. The user sees an error.
The article chooses 301 Source 1সোর্স 1. But with a 301, the browser can keep its own copy. If the browser does not ask the server again, the service cannot count the click. So the article sets the cache header to public. Then the copy moves to the CDN and proxy layer, where the service still sees the traffic Source 1সোর্স 1.
বাংলা ব্যাখ্যা
Mail forwarding service-এর কথা ভাবুন। আপনার পুরোনো ঠিকানায় একটি চিঠি এলে post office তাতে নতুন label লাগিয়ে আপনার নতুন বাড়িতে পাঠিয়ে দেয়।
Browser একটি short link খুললে server একটি HTTP redirect দিয়ে উত্তর দেয়। Redirect হলো একটি ছোট উত্তর, যা বলে "আপনি যে page চান, সেটি ওখানে আছে।" এটি long address-টি location header-এ বহন করে Source 1সোর্স 1। তারপর browser নিজেই long address-এ দ্বিতীয় একটি request পাঠায় Source 1সোর্স 1।
Article-টি এই redirect code-গুলো তুলনা করে Source 1সোর্স 1:
- 301 Moved Permanently। Short link সবসময় এখানেই নির্দেশ করে। Search engine তাদের record update করে, আর browser একটি copy রেখে দেয়।
- 302 Found। একটি অস্থায়ী সরানো। Long page কোনো search ranking সুবিধা পায় না।
- 307 Temporary Redirect। Method ঠিক রেখে একটি অস্থায়ী সরানো। Browser নতুন address-এ PUT বা POST আবার পাঠাতে পারে।
- 404 Not Found। এমন কোনো short code নেই। User একটি error দেখেন।
Article 301 বেছে নেয় Source 1সোর্স 1। কিন্তু 301 পেলে browser নিজের একটি copy রাখতে পারে। Browser যদি আর কখনো server-কে জিজ্ঞেস না করে, তাহলে service click-টি গুনতে পারে না। তাই article cache header-কে public করে দেয়। এতে copy-টি CDN আর proxy layer-এ চলে যায়, যেখানে service তখনও traffic দেখতে পায় Source 1সোর্স 1।
Keeping popular links fast
Think of a library with a "most borrowed" shelf at the front desk. The staff do not walk to the back rooms for the books that everyone wants.
A cache is that front shelf. It keeps recent answers in fast memory. The article follows an 80/20 rule: about 20% of links get about 80% of clicks, so it caches those Source 1সোর্স 1. It suggests a time-to-live of one day, after which a cached entry expires Source 1সোর্স 1. It names Redis or Memcached as cache servers Source 1সোর্স 1.
The design uses the cache-aside pattern. The server checks the cache first. On a miss, it reads the database and then fills the cache Source 1সোর্স 1. When the cache is full, it removes the least recently used entries Source 1সোর্স 1.
Two extra tricks protect the system:
- One-click links. Many links are opened only once. Filling the cache with them wastes space. So a Bloom filter records the first visit, and the cache stores a link only on a repeat visit Source 1সোর্স 1.
- Codes that do not exist. A second Bloom filter on short codes lets the service return 404 without a cache or database lookup Source 1সোর্স 1.
Sometimes thousands of people open the same hot link at the same moment. Then the cache or proxy sends just one request to the origin server and shares the answer with all of them. The article calls this collapsed forwarding Source 1সোর্স 1.
সহজ English
A cache keeps recent answers in fast memory. The article uses an 80/20 rule: about 20% of links get about 80% of clicks, so it caches them Source 1সোর্স 1. It suggests that a cached entry expires after one day Source 1সোর্স 1. The article names Redis or Memcached as cache servers Source 1সোর্স 1.
In the cache-aside pattern, the server checks the cache first. If the link is not there, it reads the database and fills the cache Source 1সোর্স 1. A full cache removes the least recently used entries Source 1সোর্স 1.
A Bloom filter is a fast "seen before?" check.
- Many links are opened only once. So a Bloom filter records the first visit, and the cache keeps a link only on a repeat visit Source 1সোর্স 1.
- A second Bloom filter on short codes lets the service return 404 for an unknown code, with no cache or database lookup Source 1সোর্স 1.
If thousands of people open one link at once, the cache or proxy sends only one request to the origin server and shares the answer with all. The article calls this collapsed forwarding Source 1সোর্স 1.
বাংলা ব্যাখ্যা
একটি library-র কথা ভাবুন, যার front desk-এ "সবচেয়ে বেশি ধার নেওয়া" বইয়ের একটি তাক আছে। সবাই যে বই চান, সেগুলোর জন্য staff-কে পেছনের ঘরে যেতে হয় না।
Cache হলো সেই সামনের তাক। এটি সাম্প্রতিক উত্তরগুলো দ্রুত memory-তে রাখে। Article একটি 80/20 নিয়ম মানে: প্রায় 20% link প্রায় 80% click পায়, তাই সেগুলোকে cache করা হয় Source 1সোর্স 1। এটি এক দিনের time-to-live প্রস্তাব করে, যার পরে cache-এর entry মেয়াদোত্তীর্ণ হয় Source 1সোর্স 1। Cache server হিসেবে article Redis বা Memcached-এর নাম বলে Source 1সোর্স 1।
Design-টি cache-aside pattern ব্যবহার করে। Server প্রথমে cache দেখে। Cache-এ না পেলে database পড়ে, তারপর cache ভরে দেয় Source 1সোর্স 1। Cache ভরে গেলে সবচেয়ে কম সম্প্রতি ব্যবহৃত (least recently used) entry-গুলো সরিয়ে দেয় Source 1সোর্স 1।
আরও দুটি কৌশল system-কে রক্ষা করে:
- এক-click-এর link। অনেক link মাত্র একবার খোলা হয়। তাই একটি Bloom filter প্রথম visit-টি মনে রাখে, আর link-টি দ্বিতীয়বার খোলা হলে তবেই cache তা রাখে Source 1সোর্স 1।
- যে code নেই। Short code-এর ওপর দ্বিতীয় একটি Bloom filter থাকায় service cache বা database না দেখেই 404 দিতে পারে Source 1সোর্স 1।
কখনো হাজার হাজার মানুষ একই মুহূর্তে একই জনপ্রিয় link খোলেন। তখন cache বা proxy origin server-এ মাত্র একটি request পাঠায় এবং উত্তরটি সবার সাথে ভাগ করে। Article এর নাম দেয় collapsed forwarding Source 1সোর্স 1।
Storing links and cleaning up
The article stores the link table in a NoSQL database such as DynamoDB or MongoDB Source 1সোর্স 1. NoSQL means a database that does not use fixed relational tables, and it spreads data across many machines easily. The user accounts go into a SQL database (Postgres or MySQL), because that data is relational and needs strict rules Source 1সোর্স 1. The article suggests at least three copies of the stored data for safety Source 1সোর্স 1.
The data is split into shards by short code Source 1সোর্স 1. A shard is one slice of the data on its own machine. To find the code of a long link that is already stored, the article adds a second store keyed by the long link Source 1সোর্স 1.
Old links must go. The article offers two ways Source 1সোর্স 1:
- Lazy removal. When someone opens an expired link, the service deletes it and returns 404.
- A cleanup job. A job scans for expired links during quiet hours and stops if traffic spikes.
Links that nobody opened for a long time, such as 3 years, can be compressed and moved to object storage like AWS S3 Source 1সোর্স 1.
সহজ English
The article keeps the link table in a NoSQL database, such as DynamoDB or MongoDB Source 1সোর্স 1. A NoSQL database does not use fixed relational tables, and it spreads data across many machines easily. The user accounts go into a SQL database (Postgres or MySQL), because that data is relational and needs strict rules Source 1সোর্স 1. The article suggests at least three copies of the stored data, for safety Source 1সোর্স 1.
The data is split into shards by short code. A shard is one slice of the data on its own machine. A second store, keyed by the long link, finds the code of a stored long link Source 1সোর্স 1.
The article gives two ways to remove old links Source 1সোর্স 1:
- Lazy removal. When a person opens an expired link, the service deletes it and returns 404.
- A cleanup job. A job looks for expired links in quiet hours. It stops if traffic goes up fast.
The service can compress links that nobody opened for a long time, such as 3 years, and move them to object storage, such as AWS S3 Source 1সোর্স 1.
বাংলা ব্যাখ্যা
Article link table-টি DynamoDB বা MongoDB-এর মতো একটি NoSQL database-এ রাখে Source 1সোর্স 1। NoSQL মানে এমন database, যা নির্দিষ্ট relational table ব্যবহার করে না এবং সহজে অনেক machine-এ data ছড়িয়ে দেয়। User account-গুলো যায় একটি SQL database-এ (Postgres বা MySQL), কারণ সেই data relational এবং তার জন্য কঠোর নিয়ম দরকার Source 1সোর্স 1। নিরাপত্তার জন্য article stored data-র অন্তত তিনটি copy রাখার পরামর্শ দেয় Source 1সোর্স 1।
Data-কে short code অনুযায়ী shard-এ ভাগ করা হয় Source 1সোর্স 1। Shard হলো data-র একটি অংশ, যা নিজের আলাদা machine-এ থাকে। আগে থেকে stored একটি long link-এর code খুঁজতে article long link দিয়ে key করা দ্বিতীয় একটি store যোগ করে Source 1সোর্স 1।
পুরোনো link সরাতে হয়। Article দুটি উপায় দেয় Source 1সোর্স 1:
- Lazy removal। কেউ মেয়াদোত্তীর্ণ link খুললে service সেটি delete করে এবং 404 দেয়।
- একটি cleanup job। একটি job শান্ত সময়ে মেয়াদোত্তীর্ণ link খোঁজে, আর traffic হঠাৎ বেড়ে গেলে থেমে যায়।
যে link অনেক দিন, যেমন 3 বছর, কেউ খোলেননি, সেগুলো compress করে AWS S3-এর মতো object storage-এ সরিয়ে রাখা যায় Source 1সোর্স 1।
Same link, many users at once
The design wants a one-to-one rule: the same long link always gets the same short code Source 1সোর্স 1. If two people submit the same link at the same instant, both could get different codes. The article solves this with a distributed lock on the long link Source 1সোর্স 1. A lock is like a "room in use" sign: only one request can work on that link at a time. The article names Chubby or a Redis lock as options Source 1সোর্স 1.
The article also adds rate limiting, which caps how many requests one client can send Source 1সোর্স 1. For analytics, each click puts a message on a queue such as Apache Kafka, and a batch job processes the clicks later Source 1সোর্স 1. The article says Bitly earns money by offering analytics on redirects Source 1সোর্স 1.
সহজ English
The design wants a one-to-one rule: the same long link always gets the same short code Source 1সোর্স 1. If two people send the same link at the same instant, they can get different codes. The article solves this with a distributed lock on the long link Source 1সোর্স 1. A lock is like a "room in use" sign: only one request can work on that link at a time. The article names Chubby or a Redis lock as options Source 1সোর্স 1.
The article also adds rate limiting. Rate limiting sets a maximum number of requests that one client can send Source 1সোর্স 1. For analytics, each click puts a message on a queue, such as Apache Kafka. A batch job processes the clicks later Source 1সোর্স 1. The article says that Bitly earns money when it offers analytics on redirects Source 1সোর্স 1.
বাংলা ব্যাখ্যা
Design-টি একটি one-to-one নিয়ম চায়: একই long link সবসময় একই short code পাবে Source 1সোর্স 1। দুজন মানুষ একই মুহূর্তে একই link জমা দিলে দুজন আলাদা code পেতে পারেন। Article long link-এর ওপর একটি distributed lock দিয়ে এর সমাধান করে Source 1সোর্স 1। Lock হলো "ঘর ব্যবহার হচ্ছে" লেখা একটি চিহ্নের মতো: একবারে মাত্র একটি request সেই link নিয়ে কাজ করতে পারে। Article Chubby বা একটি Redis lock-কে বিকল্প হিসেবে উল্লেখ করে Source 1সোর্স 1।
Article rate limiting-ও যোগ করে, যা একটি client কতগুলো request পাঠাতে পারে, তার একটি সীমা ঠিক করে Source 1সোর্স 1। Analytics-এর জন্য প্রতিটি click Apache Kafka-র মতো একটি queue-তে একটি message রাখে, আর একটি batch job পরে click-গুলো process করে Source 1সোর্স 1। Article বলে, Bitly redirect-এর ওপর analytics দিয়ে আয় করে Source 1সোর্স 1।
Key words
| Word | Plain meaning |
|---|---|
| Short code | The few characters at the end of a short link that identify it |
| Redirect | A reply that tells the browser to go to a different address |
| Cache | Fast memory that keeps copies of popular answers |
| CDN | A network of servers close to users that serves copies of content |
| Shard | One slice of a big database, stored on its own machine |
| Replica | A full copy of data kept on another machine for safety |
| Bloom filter | A tiny memory check for "seen before?" that can give false "yes" answers |
| Hash | A fixed-size fingerprint of some data |
| Rate limiting | A cap on how many requests one client can send in a time window |
| Lock | A rule that lets only one worker change something at a time |
What a tester can learn
Tutorial advice
These test ideas are the tutorial's own advice, not claims from the article.
- Uniqueness under load. Create many links in parallel from many clients and check that no two long links share a short code.
- Same link, same code. Submit one long link from many clients at the same instant. Check that all of them get the same short code.
- Redirect codes. Check the status code and
locationheader for a valid code, an unknown code (404), and an expired code. - Cache staleness. Expire or delete a link, then open it again through every layer. Check that no cache still sends users to the old page.
- Bad input. Try very long URLs, custom codes with odd characters, and script tags, to check validation and the defenses against XSS and injection.
- Lost analytics. Kill the analytics queue consumer during a click burst and check that clicks still redirect and that counts recover later.
সহজ English
These test ideas are the tutorial's own advice, not claims from the article.
- Uniqueness under load. Create many links at the same time from many clients. Make sure that no two long links share a short code.
- Same link, same code. Send one long link from many clients at the same instant. Make sure that all of them get the same short code.
- Redirect codes. Check the status code and the
locationheader for a valid code, an unknown code (404), and an expired code. - Cache staleness. Expire or delete a link. Then open it again through every layer. Make sure that no cache still sends users to the old page.
- Bad input. Try very long URLs, custom codes with odd characters, and script tags. This checks the validation and the defenses against XSS and injection.
- Lost analytics. Stop the analytics queue consumer during a burst of clicks. Make sure that the clicks still redirect and that the counts recover later.
বাংলা ব্যাখ্যা
নিচের test ধারণাগুলো এই tutorial-এর নিজস্ব পরামর্শ, article-এর দাবি নয়।
- Load-এর মধ্যে uniqueness। অনেক client থেকে একসাথে অনেক link তৈরি করুন। দেখুন, দুটি long link একই short code পায় কি না।
- একই link, একই code। একই মুহূর্তে অনেক client থেকে একটি long link জমা দিন। দেখুন, সবাই একই short code পায় কি না।
- Redirect code। একটি valid code, একটি অজানা code (404) আর একটি মেয়াদোত্তীর্ণ code-এর জন্য status code আর
locationheader পরীক্ষা করুন। - Cache staleness। একটি link expire বা delete করুন, তারপর প্রতিটি layer দিয়ে সেটি আবার খুলুন। দেখুন, কোনো cache এখনও user-দের পুরোনো page-এ পাঠায় কি না।
- খারাপ input। খুব লম্বা URL, অদ্ভুত character-সহ custom code আর script tag দিয়ে চেষ্টা করুন, যাতে validation আর XSS ও injection-এর বিরুদ্ধে সুরক্ষা পরীক্ষা হয়।
- হারানো analytics। Click-এর ঢেউয়ের সময় analytics queue consumer বন্ধ করে দিন। দেখুন, click-গুলো তখনও redirect হয় কি না এবং পরে count ঠিক হয়ে যায় কি না।